Initial setup for Garadget garage door opener

This commit is contained in:
Bruce Eckstein 2021-09-24 15:42:54 -04:00
parent 7f6ceb4171
commit 0841229136
19 changed files with 1610 additions and 0 deletions

14
garadget/Garadget.pro Normal file
View File

@ -0,0 +1,14 @@
include($$[QT_INSTALL_PREFIX]/include/nymea/plugin.pri)
QT += network
PKGCONFIG += nymea-mqtt
TARGET = $$qtLibraryTarget(nymea_integrationpluginGaradget)
SOURCES += \
integrationpluginGaradget.cpp
HEADERS += \
integrationpluginGaradget.h

323
garadget/Garadget.pro.user Normal file
View File

@ -0,0 +1,323 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.1, 2021-09-22T16:29:05. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{ba25b4ed-600c-4ef0-9f6e-aee74c4d5771}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.Questionable</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">4</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuelist type="QVariantList" key="ProjectExplorer.Project.Environment"/>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{42208f61-3dc1-4538-a721-4593dcfd5243}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/beckstein/nymea-testing/build-Garadget-Desktop-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/beckstein/nymea-testing/build-Garadget-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="int" key="RunSystemFunction">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/beckstein/nymea-testing/build-Garadget-Desktop-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/beckstein/nymea-testing/build-Garadget-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="RunSystemFunction">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/beckstein/nymea-testing/build-Garadget-Desktop-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/home/beckstein/nymea-testing/build-Garadget-Desktop-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="RunSystemFunction">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
<value type="QString">cpu-cycles</value>
</valuelist>
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
<value type="int" key="Analyzer.Perf.Frequency">250</value>
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
<value type="QString">-e</value>
<value type="QString">cpu-cycles</value>
<value type="QString">--call-graph</value>
<value type="QString">dwarf,4096</value>
<value type="QString">-F</value>
<value type="QString">250</value>
</valuelist>
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes">
<value type="QString">LD_LIBRARY_PATH=/home/beckstein/nymea-testing/build-nymea-Desktop-Debug/libnymea/:home/beckstein/nymea-testing/build-nymea-Desktop-Debug/libnymea-core/</value>
<value type="QString">NYMEA_PLUGINS_PATH=/home/beckstein/nymea-testing/build-Garadget-Desktop-Debug
</value>
</valuelist>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">/usr/bin/nymead</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments">-n -d Garadget</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory">/home/beckstein/nymea-testing/working</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

165
garadget/LICENSE.LGPL3 Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

4
garadget/README.md Normal file
View File

@ -0,0 +1,4 @@
# Garadget
--------------------------------
Description of the plugin...

View File

@ -0,0 +1,5 @@
nymea-plugin-Garadget (0.0.1) xenial; urgency=medium
* Initial release.
-- Bruce Eckstein <aeronexcom@gmail.com> Mon, 21 Aug 2017 10:12:00 +0000

1
garadget/debian/compat Normal file
View File

@ -0,0 +1 @@
9

25
garadget/debian/control Normal file
View File

@ -0,0 +1,25 @@
Source: nymea-plugin-Garadget
Section: utils
Priority: options
Maintainer: Bruce Eckstein <aeronexcom@gmail.com>
Build-depends: debhelper (>= 9.0.0),
libnymea1-dev,
nymea-dev-tools:native,
qt5-qmake:native,
pkg-config,
Standards-Version: 3.9.3
Package: nymea-plugin-Garadget
Architecture: any
Multi-Arch: same
Section: libs
Depends: ${shlibs:Depends},
${misc:Depends},
Description: nymea.io plugin for Garadget
The nymea daemon is a plugin based IoT (Internet of Things) server. The
server works like a translator for devices, things and services and
allows them to interact.
With the powerful rule engine you are able to connect any device available
in the system and create individual scenes and behaviors for your environment.
.
This package will install the nymea.io plugin for Garadget

14
garadget/debian/copyright Normal file
View File

