diff --git a/genericelements/genericelements.pro b/genericelements/genericelements.pro index 15e685e..660914e 100644 --- a/genericelements/genericelements.pro +++ b/genericelements/genericelements.pro @@ -1,11 +1,11 @@ include(../plugins.pri) -TARGET = $$qtLibraryTarget(nymea_deviceplugingenericelements) +TARGET = $$qtLibraryTarget(nymea_integrationplugingenericelements) SOURCES += \ - deviceplugingenericelements.cpp + integrationplugingenericelements.cpp HEADERS += \ - deviceplugingenericelements.h + integrationplugingenericelements.h diff --git a/genericelements/deviceplugingenericelements.cpp b/genericelements/integrationplugingenericelements.cpp similarity index 72% rename from genericelements/deviceplugingenericelements.cpp rename to genericelements/integrationplugingenericelements.cpp index c557e01..7725ec8 100644 --- a/genericelements/deviceplugingenericelements.cpp +++ b/genericelements/integrationplugingenericelements.cpp @@ -28,39 +28,39 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "deviceplugingenericelements.h" +#include "integrationplugingenericelements.h" #include "plugininfo.h" #include -DevicePluginGenericElements::DevicePluginGenericElements() +IntegrationPluginGenericElements::IntegrationPluginGenericElements() { } -void DevicePluginGenericElements::setupDevice(DeviceSetupInfo *info) +void IntegrationPluginGenericElements::setupThing(ThingSetupInfo *info) { - info->finish(Device::DeviceErrorNoError); + info->finish(Thing::ThingErrorNoError); } -void DevicePluginGenericElements::executeAction(DeviceActionInfo *info) +void IntegrationPluginGenericElements::executeAction(ThingActionInfo *info) { - Device *device = info->device(); + Thing *thing = info->thing(); Action action = info->action(); // Toggle Button if (action.actionTypeId() == toggleButtonStateActionTypeId) { - device->setStateValue(toggleButtonStateStateTypeId, action.params().paramValue(toggleButtonStateActionStateParamTypeId).toBool()); + thing->setStateValue(toggleButtonStateStateTypeId, action.params().paramValue(toggleButtonStateActionStateParamTypeId).toBool()); } // Button if (action.actionTypeId() == buttonButtonPressActionTypeId) { - emit emitEvent(Event(buttonButtonPressedEventTypeId, device->id())); + emit emitEvent(Event(buttonButtonPressedEventTypeId, thing->id())); } // ON/OFF Button if (action.actionTypeId() == onOffButtonOnActionTypeId) { - emit emitEvent(Event(onOffButtonOnEventTypeId, device->id())); + emit emitEvent(Event(onOffButtonOnEventTypeId, thing->id())); } if (action.actionTypeId() == onOffButtonOffActionTypeId) { - emit emitEvent(Event(onOffButtonOffEventTypeId, device->id())); + emit emitEvent(Event(onOffButtonOffEventTypeId, thing->id())); } - info->finish(Device::DeviceErrorNoError); + info->finish(Thing::ThingErrorNoError); } diff --git a/genericelements/deviceplugingenericelements.h b/genericelements/integrationplugingenericelements.h similarity index 73% rename from genericelements/deviceplugingenericelements.h rename to genericelements/integrationplugingenericelements.h index 85f487b..be25eb4 100644 --- a/genericelements/deviceplugingenericelements.h +++ b/genericelements/integrationplugingenericelements.h @@ -28,25 +28,25 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef DEVICEPLUGINGENERICELEMENTS_H -#define DEVICEPLUGINGENERICELEMENTS_H +#ifndef INTEGRATIONPLUGINGENERICELEMENTS_H +#define INTEGRATIONPLUGINGENERICELEMENTS_H -#include "devices/deviceplugin.h" +#include "integrations/integrationplugin.h" -class DevicePluginGenericElements : public DevicePlugin +class IntegrationPluginGenericElements : public IntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "deviceplugingenericelements.json") - Q_INTERFACES(DevicePlugin) + Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationplugingenericelements.json") + Q_INTERFACES(IntegrationPlugin) public: - explicit DevicePluginGenericElements(); - void setupDevice(DeviceSetupInfo *info) override; + explicit IntegrationPluginGenericElements(); + void setupThing(ThingSetupInfo *info) override; public slots: - void executeAction(DeviceActionInfo *info) override; + void executeAction(ThingActionInfo *info) override; }; -#endif // DEVICEPLUGINGENERICELEMENTS_H +#endif // INTEGRATIONPLUGINGENERICELEMENTS_H diff --git a/genericelements/deviceplugingenericelements.json b/genericelements/integrationplugingenericelements.json similarity index 99% rename from genericelements/deviceplugingenericelements.json rename to genericelements/integrationplugingenericelements.json index 18688ce..a755b86 100644 --- a/genericelements/deviceplugingenericelements.json +++ b/genericelements/integrationplugingenericelements.json @@ -7,7 +7,7 @@ "name": "nymea", "displayName": "nymea", "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", - "deviceClasses": [ + "thingClasses": [ { "id": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4", "name": "toggleButton", diff --git a/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-de_DE.ts b/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-de_DE.ts index 6a0e5e3..909ebbf 100644 --- a/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-de_DE.ts +++ b/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-de_DE.ts @@ -18,13 +18,13 @@ Toggle Button - The name of the DeviceClass ({c0f511f9-70f5-499b-bd70-2c0e9ddd68c4}) + The name of the ThingClass ({c0f511f9-70f5-499b-bd70-2c0e9ddd68c4}) Toggle Taster state changed - The name of the EventType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of DeviceClass toggleButton + The name of the EventType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of ThingClass toggleButton @@ -32,65 +32,65 @@ state - The name of the ParamType (DeviceClass: toggleButton, ActionType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) + The name of the ParamType (ThingClass: toggleButton, ActionType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) ---------- -The name of the ParamType (DeviceClass: toggleButton, EventType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) +The name of the ParamType (ThingClass: toggleButton, EventType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) ---------- -The name of the StateType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of DeviceClass toggleButton +The name of the StateType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of ThingClass toggleButton Set state - The name of the ActionType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of DeviceClass toggleButton + The name of the ActionType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of ThingClass toggleButton Button - The name of the DeviceClass ({820b2f2d-0d92-48c8-8fd4-f94ce8fc4103}) + The name of the ThingClass ({820b2f2d-0d92-48c8-8fd4-f94ce8fc4103}) Taster press - The name of the ActionType ({01f38af1-b2ab-4ec3-844e-ef52f0f229a9}) of DeviceClass button + The name of the ActionType ({01f38af1-b2ab-4ec3-844e-ef52f0f229a9}) of ThingClass button button pressed - The name of the EventType ({effdbc2d-e467-4b0b-80a9-9dda251bfa5c}) of DeviceClass button + The name of the EventType ({effdbc2d-e467-4b0b-80a9-9dda251bfa5c}) of ThingClass button ON/OFF Button - The name of the DeviceClass ({430d188c-476d-4825-a9bd-86dfa3094b56}) + The name of the ThingClass ({430d188c-476d-4825-a9bd-86dfa3094b56}) An/Aus Taster press ON - The name of the ActionType ({892596d2-0863-4807-97da-469b9f7003f2}) of DeviceClass onOffButton + The name of the ActionType ({892596d2-0863-4807-97da-469b9f7003f2}) of ThingClass onOffButton press OFF - The name of the ActionType ({a8d64050-0b58-4ccf-b052-77ce2b7368ad}) of DeviceClass onOffButton + The name of the ActionType ({a8d64050-0b58-4ccf-b052-77ce2b7368ad}) of ThingClass onOffButton ON pressed - The name of the EventType ({4eeba6a2-e4c7-4a2e-8360-2797d98114e6}) of DeviceClass onOffButton + The name of the EventType ({4eeba6a2-e4c7-4a2e-8360-2797d98114e6}) of ThingClass onOffButton OFF pressed - The name of the EventType ({b636c5f3-2eb0-4682-96d4-88a4aa9d2c12}) of DeviceClass onOffButton + The name of the EventType ({b636c5f3-2eb0-4682-96d4-88a4aa9d2c12}) of ThingClass onOffButton diff --git a/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-en_US.ts b/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-en_US.ts index 9f7b1f8..40bf713 100644 --- a/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-en_US.ts +++ b/genericelements/translations/6e22161e-39b7-4416-8623-39e730721efb-en_US.ts @@ -18,13 +18,13 @@ Toggle Button - The name of the DeviceClass ({c0f511f9-70f5-499b-bd70-2c0e9ddd68c4}) + The name of the ThingClass ({c0f511f9-70f5-499b-bd70-2c0e9ddd68c4}) state changed - The name of the EventType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of DeviceClass toggleButton + The name of the EventType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of ThingClass toggleButton @@ -32,65 +32,65 @@ state - The name of the ParamType (DeviceClass: toggleButton, ActionType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) + The name of the ParamType (ThingClass: toggleButton, ActionType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) ---------- -The name of the ParamType (DeviceClass: toggleButton, EventType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) +The name of the ParamType (ThingClass: toggleButton, EventType: state, ID: {b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) ---------- -The name of the StateType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of DeviceClass toggleButton +The name of the StateType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of ThingClass toggleButton Set state - The name of the ActionType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of DeviceClass toggleButton + The name of the ActionType ({b5e90567-54aa-49bd-a78a-3c19fb38aaf5}) of ThingClass toggleButton Button - The name of the DeviceClass ({820b2f2d-0d92-48c8-8fd4-f94ce8fc4103}) + The name of the ThingClass ({820b2f2d-0d92-48c8-8fd4-f94ce8fc4103}) press - The name of the ActionType ({01f38af1-b2ab-4ec3-844e-ef52f0f229a9}) of DeviceClass button + The name of the ActionType ({01f38af1-b2ab-4ec3-844e-ef52f0f229a9}) of ThingClass button button pressed - The name of the EventType ({effdbc2d-e467-4b0b-80a9-9dda251bfa5c}) of DeviceClass button + The name of the EventType ({effdbc2d-e467-4b0b-80a9-9dda251bfa5c}) of ThingClass button ON/OFF Button - The name of the DeviceClass ({430d188c-476d-4825-a9bd-86dfa3094b56}) + The name of the ThingClass ({430d188c-476d-4825-a9bd-86dfa3094b56}) press ON - The name of the ActionType ({892596d2-0863-4807-97da-469b9f7003f2}) of DeviceClass onOffButton + The name of the ActionType ({892596d2-0863-4807-97da-469b9f7003f2}) of ThingClass onOffButton press OFF - The name of the ActionType ({a8d64050-0b58-4ccf-b052-77ce2b7368ad}) of DeviceClass onOffButton + The name of the ActionType ({a8d64050-0b58-4ccf-b052-77ce2b7368ad}) of ThingClass onOffButton ON pressed - The name of the EventType ({4eeba6a2-e4c7-4a2e-8360-2797d98114e6}) of DeviceClass onOffButton + The name of the EventType ({4eeba6a2-e4c7-4a2e-8360-2797d98114e6}) of ThingClass onOffButton OFF pressed - The name of the EventType ({b636c5f3-2eb0-4682-96d4-88a4aa9d2c12}) of DeviceClass onOffButton + The name of the EventType ({b636c5f3-2eb0-4682-96d4-88a4aa9d2c12}) of ThingClass onOffButton diff --git a/genericinterfaces/deviceplugingenericinterfaces.cpp b/genericinterfaces/deviceplugingenericinterfaces.cpp deleted file mode 100644 index e763448..0000000 --- a/genericinterfaces/deviceplugingenericinterfaces.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* -* 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 . -* -* 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 -* -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*! - \page genericinterfaces.html - \title Generic interfaces - \brief Common interfaces to test the rule engine. - - \ingroup plugins - \ingroup nymea-tests - - The generic interfaces plugin allows you create virtual buttons, which can be connected with a rule. This gives you - the possibility to execute multiple \l{Action}{Actions} with one signal. Without a rule this generic interfaces are - useless. - - \chapter Plugin properties - Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses} - and \l{Vendor}{Vendors} of this \l{DevicePlugin}. - - For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}. - - \quotefile plugins/deviceplugins/genericinterfaces/deviceplugingenericinterfaces.json -*/ - - -#include "deviceplugingenericinterfaces.h" -#include "devices/devicemanager.h" -#include "plugininfo.h" - -#include - -DevicePluginGenericInterfaces::DevicePluginGenericInterfaces() -{ -} - -void DevicePluginGenericInterfaces::setupDevice(DeviceSetupInfo *info) -{ - info->finish(Device::DeviceErrorNoError); -} - -void DevicePluginGenericInterfaces::executeAction(DeviceActionInfo *info) -{ - Device *device = info->device(); - Action action = info->action(); - - if (device->deviceClassId() == awningDeviceClassId) { - if (action.actionTypeId() == awningOpenActionTypeId) { - device->setStateValue(awningStatusStateTypeId, "Opening"); - device->setStateValue(awningClosingOutputStateTypeId, false); - device->setStateValue(awningOpeningOutputStateTypeId, true); - return info->finish(Device::DeviceErrorNoError); - } - if (action.actionTypeId() == awningStopActionTypeId) { - device->setStateValue(awningStatusStateTypeId, "Stopped"); - device->setStateValue(awningOpeningOutputStateTypeId, false); - device->setStateValue(awningClosingOutputStateTypeId, false); - return info->finish(Device::DeviceErrorNoError); - } - if (action.actionTypeId() == awningCloseActionTypeId) { - device->setStateValue(awningStatusStateTypeId, "Closing"); - device->setStateValue(awningOpeningOutputStateTypeId, false); - device->setStateValue(awningClosingOutputStateTypeId, true); - return info->finish(Device::DeviceErrorNoError); - } - return info->finish(Device::DeviceErrorActionTypeNotFound); - } - - if (device->deviceClassId() == blindDeviceClassId ) { - if (action.actionTypeId() == blindOpenActionTypeId) { - device->setStateValue(blindStatusStateTypeId, "Opening"); - device->setStateValue(blindClosingOutputStateTypeId, false); - device->setStateValue(blindOpeningOutputStateTypeId, true); - return info->finish(Device::DeviceErrorNoError); - } - if (action.actionTypeId() == blindStopActionTypeId) { - device->setStateValue(blindStatusStateTypeId, "Stopped"); - device->setStateValue(blindOpeningOutputStateTypeId, false); - device->setStateValue(blindClosingOutputStateTypeId, false); - return info->finish(Device::DeviceErrorNoError); - } - if (action.actionTypeId() == blindCloseActionTypeId) { - device->setStateValue(blindStatusStateTypeId, "Closing"); - device->setStateValue(blindOpeningOutputStateTypeId, false); - device->setStateValue(blindClosingOutputStateTypeId, true); - return info->finish(Device::DeviceErrorNoError); - } - return info->finish(Device::DeviceErrorActionTypeNotFound); - } - - if (device->deviceClassId() == shutterDeviceClassId) { - if (action.actionTypeId() == shutterOpenActionTypeId) { - device->setStateValue(shutterStatusStateTypeId, "Opening"); - device->setStateValue(shutterClosingOutputStateTypeId, false); - device->setStateValue(shutterOpeningOutputStateTypeId, true); - return info->finish(Device::DeviceErrorNoError); - } - if (action.actionTypeId() == shutterStopActionTypeId) { - device->setStateValue(shutterStatusStateTypeId, "Stopped"); - device->setStateValue(shutterOpeningOutputStateTypeId, false); - device->setStateValue(shutterClosingOutputStateTypeId, false); - return info->finish(Device::DeviceErrorNoError); - } - if (action.actionTypeId() == shutterCloseActionTypeId) { - device->setStateValue(shutterStatusStateTypeId, "Closing"); - device->setStateValue(shutterOpeningOutputStateTypeId, false); - device->setStateValue(shutterClosingOutputStateTypeId, true); - return info->finish(Device::DeviceErrorNoError); - } - return info->finish(Device::DeviceErrorActionTypeNotFound); - } - - if (device->deviceClassId() == socketDeviceClassId) { - if (action.actionTypeId() == socketPowerActionTypeId) { - device->setStateValue(socketPowerStateTypeId, action.param(socketPowerActionPowerParamTypeId).value()); - return info->finish(Device::DeviceErrorNoError); - } - return info->finish(Device::DeviceErrorActionTypeNotFound); - } - - if (device->deviceClassId() == lightDeviceClassId) { - if (action.actionTypeId() == lightPowerActionTypeId) { - device->setStateValue(lightPowerStateTypeId, action.param(lightPowerActionPowerParamTypeId).value()); - return info->finish(Device::DeviceErrorNoError); - } - return info->finish(Device::DeviceErrorActionTypeNotFound); - } - - if (device->deviceClassId() == heatingDeviceClassId) { - if (action.actionTypeId() == heatingPowerActionTypeId) { - device->setStateValue(heatingPowerStateTypeId, action.param(heatingPowerActionPowerParamTypeId).value()); - return info->finish(Device::DeviceErrorNoError); - } - return info->finish(Device::DeviceErrorActionTypeNotFound); - } - return info->finish(Device::DeviceErrorDeviceClassNotFound); -} diff --git a/genericinterfaces/genericinterfaces.pro b/genericinterfaces/genericinterfaces.pro index d66633d..90a9805 100644 --- a/genericinterfaces/genericinterfaces.pro +++ b/genericinterfaces/genericinterfaces.pro @@ -1,12 +1,12 @@ include(../plugins.pri) -TARGET = $$qtLibraryTarget(nymea_deviceplugingenericinterfaces) +TARGET = $$qtLibraryTarget(nymea_integrationplugingenericinterfaces) SOURCES += \ - deviceplugingenericinterfaces.cpp + integrationplugingenericinterfaces.cpp HEADERS += \ - deviceplugingenericinterfaces.h + integrationplugingenericinterfaces.h diff --git a/genericinterfaces/integrationplugingenericinterfaces.cpp b/genericinterfaces/integrationplugingenericinterfaces.cpp new file mode 100644 index 0000000..cf2f893 --- /dev/null +++ b/genericinterfaces/integrationplugingenericinterfaces.cpp @@ -0,0 +1,162 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* 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 . +* +* 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 +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*! + \page genericinterfaces.html + \title Generic interfaces + \brief Common interfaces to test the rule engine. + + \ingroup plugins + \ingroup nymea-tests + + The generic interfaces plugin allows you create virtual buttons, which can be connected with a rule. This gives you + the possibility to execute multiple \l{Action}{Actions} with one signal. Without a rule this generic interfaces are + useless. + + \chapter Plugin properties + Following JSON file contains the definition and the description of all available \l{ThingClass}{DeviceClasses} + and \l{Vendor}{Vendors} of this \l{DevicePlugin}. + + For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}. + + \quotefile plugins/deviceplugins/genericinterfaces/deviceplugingenericinterfaces.json +*/ + + +#include "integrationplugingenericinterfaces.h" +#include "plugininfo.h" + +#include + +IntegrationPluginGenericInterfaces::IntegrationPluginGenericInterfaces() +{ +} + +void IntegrationPluginGenericInterfaces::setupThing(ThingSetupInfo *info) +{ + info->finish(Thing::ThingErrorNoError); +} + +void IntegrationPluginGenericInterfaces::executeAction(ThingActionInfo *info) +{ + Thing *thing = info->thing(); + Action action = info->action(); + + if (thing->thingClassId() == awningThingClassId) { + if (action.actionTypeId() == awningOpenActionTypeId) { + thing->setStateValue(awningStatusStateTypeId, "Opening"); + thing->setStateValue(awningClosingOutputStateTypeId, false); + thing->setStateValue(awningOpeningOutputStateTypeId, true); + return info->finish(Thing::ThingErrorNoError); + } + if (action.actionTypeId() == awningStopActionTypeId) { + thing->setStateValue(awningStatusStateTypeId, "Stopped"); + thing->setStateValue(awningOpeningOutputStateTypeId, false); + thing->setStateValue(awningClosingOutputStateTypeId, false); + return info->finish(Thing::ThingErrorNoError); + } + if (action.actionTypeId() == awningCloseActionTypeId) { + thing->setStateValue(awningStatusStateTypeId, "Closing"); + thing->setStateValue(awningOpeningOutputStateTypeId, false); + thing->setStateValue(awningClosingOutputStateTypeId, true); + return info->finish(Thing::ThingErrorNoError); + } + return info->finish(Thing::ThingErrorActionTypeNotFound); + } + + if (thing->thingClassId() == blindThingClassId ) { + if (action.actionTypeId() == blindOpenActionTypeId) { + thing->setStateValue(blindStatusStateTypeId, "Opening"); + thing->setStateValue(blindClosingOutputStateTypeId, false); + thing->setStateValue(blindOpeningOutputStateTypeId, true); + return info->finish(Thing::ThingErrorNoError); + } + if (action.actionTypeId() == blindStopActionTypeId) { + thing->setStateValue(blindStatusStateTypeId, "Stopped"); + thing->setStateValue(blindOpeningOutputStateTypeId, false); + thing->setStateValue(blindClosingOutputStateTypeId, false); + return info->finish(Thing::ThingErrorNoError); + } + if (action.actionTypeId() == blindCloseActionTypeId) { + thing->setStateValue(blindStatusStateTypeId, "Closing"); + thing->setStateValue(blindOpeningOutputStateTypeId, false); + thing->setStateValue(blindClosingOutputStateTypeId, true); + return info->finish(Thing::ThingErrorNoError); + } + return info->finish(Thing::ThingErrorActionTypeNotFound); + } + + if (thing->thingClassId() == shutterThingClassId) { + if (action.actionTypeId() == shutterOpenActionTypeId) { + thing->setStateValue(shutterStatusStateTypeId, "Opening"); + thing->setStateValue(shutterClosingOutputStateTypeId, false); + thing->setStateValue(shutterOpeningOutputStateTypeId, true); + return info->finish(Thing::ThingErrorNoError); + } + if (action.actionTypeId() == shutterStopActionTypeId) { + thing->setStateValue(shutterStatusStateTypeId, "Stopped"); + thing->setStateValue(shutterOpeningOutputStateTypeId, false); + thing->setStateValue(shutterClosingOutputStateTypeId, false); + return info->finish(Thing::ThingErrorNoError); + } + if (action.actionTypeId() == shutterCloseActionTypeId) { + thing->setStateValue(shutterStatusStateTypeId, "Closing"); + thing->setStateValue(shutterOpeningOutputStateTypeId, false); + thing->setStateValue(shutterClosingOutputStateTypeId, true); + return info->finish(Thing::ThingErrorNoError); + } + return info->finish(Thing::ThingErrorActionTypeNotFound); + } + + if (thing->thingClassId() == socketThingClassId) { + if (action.actionTypeId() == socketPowerActionTypeId) { + thing->setStateValue(socketPowerStateTypeId, action.param(socketPowerActionPowerParamTypeId).value()); + return info->finish(Thing::ThingErrorNoError); + } + return info->finish(Thing::ThingErrorActionTypeNotFound); + } + + if (thing->thingClassId() == lightThingClassId) { + if (action.actionTypeId() == lightPowerActionTypeId) { + thing->setStateValue(lightPowerStateTypeId, action.param(lightPowerActionPowerParamTypeId).value()); + return info->finish(Thing::ThingErrorNoError); + } + return info->finish(Thing::ThingErrorActionTypeNotFound); + } + + if (thing->thingClassId() == heatingThingClassId) { + if (action.actionTypeId() == heatingPowerActionTypeId) { + thing->setStateValue(heatingPowerStateTypeId, action.param(heatingPowerActionPowerParamTypeId).value()); + return info->finish(Thing::ThingErrorNoError); + } + return info->finish(Thing::ThingErrorActionTypeNotFound); + } + return info->finish(Thing::ThingErrorThingClassNotFound); +} diff --git a/genericinterfaces/deviceplugingenericinterfaces.h b/genericinterfaces/integrationplugingenericinterfaces.h similarity index 73% rename from genericinterfaces/deviceplugingenericinterfaces.h rename to genericinterfaces/integrationplugingenericinterfaces.h index cf982e6..7e6be93 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.h +++ b/genericinterfaces/integrationplugingenericinterfaces.h @@ -28,22 +28,22 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef DEVICEPLUGINGENERICINTERFACES_H -#define DEVICEPLUGINGENERICINTERFACES_H +#ifndef INTEGRATIONPLUGINGENERICINTERFACES_H +#define INTEGRATIONPLUGINGENERICINTERFACES_H -#include "devices/deviceplugin.h" +#include "integrations/integrationplugin.h" -class DevicePluginGenericInterfaces : public DevicePlugin +class IntegrationPluginGenericInterfaces : public IntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "deviceplugingenericinterfaces.json") - Q_INTERFACES(DevicePlugin) + Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationplugingenericinterfaces.json") + Q_INTERFACES(IntegrationPlugin) public: - explicit DevicePluginGenericInterfaces(); - void setupDevice(DeviceSetupInfo *info) override; - void executeAction(DeviceActionInfo *info) override; + explicit IntegrationPluginGenericInterfaces(); + void setupThing(ThingSetupInfo *info) override; + void executeAction(ThingActionInfo *info) override; }; -#endif // DEVICEPLUGINGENERICINTERFACES_H +#endif // INTEGRATIONPLUGINGENERICINTERFACES_H diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/integrationplugingenericinterfaces.json similarity index 99% rename from genericinterfaces/deviceplugingenericinterfaces.json rename to genericinterfaces/integrationplugingenericinterfaces.json index 98bf5f7..48ab88e 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/integrationplugingenericinterfaces.json @@ -7,7 +7,7 @@ "name": "nymea", "displayName": "nymea", "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", - "deviceClasses": [ + "thingClasses": [ { "id": "9e69585f-90ba-44e4-ad90-5b4bffbe345a", "name": "awning", diff --git a/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts index 2dedbed..e842fcf 100644 --- a/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -5,45 +5,45 @@ GenericInterfaces Awning interface - The name of the DeviceClass ({9e69585f-90ba-44e4-ad90-5b4bffbe345a}) + The name of the ThingClass ({9e69585f-90ba-44e4-ad90-5b4bffbe345a}) Blind interface - The name of the DeviceClass ({17ee3657-6ad8-4ae2-8959-3cf66cec8d13}) + The name of the ThingClass ({17ee3657-6ad8-4ae2-8959-3cf66cec8d13}) Close - The name of the ActionType ({cf5303f1-67c7-4cef-b11c-eb9de6fc8a87}) of DeviceClass shutter + The name of the ActionType ({cf5303f1-67c7-4cef-b11c-eb9de6fc8a87}) of ThingClass shutter ---------- -The name of the ActionType ({86e9cf21-7487-47c4-b4be-4a940d7235fb}) of DeviceClass blind +The name of the ActionType ({86e9cf21-7487-47c4-b4be-4a940d7235fb}) of ThingClass blind ---------- -The name of the ActionType ({53b5ba77-9a34-4cd6-ad24-fb01fc465f98}) of DeviceClass awning +The name of the ActionType ({53b5ba77-9a34-4cd6-ad24-fb01fc465f98}) of ThingClass awning Closing output - The name of the ParamType (DeviceClass: shutter, EventType: closingOutput, ID: {1c35df0e-4c41-455f-893a-0145377952a0}) + The name of the ParamType (ThingClass: shutter, EventType: closingOutput, ID: {1c35df0e-4c41-455f-893a-0145377952a0}) ---------- -The name of the StateType ({1c35df0e-4c41-455f-893a-0145377952a0}) of DeviceClass shutter +The name of the StateType ({1c35df0e-4c41-455f-893a-0145377952a0}) of ThingClass shutter ---------- -The name of the ParamType (DeviceClass: blind, EventType: closingOutput, ID: {9b673430-572d-4a9c-85d3-dafadbe541cd}) +The name of the ParamType (ThingClass: blind, EventType: closingOutput, ID: {9b673430-572d-4a9c-85d3-dafadbe541cd}) ---------- -The name of the StateType ({9b673430-572d-4a9c-85d3-dafadbe541cd}) of DeviceClass blind +The name of the StateType ({9b673430-572d-4a9c-85d3-dafadbe541cd}) of ThingClass blind ---------- -The name of the ParamType (DeviceClass: awning, EventType: closingOutput, ID: {59bfd575-709f-4e43-9726-de26e6d4ca8b}) +The name of the ParamType (ThingClass: awning, EventType: closingOutput, ID: {59bfd575-709f-4e43-9726-de26e6d4ca8b}) ---------- -The name of the StateType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of DeviceClass awning +The name of the StateType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClass awning Closing output changed - The name of the EventType ({1c35df0e-4c41-455f-893a-0145377952a0}) of DeviceClass shutter + The name of the EventType ({1c35df0e-4c41-455f-893a-0145377952a0}) of ThingClass shutter ---------- -The name of the EventType ({9b673430-572d-4a9c-85d3-dafadbe541cd}) of DeviceClass blind +The name of the EventType ({9b673430-572d-4a9c-85d3-dafadbe541cd}) of ThingClass blind ---------- -The name of the EventType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of DeviceClass awning +The name of the EventType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClass awning @@ -53,127 +53,127 @@ The name of the EventType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of DeviceClas Heating interface - The name of the DeviceClass ({392854c4-3d14-4cf8-96cd-d933526bd197}) + The name of the ThingClass ({392854c4-3d14-4cf8-96cd-d933526bd197}) Light interface - The name of the DeviceClass ({c50d3216-f307-4f9f-8190-4391510c385c}) + The name of the ThingClass ({c50d3216-f307-4f9f-8190-4391510c385c}) Open - The name of the ActionType ({9deb662d-2378-4345-a898-8742d41e43c1}) of DeviceClass shutter + The name of the ActionType ({9deb662d-2378-4345-a898-8742d41e43c1}) of ThingClass shutter ---------- -The name of the ActionType ({120dc265-dbbb-4f19-9d31-c372c23479c0}) of DeviceClass blind +The name of the ActionType ({120dc265-dbbb-4f19-9d31-c372c23479c0}) of ThingClass blind ---------- -The name of the ActionType ({979e9c51-5a93-4635-85e3-01874306b229}) of DeviceClass awning +The name of the ActionType ({979e9c51-5a93-4635-85e3-01874306b229}) of ThingClass awning Opening output - The name of the ParamType (DeviceClass: shutter, EventType: openingOutput, ID: {cc547728-b309-4695-b355-49748ef2521c}) + The name of the ParamType (ThingClass: shutter, EventType: openingOutput, ID: {cc547728-b309-4695-b355-49748ef2521c}) ---------- -The name of the StateType ({cc547728-b309-4695-b355-49748ef2521c}) of DeviceClass shutter +The name of the StateType ({cc547728-b309-4695-b355-49748ef2521c}) of ThingClass shutter ---------- -The name of the ParamType (DeviceClass: blind, EventType: openingOutput, ID: {b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b}) +The name of the ParamType (ThingClass: blind, EventType: openingOutput, ID: {b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b}) ---------- -The name of the StateType ({b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b}) of DeviceClass blind +The name of the StateType ({b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b}) of ThingClass blind ---------- -The name of the ParamType (DeviceClass: awning, EventType: openingOutput, ID: {4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4}) +The name of the ParamType (ThingClass: awning, EventType: openingOutput, ID: {4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4}) ---------- -The name of the StateType ({4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4}) of DeviceClass awning +The name of the StateType ({4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4}) of ThingClass awning Opening output changed - The name of the EventType ({cc547728-b309-4695-b355-49748ef2521c}) of DeviceClass shutter + The name of the EventType ({cc547728-b309-4695-b355-49748ef2521c}) of ThingClass shutter ---------- -The name of the EventType ({b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b}) of DeviceClass blind +The name of the EventType ({b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b}) of ThingClass blind ---------- -The name of the EventType ({4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4}) of DeviceClass awning +The name of the EventType ({4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4}) of ThingClass awning Power - The name of the ParamType (DeviceClass: heating, ActionType: power, ID: {409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) + The name of the ParamType (ThingClass: heating, ActionType: power, ID: {409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) ---------- -The name of the ParamType (DeviceClass: heating, EventType: power, ID: {409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) +The name of the ParamType (ThingClass: heating, EventType: power, ID: {409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) ---------- -The name of the StateType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of DeviceClass heating +The name of the StateType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating ---------- -The name of the ParamType (DeviceClass: light, ActionType: power, ID: {8b6e4a67-6522-408b-b676-8d2f09ed2d54}) +The name of the ParamType (ThingClass: light, ActionType: power, ID: {8b6e4a67-6522-408b-b676-8d2f09ed2d54}) ---------- -The name of the ParamType (DeviceClass: light, EventType: power, ID: {8b6e4a67-6522-408b-b676-8d2f09ed2d54}) +The name of the ParamType (ThingClass: light, EventType: power, ID: {8b6e4a67-6522-408b-b676-8d2f09ed2d54}) ---------- -The name of the StateType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of DeviceClass light +The name of the StateType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of ThingClass light ---------- -The name of the ParamType (DeviceClass: socket, ActionType: power, ID: {018038d7-1d02-4b17-8fe3-babca044b087}) +The name of the ParamType (ThingClass: socket, ActionType: power, ID: {018038d7-1d02-4b17-8fe3-babca044b087}) ---------- -The name of the ParamType (DeviceClass: socket, EventType: power, ID: {018038d7-1d02-4b17-8fe3-babca044b087}) +The name of the ParamType (ThingClass: socket, EventType: power, ID: {018038d7-1d02-4b17-8fe3-babca044b087}) ---------- -The name of the StateType ({018038d7-1d02-4b17-8fe3-babca044b087}) of DeviceClass socket +The name of the StateType ({018038d7-1d02-4b17-8fe3-babca044b087}) of ThingClass socket Power changed - The name of the EventType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of DeviceClass heating + The name of the EventType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating ---------- -The name of the EventType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of DeviceClass light +The name of the EventType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of ThingClass light ---------- -The name of the EventType ({018038d7-1d02-4b17-8fe3-babca044b087}) of DeviceClass socket +The name of the EventType ({018038d7-1d02-4b17-8fe3-babca044b087}) of ThingClass socket Set power - The name of the ActionType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of DeviceClass heating + The name of the ActionType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating ---------- -The name of the ActionType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of DeviceClass light +The name of the ActionType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of ThingClass light ---------- -The name of the ActionType ({018038d7-1d02-4b17-8fe3-babca044b087}) of DeviceClass socket +The name of the ActionType ({018038d7-1d02-4b17-8fe3-babca044b087}) of ThingClass socket Shutter interface - The name of the DeviceClass ({7917c2e7-d7d2-4c47-a38d-41f7dd7693d9}) + The name of the ThingClass ({7917c2e7-d7d2-4c47-a38d-41f7dd7693d9}) Socket interface - The name of the DeviceClass ({4e7261af-a27b-4446-8346-914ea59f7547}) + The name of the ThingClass ({4e7261af-a27b-4446-8346-914ea59f7547}) Status - The name of the ParamType (DeviceClass: shutter, EventType: status, ID: {6d6e72dc-4d2b-4ec1-82c2-54405a682711}) + The name of the ParamType (ThingClass: shutter, EventType: status, ID: {6d6e72dc-4d2b-4ec1-82c2-54405a682711}) ---------- -The name of the StateType ({6d6e72dc-4d2b-4ec1-82c2-54405a682711}) of DeviceClass shutter +The name of the StateType ({6d6e72dc-4d2b-4ec1-82c2-54405a682711}) of ThingClass shutter ---------- -The name of the ParamType (DeviceClass: blind, EventType: status, ID: {5fdec1e0-51f6-48b9-b743-ba572504b2c1}) +The name of the ParamType (ThingClass: blind, EventType: status, ID: {5fdec1e0-51f6-48b9-b743-ba572504b2c1}) ---------- -The name of the StateType ({5fdec1e0-51f6-48b9-b743-ba572504b2c1}) of DeviceClass blind +The name of the StateType ({5fdec1e0-51f6-48b9-b743-ba572504b2c1}) of ThingClass blind ---------- -The name of the ParamType (DeviceClass: awning, EventType: status, ID: {ff6f2565-2a2e-4d34-b10f-d3f73b676399}) +The name of the ParamType (ThingClass: awning, EventType: status, ID: {ff6f2565-2a2e-4d34-b10f-d3f73b676399}) ---------- -The name of the StateType ({ff6f2565-2a2e-4d34-b10f-d3f73b676399}) of DeviceClass awning +The name of the StateType ({ff6f2565-2a2e-4d34-b10f-d3f73b676399}) of ThingClass awning Status changed - The name of the EventType ({6d6e72dc-4d2b-4ec1-82c2-54405a682711}) of DeviceClass shutter + The name of the EventType ({6d6e72dc-4d2b-4ec1-82c2-54405a682711}) of ThingClass shutter ---------- -The name of the EventType ({5fdec1e0-51f6-48b9-b743-ba572504b2c1}) of DeviceClass blind +The name of the EventType ({5fdec1e0-51f6-48b9-b743-ba572504b2c1}) of ThingClass blind ---------- -The name of the EventType ({ff6f2565-2a2e-4d34-b10f-d3f73b676399}) of DeviceClass awning +The name of the EventType ({ff6f2565-2a2e-4d34-b10f-d3f73b676399}) of ThingClass awning Stop - The name of the ActionType ({db5f3332-1f4e-4f9e-84d2-93c5d7de315c}) of DeviceClass shutter + The name of the ActionType ({db5f3332-1f4e-4f9e-84d2-93c5d7de315c}) of ThingClass shutter ---------- -The name of the ActionType ({1a924c9a-5dcb-4b1c-8fd6-ab101098e007}) of DeviceClass blind +The name of the ActionType ({1a924c9a-5dcb-4b1c-8fd6-ab101098e007}) of ThingClass blind ---------- -The name of the ActionType ({555cafe4-bd12-42c6-bab1-8cd59af6468e}) of DeviceClass awning +The name of the ActionType ({555cafe4-bd12-42c6-bab1-8cd59af6468e}) of ThingClass awning