@ -0,0 +1,14 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ${ProjectName}
Upstream-Contact: Bruce Eckstein <aeronexcom@gmail.com>
Copyright: 2020, Bruce Eckstein
License: LGPL-3
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in `/usr/share/common-licenses/LGPL-3'.
Files: *
License: LGPL-3
Copyright: Bruce Eckstein <aeronexcom@gmail.com>

View File

@ -0,0 +1 @@
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_integrationpluginGaradget.so

25
garadget/debian/rules Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/make -f
# -*- makefile -*-
export DH_VERBOSE=1
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
PREPROCESS_FILES := $(wildcard debian/*.in)
$(PREPROCESS_FILES:.in=): %: %.in
sed 's,/@DEB_HOST_MULTIARCH@,$(DEB_HOST_MULTIARCH:%=/%),g' $< > $@
%:
dh $@ --parallel
override_dh_install: $(PREPROCESS_FILES:.in=)
make -j9 install DESTDIR=debian/tmp AM_UPDATE_INFO_DIR=no INSTALL_ROOT=debian/tmp
dh_install --fail-missing
override_dh_auto_build:
dh_auto_build
make lrelease
override_dh_auto_clean:
dh_auto_clean
rm -rf $(PREPROCESS_FILES:.in=)

View File

@ -0,0 +1 @@
3.0 (native)

128
garadget/garadget.svg Normal file
View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="Ebene_1"
data-name="Ebene 1"
viewBox="0 0 482.32801 240.97508"
version="1.1"
sodipodi:docname="frontlogo.svg"
inkscape:export-filename="D:\github\docs\_media\logo-blue.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
width="482.328"
height="240.97508"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata37">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Zeichenfläche 1</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1027"
id="namedview35"
showgrid="false"
inkscape:zoom="1.4214414"
inkscape:cx="452.13125"
inkscape:cy="190.01553"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Ebene_1"
height="1"
showguides="true"
inkscape:guide-bbox="true">
<sodipodi:guide
position="234.26924,297.58525"
orientation="0,1"
id="guide6233"
inkscape:locked="false" />
<sodipodi:guide
position="233.56573,165.32514"
orientation="1,0"
id="guide6235"
inkscape:locked="false" />
</sodipodi:namedview>
<defs
id="defs12">
<style
id="style10">.cls-1{fill:#010101;}</style>
</defs>
<title
id="title14">Zeichenfläche 1</title>
<polygon
class="cls-1"
points="44.42,115.07 54.16,124.8 129.62,49.35 205.07,124.8 214.81,115.07 129.62,29.87 "
id="polygon16"
transform="matrix(0.85895992,0,0,0.85895992,122.48759,-25.657133)"
style="fill:#1fa3ec;fill-opacity:1" />
<path
class="cls-1"
d="m 233.81738,51.649254 a 45.181292,45.181292 0 0 0 -16.0969,87.407766 v -13.03901 a 33.327645,33.327645 0 0 1 10.18726,-62.025496 v 82.365666 h 11.82788 V 63.992514 a 33.327645,33.327645 0 0 1 10.18726,62.025496 v 12.99606 a 45.181292,45.181292 0 0 0 -16.1055,-87.364816 z"
id="path18"
inkscape:connector-curvature="0"
style="fill:#1fa3ec;fill-opacity:1;stroke-width:0.85895991" />
<polygon
class="cls-1"
points="860.75,74.18 860.75,60.41 772.33,60.41 772.33,74.18 809.65,74.18 809.65,178.31 823.42,178.31 823.42,74.18 "
id="polygon20"
style="fill:#000000;fill-opacity:1"
transform="matrix(0.7,0,0,0.7,-187.838,115.35308)" />
<polygon
class="cls-1"
points="356.75,74.18 356.75,60.41 268.34,60.41 268.34,74.18 305.66,74.18 305.66,178.31 319.43,178.31 319.43,74.18 "
id="polygon22"
style="fill:#000000;fill-opacity:1"
transform="matrix(0.7,0,0,0.7,-187.838,115.35308)" />
<path
class="cls-1"
d="m 118.839,240.17008 h 10.696 c -8.673,-17.759 -30.695,-66.353 -30.695,-82.53 H 88.746 c 0,16.177 -22.015,64.771 -30.688,82.53 h 10.689 c 2.576,-5.418 7.098,-15.113 11.837,-26.18 h 26.418 c 4.76,11.067 9.261,20.762 11.837,26.18 z m -34.223,-35.819 c 3.409,-8.4 6.678,-17.024 9.177,-24.899 2.499,7.875 5.775,16.534 9.184,24.899 z"
id="path24"
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke-width:0.69999999" />
<path
class="cls-1"
d="m 471.632,240.17008 h 10.696 c -8.666,-17.759 -30.695,-66.353 -30.695,-82.53 h -10.094 c 0,16.177 -22.015,64.771 -30.688,82.53 h 10.689 c 2.583,-5.418 7.098,-15.113 11.837,-26.18 h 26.418 c 4.767,11.067 9.261,20.762 11.837,26.18 z m -34.223,-35.819 c 3.409,-8.4 6.678,-17.024 9.177,-24.899 2.499,7.875 5.775,16.534 9.184,24.899 z"
id="path26"
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke-width:0.69999999" />
<path
class="cls-1"
d="m 315.287,167.27908 c 14.343,0 26.019,14.189 26.019,31.626 0,17.437 -11.676,31.626 -26.019,31.626 -14.343,0 -26.019,-14.189 -26.019,-31.626 0,-17.437 11.669,-31.626 26.019,-31.626 m 0,-9.639 c -19.698,0 -35.658,18.473 -35.658,41.3 0,22.827 15.96,41.3 35.658,41.3 19.698,0 35.658,-18.473 35.658,-41.265 0,-22.792 -15.967,-41.265 -35.658,-41.265 z"
id="path28"
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke-width:0.69999999" />
<path
class="cls-1"
d="m 161.462,240.97508 a 25.368,25.368 0 0 1 -25.256,-25.417 h 9.639 a 15.617,15.617 0 1 0 31.234,0 16.002,16.002 0 0 0 -4.347,-10.927 c -2.8,-2.94 -6.3,-4.403 -11.795,-4.9 -6.3,-0.56 -11.165,-2.744 -14.805,-6.671 a 21.371,21.371 0 0 1 -5.6,-14.357 20.944,20.944 0 1 1 41.888,0 h -9.653 a 11.305,11.305 0 1 0 -22.61,0 11.585,11.585 0 0 0 3.052,7.805 c 1.995,2.156 4.641,3.276 8.582,3.619 4.9,0.441 12.11,1.736 17.927,7.861 a 25.746,25.746 0 0 1 7,17.563 25.368,25.368 0 0 1 -25.256,25.424 z"
id="path30"
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke-width:0.69999999" />
<path
class="cls-1"
d="m 265.51,157.69608 v 0 -0.056 h -9.667 v 0.259 c -0.301,3.206 -7.917,11.543 -21.896,21.469 -15.533,-11.025 -21.609,-18.83 -21.896,-21.469 v -0.259 h -9.632 v 0.056 0 c 0,0.119 0,0.238 0,0.357 v 82.117 h 9.632 v -66.213 q 7.056,6.937 19.201,15.281 l 2.716,1.827 2.702,-1.848 q 12.138,-8.302 19.173,-15.246 v 66.199 h 9.632 v -82.117 c 0.007,-0.105 0.035,-0.231 0.035,-0.357 z"
id="path32"
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke-width:0.69999999" />
</svg>

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -0,0 +1,278 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "integrationpluginGaradget.h"
#include "plugininfo.h"
#include <QUrlQuery>
#include <QNetworkReply>
#include <QHostAddress>
#include <QJsonDocument>
#include "hardwaremanager.h"
#include "network/networkaccessmanager.h"
#include "network/mqtt/mqttprovider.h"
#include "network/mqtt/mqttchannel.h"
static QHash<QString, StateTypeId> sonoff_basicPowerStateTypeIds = {
{"POWER1", sonoff_basicPowerStateTypeId},
};
static QHash<ThingClassId, QHash<QString, StateTypeId>> stateMaps = {
{sonoff_basicThingClassId, sonoff_basicPowerStateTypeIds},
};
IntegrationPluginGaradget::IntegrationPluginGaradget()
{
// Helper maps for parent devices (aka sonoff_*)
m_ipAddressParamTypeMap[sonoff_basicThingClassId] = sonoff_basicThingIpAddressParamTypeId;
// Helper maps for all devices
m_connectedStateTypeMap[sonoff_basicThingClassId] = sonoff_basicConnectedStateTypeId;
m_signalStrengthStateTypeMap[sonoff_basicThingClassId] = sonoff_basicSignalStrengthStateTypeId;
}
IntegrationPluginGaradget::~IntegrationPluginGaradget()
{
}
void IntegrationPluginGaradget::init()
{
}
void IntegrationPluginGaradget::setupThing(ThingSetupInfo *info)
{
Thing *thing = info->thing();
if (m_ipAddressParamTypeMap.contains(thing->thingClassId())) {
ParamTypeId ipAddressParamTypeId = m_ipAddressParamTypeMap.value(thing->thingClassId());
QHostAddress deviceAddress = QHostAddress(thing->paramValue(ipAddressParamTypeId).toString());
if (deviceAddress.isNull()) {
qCWarning(dcGaradget) << "Not a valid IP address given for IP address parameter";
//: Error setting up thing
return info->finish(Thing::ThingErrorInvalidParameter, QT_TR_NOOP("The given IP address is not valid."));
}
MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(thing->id().toString().remove(QRegExp("[{}-]")), deviceAddress );
if (!channel) {
qCWarning(dcGaradget) << "Failed to create MQTT channel.";
//: Error setting up thing
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Error creating MQTT channel. Please check MQTT server settings."));
}
// ipaddress is defined here but not sure how to get rid of and still have the mqtt channel. Garadget only works with the broker.
qCDebug(dcGaradget) << "BEE initial setup instructions:" << deviceAddress.toString() << channel;
m_mqttChannels.insert(info->thing(), channel);
connect(channel, &MqttChannel::clientConnected, this, &IntegrationPluginGaradget::onClientConnected);
connect(channel, &MqttChannel::clientDisconnected, this, &IntegrationPluginGaradget::onClientDisconnected);
connect(channel, &MqttChannel::publishReceived, this, &IntegrationPluginGaradget::onPublishReceived);
qCDebug(dcGaradget) << "Garadget setup complete";
info->finish(Thing::ThingErrorNoError);
foreach (Thing *child, myThings()) {
if (child->parentId() == info->thing()->id()) {
// Already have child devices... We're done here
return;
}
}
// insert to reprogram client Garadget to new device/topic name
QJsonObject beeobj;
beeobj.insert("nme", QString(channel->topicPrefixList().first()));
QJsonDocument beedoc(beeobj);
QByteArray beedata = beedoc.toJson(QJsonDocument::Compact);
QString jsonString(beedata);
qCDebug(dcGaradget) << "Publishing:" << "garadget/garage/set-conf " << beedata;
// next line will not publish to the correct device as topic is 32 characters long and garadget only allows 30 characters.
channel->publish("garadget/garaged/set-config", beedata);
channel->publish("garadget/garage/command", "get-config");
// need to develop test for correct modification of nme
return;
}
if (m_connectedStateTypeMap.contains(thing->thingClassId())) {
Thing* parentDevice = myThings().findById(thing->parentId());
StateTypeId connectedStateTypeId = m_connectedStateTypeMap.value(thing->thingClassId());
thing->setStateValue(m_connectedStateTypeMap.value(thing->thingClassId()), parentDevice->stateValue(connectedStateTypeId));
return info->finish(Thing::ThingErrorNoError);
}
qCWarning(dcGaradget) << "Unhandled ThingClass in setupDevice" << thing->thingClassId();
}
void IntegrationPluginGaradget::thingRemoved(Thing *thing)
{
qCDebug(dcGaradget) << "Device removed" << thing->name();
if (m_mqttChannels.contains(thing)) {
qCDebug(dcGaradget) << "Releasing MQTT channel";
MqttChannel* channel = m_mqttChannels.take(thing);
hardwareManager()->mqttProvider()->releaseChannel(channel);
}
}
void IntegrationPluginGaradget::executeAction(ThingActionInfo *info)
{
Thing *thing = info->thing();
Action action = info->action();
if (thing->thingClassId() == sonoff_basicThingClassId) {
MqttChannel *channel = m_mqttChannels.value(thing);
if (!channel) {
qCWarning(dcGaradget()) << "No MQTT channel for this thing.";
info->finish(Thing::ThingErrorHardwareNotAvailable);
return;
}
QString channelName = stateMaps.value(thing->thingClassId()).key(action.actionTypeId());
QByteArray payload = action.paramValue(action.actionTypeId()).toBool() ? "ON" : "OFF";
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + channelName << payload;
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + channelName, payload);
thing->setStateValue(action.actionTypeId(), action.paramValue(action.actionTypeId()));
info->finish(Thing::ThingErrorNoError);
return;
}
// Legacy (deprecated) connected devices
if (m_powerStateTypeMap.contains(thing->thingClassId())) {
Thing *parentDev = myThings().findById(thing->parentId());
MqttChannel *channel = m_mqttChannels.value(parentDev);
if (!channel) {
qCWarning(dcGaradget()) << "No mqtt channel for this thing.";
return info->finish(Thing::ThingErrorHardwareNotAvailable);
}
ParamTypeId channelParamTypeId = m_channelParamTypeMap.value(thing->thingClassId());
ParamTypeId powerActionParamTypeId = ParamTypeId(m_powerStateTypeMap.value(thing->thingClassId()).toString());
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(channelParamTypeId).toString() << (action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF");
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(channelParamTypeId).toString().toLower(), action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF");
thing->setStateValue(m_powerStateTypeMap.value(thing->thingClassId()), action.param(powerActionParamTypeId).value().toBool());
return info->finish(Thing::ThingErrorNoError);
}
if (m_closableStopActionTypeMap.contains(thing->thingClassId())) {
Thing *parentDev = myThings().findById(thing->parentId());
MqttChannel *channel = m_mqttChannels.value(parentDev);
if (!channel) {
qCWarning(dcGaradget()) << "No mqtt channel for this thing.";
return info->finish(Thing::ThingErrorHardwareNotAvailable);
}
ParamTypeId openingChannelParamTypeId = m_openingChannelParamTypeMap.value(thing->thingClassId());
ParamTypeId closingChannelParamTypeId = m_closingChannelParamTypeMap.value(thing->thingClassId());
if (action.actionTypeId() == m_closableOpenActionTypeMap.value(thing->thingClassId())) {
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString().toLower(), "OFF");
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString() << "ON";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString().toLower(), "ON");
} else if (action.actionTypeId() == m_closableCloseActionTypeMap.value(thing->thingClassId())) {
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString().toLower(), "OFF");
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString() << "ON";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString().toLower(), "ON");
} else { // Stop
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString().toLower(), "OFF");
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString().toLower(), "OFF");
}
return info->finish(Thing::ThingErrorNoError);
}
qCWarning(dcGaradget) << "Unhandled execute action call for devie" << thing;
}
void IntegrationPluginGaradget::onClientConnected(MqttChannel *channel)
{
qCDebug(dcGaradget) << "Sonoff thing connected!";
Thing *dev = m_mqttChannels.key(channel);
dev->setStateValue(m_connectedStateTypeMap.value(dev->thingClassId()), true);
foreach (Thing *child, myThings()) {
if (child->parentId() == dev->id()) {
child->setStateValue(m_connectedStateTypeMap.value(child->thingClassId()), true);
}
}
}
void IntegrationPluginGaradget::onClientDisconnected(MqttChannel *channel)
{
qCDebug(dcGaradget) << "Sonoff thing disconnected!";
Thing *dev = m_mqttChannels.key(channel);
dev->setStateValue(m_connectedStateTypeMap.value(dev->thingClassId()), false);
foreach (Thing *child, myThings()) {
if (child->parentId() == dev->id()) {
child->setStateValue(m_connectedStateTypeMap.value(child->thingClassId()), false);
}
}
}
void IntegrationPluginGaradget::onPublishReceived(MqttChannel *channel, const QString &topic, const QByteArray &payload)
{
qCDebug(dcGaradget) << "Publish received from Sonoff thing:" << topic << qUtf8Printable(payload);
Thing *thing = m_mqttChannels.key(channel);
if (topic.startsWith(channel->topicPrefixList().first() + "/sonoff/POWER")) {
QString channelName = topic.split("/").last();
thing->setStateValue(stateMaps.value(thing->thingClassId()).value(channelName), payload == "ON");
// Legacy (deprecated) connected things via params
foreach (Thing *child, myThings().filterByParentId(thing->id())) {
if (child->paramValue(m_channelParamTypeMap.value(child->thingClassId())).toString() != channelName) {
continue;
}
if (m_powerStateTypeMap.contains(child->thingClassId())) {
child->setStateValue(m_powerStateTypeMap.value(child->thingClassId()), payload == "ON");
}
}
}
if (topic.startsWith(channel->topicPrefixList().first() + "/sonoff/STATE")) {
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(dcGaradget) << "Cannot parse JSON from Garadget device" << error.errorString();
return;
}
QVariantMap dataMap = jsonDoc.toVariant().toMap();
thing->setStateValue(m_signalStrengthStateTypeMap.value(thing->thingClassId()), dataMap.value("Wifi").toMap().value("RSSI").toInt());
if (m_brightnessStateTypeMap.contains(thing->thingClassId())) {
thing->setStateValue(m_brightnessStateTypeMap.value(thing->thingClassId()), dataMap.value("Dimmer").toInt());
}
// Legacy (deprecated) connected things by params
foreach (Thing *child, myThings().filterByParentId(thing->id())) {
if (m_powerStateTypeMap.contains(child->thingClassId())) {
QString childChannel = child->paramValue(m_channelParamTypeMap.value(child->thingClassId())).toString();
QString valueString = jsonDoc.toVariant().toMap().value(childChannel).toString();
child->setStateValue(m_powerStateTypeMap.value(child->thingClassId()), valueString == "ON");
}
child->setStateValue(m_signalStrengthStateTypeMap.value(child->thingClassId()), dataMap.value("Wifi").toMap().value("RSSI").toInt());
}
}
}

View File

@ -0,0 +1,301 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "integrationpluginGaradget.h"
#include "plugininfo.h"
#include <QUrlQuery>
#include <QNetworkReply>
#include <QHostAddress>
#include <QJsonDocument>
#include "hardwaremanager.h"
#include "network/networkaccessmanager.h"
#include "network/mqtt/mqttprovider.h"
#include "network/mqtt/mqttchannel.h"
static QHash<QString, StateTypeId> sonoff_basicPowerStateTypeIds = {
{"POWER1", sonoff_basicPowerStateTypeId},
};
static QHash<ThingClassId, QHash<QString, StateTypeId>> stateMaps = {
{sonoff_basicThingClassId, sonoff_basicPowerStateTypeIds},
};
IntegrationPluginGaradget::IntegrationPluginGaradget()
{
// Helper maps for parent devices (aka sonoff_*)
m_ipAddressParamTypeMap[sonoff_basicThingClassId] = sonoff_basicThingIpAddressParamTypeId;
// Helper maps for all devices
m_connectedStateTypeMap[sonoff_basicThingClassId] = sonoff_basicConnectedStateTypeId;
m_signalStrengthStateTypeMap[sonoff_basicThingClassId] = sonoff_basicSignalStrengthStateTypeId;
}
IntegrationPluginGaradget::~IntegrationPluginGaradget()
{
}
void IntegrationPluginGaradget::init()
{
}
void IntegrationPluginGaradget::setupThing(ThingSetupInfo *info)
{
Thing *thing = info->thing();
if (m_ipAddressParamTypeMap.contains(thing->thingClassId())) {
ParamTypeId ipAddressParamTypeId = m_ipAddressParamTypeMap.value(thing->thingClassId());
QHostAddress deviceAddress = QHostAddress(thing->paramValue(ipAddressParamTypeId).toString());
if (deviceAddress.isNull()) {
qCWarning(dcGaradget) << "Not a valid IP address given for IP address parameter";
//: Error setting up thing
return info->finish(Thing::ThingErrorInvalidParameter, QT_TR_NOOP("The given IP address is not valid."));
}
MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(thing->id().toString().remove(QRegExp("[{}-]")), deviceAddress );
if (!channel) {
qCWarning(dcGaradget) << "Failed to create MQTT channel.";
//: Error setting up thing
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Error creating MQTT channel. Please check MQTT server settings."));
}
// ipaddress is defined here but not sure how to get rid of and still have the mqtt channel. Garadget only works with the broker.
qCDebug(dcGaradget) << "BEE initial setup instructions:" << deviceAddress.toString() << channel;
m_mqttChannels.insert(info->thing(), channel);
connect(channel, &MqttChannel::clientConnected, this, &IntegrationPluginGaradget::onClientConnected);
connect(channel, &MqttChannel::clientDisconnected, this, &IntegrationPluginGaradget::onClientDisconnected);
connect(channel, &MqttChannel::publishReceived, this, &IntegrationPluginGaradget::onPublishReceived);
qCDebug(dcGaradget) << "Garadget setup complete";
info->finish(Thing::ThingErrorNoError);
foreach (Thing *child, myThings()) {
if (child->parentId() == info->thing()->id()) {
// Already have child devices... We're done here
return;
}
}
// insert to reprogram client Garadget to new device/topic name
QJsonObject beeobj;
beeobj.insert("nme", QString(channel->topicPrefixList().first()));
QJsonDocument beedoc(beeobj);
QByteArray beedata = beedoc.toJson(QJsonDocument::Compact);
QString jsonString(beedata);
qCDebug(dcGaradget) << "Publishing:" << "garadget/garage/set-conf " << beedata;
// next line will not publish to the correct device as topic is 32 characters long and garadget only allows 30 characters.
channel->publish("garadget/garaged/set-config", beedata);
channel->publish("garadget/garage/command", "get-config");
// need to develop test for correct modification of nme
return;
}
if (m_connectedStateTypeMap.contains(thing->thingClassId())) {
Thing* parentDevice = myThings().findById(thing->parentId());
StateTypeId connectedStateTypeId = m_connectedStateTypeMap.value(thing->thingClassId());
thing->setStateValue(m_connectedStateTypeMap.value(thing->thingClassId()), parentDevice->stateValue(connectedStateTypeId));
return info->finish(Thing::ThingErrorNoError);
}
qCWarning(dcGaradget) << "Unhandled ThingClass in setupDevice" << thing->thingClassId();
}
void IntegrationPluginGaradget::onPublishReceivedSetup(MqttChannel *channel, const QString &topic, const QByteArray &payload)
{
qCDebug(dcGaradget) << "Publish received from garadget/garage thing:" << topic << qUtf8Printable(payload);
Thing *thing = m_mqttChannels.key(channel);
if (topic.startsWith( "garadget/garage/config")) {
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload, &error);
qCWarning(dcGaradget) << "BEE on receive QJsonDocument: " << jsonDoc;
if (error.error != QJsonParseError::NoError) {
qCWarning(dcGaradget) << "Cannot parse JSON from Garadget device" << error.errorString();
return;
}
QVariantMap dataMap = jsonDoc.toVariant().toMap();
thing->setStateValue(m_signalStrengthStateTypeMap.value(thing->thingClassId()), dataMap.value("Wifi").toMap().value("RSSI").toInt());
}
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload, &error);
qCWarning(dcGaradget) << "BEE on receive ending QJsonDocument: " << jsonDoc;
}
void IntegrationPluginGaradget::thingRemoved(Thing *thing)
{
qCDebug(dcGaradget) << "Device removed" << thing->name();
if (m_mqttChannels.contains(thing)) {
qCDebug(dcGaradget) << "Releasing MQTT channel";
MqttChannel* channel = m_mqttChannels.take(thing);
hardwareManager()->mqttProvider()->releaseChannel(channel);
}
}
void IntegrationPluginGaradget::executeAction(ThingActionInfo *info)
{
Thing *thing = info->thing();
Action action = info->action();
if (thing->thingClassId() == sonoff_basicThingClassId) {
MqttChannel *channel = m_mqttChannels.value(thing);
if (!channel) {
qCWarning(dcGaradget()) << "No MQTT channel for this thing.";
info->finish(Thing::ThingErrorHardwareNotAvailable);
return;
}
QString channelName = stateMaps.value(thing->thingClassId()).key(action.actionTypeId());
QByteArray payload = action.paramValue(action.actionTypeId()).toBool() ? "ON" : "OFF";
qCDebug(dcGaradget) << "Publishing:" << "garadget/" + channel->topicPrefixList().first() + "/command " + channelName << payload;
channel->publish("garadget/" + channel->topicPrefixList().first() + "/command " + channelName, payload);
thing->setStateValue(action.actionTypeId(), action.paramValue(action.actionTypeId()));
info->finish(Thing::ThingErrorNoError);
return;
}
// Legacy (deprecated) connected devices
if (m_powerStateTypeMap.contains(thing->thingClassId())) {
Thing *parentDev = myThings().findById(thing->parentId());
MqttChannel *channel = m_mqttChannels.value(parentDev);
if (!channel) {
qCWarning(dcGaradget()) << "No mqtt channel for this thing.";
return info->finish(Thing::ThingErrorHardwareNotAvailable);
}
ParamTypeId channelParamTypeId = m_channelParamTypeMap.value(thing->thingClassId());
ParamTypeId powerActionParamTypeId = ParamTypeId(m_powerStateTypeMap.value(thing->thingClassId()).toString());
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(channelParamTypeId).toString() << (action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF");
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(channelParamTypeId).toString().toLower(), action.param(powerActionParamTypeId).value().toBool() ? "ON" : "OFF");
thing->setStateValue(m_powerStateTypeMap.value(thing->thingClassId()), action.param(powerActionParamTypeId).value().toBool());
return info->finish(Thing::ThingErrorNoError);
}
if (m_closableStopActionTypeMap.contains(thing->thingClassId())) {
Thing *parentDev = myThings().findById(thing->parentId());
MqttChannel *channel = m_mqttChannels.value(parentDev);
if (!channel) {
qCWarning(dcGaradget()) << "No mqtt channel for this thing.";
return info->finish(Thing::ThingErrorHardwareNotAvailable);
}
ParamTypeId openingChannelParamTypeId = m_openingChannelParamTypeMap.value(thing->thingClassId());
ParamTypeId closingChannelParamTypeId = m_closingChannelParamTypeMap.value(thing->thingClassId());
if (action.actionTypeId() == m_closableOpenActionTypeMap.value(thing->thingClassId())) {
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString().toLower(), "OFF");
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString() << "ON";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString().toLower(), "ON");
} else if (action.actionTypeId() == m_closableCloseActionTypeMap.value(thing->thingClassId())) {
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString().toLower(), "OFF");
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString() << "ON";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString().toLower(), "ON");
} else { // Stop
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(openingChannelParamTypeId).toString().toLower(), "OFF");
qCDebug(dcGaradget) << "Publishing:" << channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString() << "OFF";
channel->publish(channel->topicPrefixList().first() + "/sonoff/cmnd/" + thing->paramValue(closingChannelParamTypeId).toString().toLower(), "OFF");
}
return info->finish(Thing::ThingErrorNoError);
}
qCWarning(dcGaradget) << "Unhandled execute action call for devie" << thing;
}
void IntegrationPluginGaradget::onClientConnected(MqttChannel *channel)
{
qCDebug(dcGaradget) << "Sonoff thing connected!";
Thing *dev = m_mqttChannels.key(channel);
dev->setStateValue(m_connectedStateTypeMap.value(dev->thingClassId()), true);
foreach (Thing *child, myThings()) {
if (child->parentId() == dev->id()) {
child->setStateValue(m_connectedStateTypeMap.value(child->thingClassId()), true);
}
}
}
void IntegrationPluginGaradget::onClientDisconnected(MqttChannel *channel)
{
qCDebug(dcGaradget) << "Sonoff thing disconnected!";
Thing *dev = m_mqttChannels.key(channel);
dev->setStateValue(m_connectedStateTypeMap.value(dev->thingClassId()), false);
foreach (Thing *child, myThings()) {
if (child->parentId() == dev->id()) {
child->setStateValue(m_connectedStateTypeMap.value(child->thingClassId()), false);
}
}
}
void IntegrationPluginGaradget::onPublishReceived(MqttChannel *channel, const QString &topic, const QByteArray &payload)
{
qCDebug(dcGaradget) << "Publish received from Sonoff thing:" << topic << qUtf8Printable(payload);
Thing *thing = m_mqttChannels.key(channel);
if (topic.startsWith(channel->topicPrefixList().first() + "/sonoff/POWER")) {
QString channelName = topic.split("/").last();
thing->setStateValue(stateMaps.value(thing->thingClassId()).value(channelName), payload == "ON");
// Legacy (deprecated) connected things via params
foreach (Thing *child, myThings().filterByParentId(thing->id())) {
if (child->paramValue(m_channelParamTypeMap.value(child->thingClassId())).toString() != channelName) {
continue;
}
if (m_powerStateTypeMap.contains(child->thingClassId())) {
child->setStateValue(m_powerStateTypeMap.value(child->thingClassId()), payload == "ON");
}
}
}
if (topic.startsWith(channel->topicPrefixList().first() + "/sonoff/STATE")) {
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(dcGaradget) << "Cannot parse JSON from Garadget device" << error.errorString();
return;
}
QVariantMap dataMap = jsonDoc.toVariant().toMap();
thing->setStateValue(m_signalStrengthStateTypeMap.value(thing->thingClassId()), dataMap.value("Wifi").toMap().value("RSSI").toInt());
if (m_brightnessStateTypeMap.contains(thing->thingClassId())) {
thing->setStateValue(m_brightnessStateTypeMap.value(thing->thingClassId()), dataMap.value("Dimmer").toInt());
}
// Legacy (deprecated) connected things by params
foreach (Thing *child, myThings().filterByParentId(thing->id())) {
if (m_powerStateTypeMap.contains(child->thingClassId())) {
QString childChannel = child->paramValue(m_channelParamTypeMap.value(child->thingClassId())).toString();
QString valueString = jsonDoc.toVariant().toMap().value(childChannel).toString();
child->setStateValue(m_powerStateTypeMap.value(child->thingClassId()), valueString == "ON");
}
child->setStateValue(m_signalStrengthStateTypeMap.value(child->thingClassId()), dataMap.value("Wifi").toMap().value("RSSI").toInt());
}
}
}

View File

@ -0,0 +1,84 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU Lesser General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; version 3. This project is distributed in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef INTEGRATIONPLUGINGARADGET_H
#define INTEGRATIONPLUGINGARADGET_H
#include "integrations/integrationplugin.h"
class MqttChannel;
class IntegrationPluginGaradget: public IntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginGaradget.json")
Q_INTERFACES(IntegrationPlugin)
public:
explicit IntegrationPluginGaradget();
~IntegrationPluginGaradget();
void init() override;
void setupThing(ThingSetupInfo *info) override;
void thingRemoved(Thing *thing) override;
void executeAction(ThingActionInfo *info) override;
private slots:
void onClientConnected(MqttChannel *channel);
void onClientDisconnected(MqttChannel *channel);
void onPublishReceived(MqttChannel *channel, const QString &topic, const QByteArray &payload);
private:
QHash<Thing*, MqttChannel*> m_mqttChannels;
// Helpers for parent devices (the ones starting with sonoff)
QHash<ThingClassId, ParamTypeId> m_ipAddressParamTypeMap;
QHash<ThingClassId, QList<ParamTypeId> > m_attachedDeviceParamTypeIdMap;
// Helpers for child devices (virtual ones, starting with Garadget)
QHash<ThingClassId, ParamTypeId> m_channelParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_openingChannelParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_closingChannelParamTypeMap;
QHash<ThingClassId, StateTypeId> m_powerStateTypeMap;
QHash<ThingClassId, ActionTypeId> m_closableOpenActionTypeMap;
QHash<ThingClassId, ActionTypeId> m_closableCloseActionTypeMap;
QHash<ThingClassId, ActionTypeId> m_closableStopActionTypeMap;
// Helpers for both devices
QHash<ThingClassId, StateTypeId> m_connectedStateTypeMap;
QHash<ThingClassId, StateTypeId> m_signalStrengthStateTypeMap;
QHash<ThingClassId, StateTypeId> m_brightnessStateTypeMap;
};
#endif // INTEGRATIONPLUGINGARADGET_H

View File

@ -0,0 +1,78 @@
{
"name": "Garadget",
"displayName": "Sonoff-Garadget",
"id": "476781af-ad41-423b-b9bb-f308f2aff339",
"vendors": [
{
"name": "Garadget",
"displayName": "Garadget",
"id": "22d59bee-79cc-4dea-b742-30ac6bdcf2c9",
"thingClasses": [
{
"name": "sonoff_basic",
"displayName": "Garadget",
"id": "e808b8ae-7608-41ce-8444-892f0648a4d3",
"setupMethod": "JustAdd",
"createMethods": ["User"],
"interfaces": [ ],
"paramTypes": [
{
"id": "54a11a17-fc37-4316-891f-001c55e38220",
"name":"ipAddress",
"displayName": "IP address",
"type": "QString"
}
],
"stateTypes": [
{
"id": "a3d7e6eb-82d0-47ee-b95f-4dde931eb7e2",
"name": "connected",
"displayName": "Connected",
"displayNameEvent": "Connected changed",
"type": "bool",
"defaultValue": false,
"cached": false
},
{
"id": "e276e6ca-4cb5-46d2-9a78-31f92d78ac70",
"name": "signalStrength",
"displayName": "Signal strength",
"displayNameEvent": "Signal strength changed",
"type": "uint",
"unit": "Percentage",
"minValue": 0,
"maxValue": 100,
"defaultValue": -1
},
{
"id": "481a7cf8-418b-4774-8fd4-32693ab52299",
"name": "power",
"displayName": "Power",
"displayNameEvent": "Power changed",
"displayNameAction": "Set power",
"type": "bool",
"writable": true,
"defaultValue": false,
"ioType": "digitalOutput"
}
],
"actionTypes": [
],
"eventTypes": [
]
}
]
}
]
}

15
garadget/meta.json Normal file
View File

@ -0,0 +1,15 @@
{
"title": "Garadget",
"tagline": "Garadget",
"icon": "garadget.svg",
"stability": "community",
"offline": true,
"technologies": [
"network",
"mqtt"
],
"categories": [
"relay",
"socket"
]
}

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>IntegrationPluginGaradget</name>
<message>
<source>Error creating MQTT channel. Please check MQTT server settings.</source>
<extracomment>Error setting up thing</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not connect to Garadget device.</source>
<extracomment>Error setting up thing</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Garadget</name>
<message>
<source>Sonoff-Garadget</source>
<extracomment>The name of the plugin Garadget ({476781af-ad41-423b-b9bb-f308f2aff339})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Single switch (Sonoff Basic, RF, Touch...)</source>
<extracomment>The name of the ThingClass ({e808b8ae-7608-41ce-8444-892f0648a4d3})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power changed</source>
<extracomment>The name of the EventType ({481a7cf8-418b-4774-8fd4-32693ab52299}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power</source>
<extracomment>The name of the ParamType (ThingClass: sonoff_basic, ActionType: power, ID: {481a7cf8-418b-4774-8fd4-32693ab52299})
----------
The name of the ParamType (ThingClass: sonoff_basic, EventType: power, ID: {481a7cf8-418b-4774-8fd4-32693ab52299})
----------
The name of the StateType ({481a7cf8-418b-4774-8fd4-32693ab52299}) of ThingClass sonoff_basic
----------
The name of the ActionType ({481a7cf8-418b-4774-8fd4-32693ab52299}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set power</source>
<extracomment>The name of the ActionType ({481a7cf8-418b-4774-8fd4-32693ab52299}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Garadget</source>
<extracomment>The name of the vendor ({22d59bee-79cc-4dea-b742-30ac6bdcf2c9})</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>IntegrationPluginGaradget</name>
<message>
<source>The given IP address is not valid.</source>
<extracomment>Error setting up thing</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Error creating MQTT channel. Please check MQTT server settings.</source>
<extracomment>Error setting up thing</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Could not connect to Garadget device.</source>
<extracomment>Error setting up thing</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Garadget</name>
<message>
<source>Sonoff-Garadget</source>
<extracomment>The name of the plugin Garadget ({476781af-ad41-423b-b9bb-f308f2aff339})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Single switch (Sonoff Basic, RF, Touch...)</source>
<extracomment>The name of the ThingClass ({e808b8ae-7608-41ce-8444-892f0648a4d3})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>IP address</source>
<extracomment>The name of the ParamType (ThingClass: sonoff_basic, Type: thing, ID: {54a11a17-fc37-4316-891f-001c55e38220})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected device</source>
<extracomment>The name of the ParamType (ThingClass: sonoff_basic, Type: thing, ID: {f2a79266-1b69-4c50-8397-9533dd2f30cb})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected changed</source>
<extracomment>The name of the EventType ({a3d7e6eb-82d0-47ee-b95f-4dde931eb7e2}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Connected</source>
<extracomment>The name of the ParamType (ThingClass: sonoff_basic, EventType: connected, ID: {a3d7e6eb-82d0-47ee-b95f-4dde931eb7e2})
----------
The name of the StateType ({a3d7e6eb-82d0-47ee-b95f-4dde931eb7e2}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power changed</source>
<extracomment>The name of the EventType ({481a7cf8-418b-4774-8fd4-32693ab52299}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Power</source>
<extracomment>The name of the ParamType (ThingClass: sonoff_basic, ActionType: power, ID: {481a7cf8-418b-4774-8fd4-32693ab52299})
----------
The name of the ParamType (ThingClass: sonoff_basic, EventType: power, ID: {481a7cf8-418b-4774-8fd4-32693ab52299})
----------
The name of the StateType ({481a7cf8-418b-4774-8fd4-32693ab52299}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Garadget</source>
<extracomment>The name of the vendor ({22d59bee-79cc-4dea-b742-30ac6bdcf2c9})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Signal strength</source>
<extracomment>The name of the ParamType (ThingClass: sonoff_basic, EventType: signalStrength, ID: {e276e6ca-4cb5-46d2-9a78-31f92d78ac70})
----------
The name of the StateType ({e276e6ca-4cb5-46d2-9a78-31f92d78ac70}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Signal strength changed</source>
<extracomment>The name of the EventType ({e276e6ca-4cb5-46d2-9a78-31f92d78ac70}) of ThingClass sonoff_basic</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>