From 6a090b79124c51c22f7d30698e4dee596a04a664 Mon Sep 17 00:00:00 2001 From: nymea Date: Sat, 8 Jun 2019 10:51:15 +0200 Subject: [PATCH 01/10] added generic interfaces plug-in --- .../deviceplugingenericinterfaces.cpp | 158 ++++++++++++++++++ .../deviceplugingenericinterfaces.h | 44 +++++ .../deviceplugingenericinterfaces.json | 143 ++++++++++++++++ genericinterfaces/genericinterfaces.pro | 12 ++ ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 4 + nymea-plugins.pro | 1 + 6 files changed, 362 insertions(+) create mode 100644 genericinterfaces/deviceplugingenericinterfaces.cpp create mode 100644 genericinterfaces/deviceplugingenericinterfaces.h create mode 100644 genericinterfaces/deviceplugingenericinterfaces.json create mode 100644 genericinterfaces/genericinterfaces.pro create mode 100644 genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts diff --git a/genericinterfaces/deviceplugingenericinterfaces.cpp b/genericinterfaces/deviceplugingenericinterfaces.cpp new file mode 100644 index 0000000..b88ebb6 --- /dev/null +++ b/genericinterfaces/deviceplugingenericinterfaces.cpp @@ -0,0 +1,158 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2019 Bernhard Trinnes . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*! + \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 "devicemanager.h" +#include "plugininfo.h" + +#include + +DevicePluginGenericInterfaces::DevicePluginGenericInterfaces() +{ +} + +DeviceManager::DeviceSetupStatus DevicePluginGenericInterfaces::setupDevice(Device *device) +{ + if (device->deviceClassId() == awningDeviceClassId) { + return DeviceManager::DeviceSetupStatusSuccess; + } + + if (device->deviceClassId() == blindDeviceClassId) { + return DeviceManager::DeviceSetupStatusSuccess; + } + + if (device->deviceClassId() == shutterDeviceClassId) { + return DeviceManager::DeviceSetupStatusSuccess; + } + + if (device->deviceClassId() == socketDeviceClassId) { + return DeviceManager::DeviceSetupStatusSuccess; + } + + if (device->deviceClassId() == lightDeviceClassId) { + return DeviceManager::DeviceSetupStatusSuccess; + } + + if (device->deviceClassId() == heatingDeviceClassId) { + return DeviceManager::DeviceSetupStatusSuccess; + } + return DeviceManager::DeviceSetupStatusFailure; +} + +DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *device, const Action &action) +{ + if (device->deviceClassId() == awningDeviceClassId) { + if (action.actionTypeId() == awningOpenActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == awningStopActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == awningCloseActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + + if (device->deviceClassId() == blindDeviceClassId ) { + if (action.actionTypeId() == blindOpenActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == blindStopActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == blindCloseActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + + if (device->deviceClassId() == shutterDeviceClassId) { + if (action.actionTypeId() == shutterOpenActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == shutterStopActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == shutterCloseActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + + if (device->deviceClassId() == awningDeviceClassId) { + if (action.actionTypeId() == awningOpenActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == awningStopActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + if (action.actionTypeId() == awningCloseActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + + if (device->deviceClassId() == socketDeviceClassId) { + if (action.actionTypeId() == socketPowerActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + + if (device->deviceClassId() == lightDeviceClassId) { + if (action.actionTypeId() == lightPowerActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + + if (device->deviceClassId() == heatingDeviceClassId) { + if (action.actionTypeId() == heatingPowerActionTypeId) { + return DeviceManager::DeviceErrorNoError; + } + return DeviceManager::DeviceErrorActionTypeNotFound; + } + return DeviceManager::DeviceErrorDeviceClassNotFound; +} diff --git a/genericinterfaces/deviceplugingenericinterfaces.h b/genericinterfaces/deviceplugingenericinterfaces.h new file mode 100644 index 0000000..a7ed4a8 --- /dev/null +++ b/genericinterfaces/deviceplugingenericinterfaces.h @@ -0,0 +1,44 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2019 Bernhard Trinnes . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef DEVICEPLUGINGENERICINTERFACES_H +#define DEVICEPLUGINGENERICINTERFACES_H + +#include "plugin/deviceplugin.h" + +class DevicePluginGenericInterfaces : public DevicePlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "deviceplugingenericinterfaces.json") + Q_INTERFACES(DevicePlugin) + +public: + explicit DevicePluginGenericInterfaces(); + DeviceManager::DeviceSetupStatus setupDevice(Device *device) override; + +public slots: + DeviceManager::DeviceError executeAction(Device *device, const Action &action) override; + +}; + +#endif // DEVICEPLUGINGENERICINTERFACES_H diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json new file mode 100644 index 0000000..9f1c5ac --- /dev/null +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -0,0 +1,143 @@ +{ + "name": "GenericInterfaces", + "displayName": "Generic Interfaces", + "id": "b3188696-2585-4806-bf98-30ab576ce5c8", + "vendors": [ + { + "name": "nymea", + "displayName": "nymea", + "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", + "deviceClasses": [ + { + "id": "", + "name": "awning", + "displayName": "Awning", + "createMethods": ["user"], + "interfaces": ["awning"], + "actionTypes": [ + { + "id": "979e9c51-5a93-4635-85e3-01874306b229", + "name": "open", + "displayName": "Open" + }, + { + "id": "555cafe4-bd12-42c6-bab1-8cd59af6468e", + "name": "stop", + "displayName": "stop" + }, + { + "id": "53b5ba77-9a34-4cd6-ad24-fb01fc465f98", + "name": "close", + "displayName": "close" + } + ] + }, + { + "id": "17ee3657-6ad8-4ae2-8959-3cf66cec8d13", + "name": "blind", + "displayName": "Blind", + "createMethods": ["user"], + "interfaces": ["blind"], + "actionTypes": [ + { + "id": "120dc265-dbbb-4f19-9d31-c372c23479c0", + "name": "open", + "displayName": "Open" + }, + { + "id": "1a924c9a-5dcb-4b1c-8fd6-ab101098e007", + "name": "stop", + "displayName": "stop" + }, + { + "id": "86e9cf21-7487-47c4-b4be-4a940d7235fb", + "name": "close", + "displayName": "close" + } + ] + }, + { + "id": "7917c2e7-d7d2-4c47-a38d-41f7dd7693d9", + "name": "shutter", + "displayName": "Shutter", + "createMethods": ["user"], + "interfaces": ["shutter"], + "actionTypes": [ + { + "id": "9deb662d-2378-4345-a898-8742d41e43c1", + "name": "open", + "displayName": "Open" + }, + { + "id": "db5f3332-1f4e-4f9e-84d2-93c5d7de315c", + "name": "stop", + "displayName": "stop" + }, + { + "id": "cf5303f1-67c7-4cef-b11c-eb9de6fc8a87", + "name": "close", + "displayName": "close" + } + ] + }, + { + "id": "4e7261af-a27b-4446-8346-914ea59f7547", + "name": "socket", + "displayName": "Socket", + "createMethods": ["user"], + "interfaces": ["powersocket"], + "stateTypes": [ + { + "id": "018038d7-1d02-4b17-8fe3-babca044b087", + "name": "power", + "displayName": "Power", + "displayNameEvent": "Power changed", + "displayNameAction": "Set power", + "type": "bool", + "defaultValue": false, + "writable": true + } + ] + }, + { + "id": "c50d3216-f307-4f9f-8190-4391510c385c", + "name": "light", + "displayName": "Light", + "createMethods": ["user"], + "interfaces": ["light"], + "stateTypes": [ + { + "id": "8b6e4a67-6522-408b-b676-8d2f09ed2d54", + "name": "power", + "displayName": "Power", + "displayNameEvent": "Power changed", + "displayNameAction": "Set power", + "type": "bool", + "defaultValue": false, + "writable": true + } + ] + }, + { + "id": "392854c4-3d14-4cf8-96cd-d933526bd197", + "name": "heating", + "displayName": "Heating", + "createMethods": ["user"], + "interfaces": ["heating"], + "stateTypes": [ + { + "id": "409b635e-a754-4b5c-b3f0-d1c5a0fb3f03", + "name": "power", + "displayName": "Power", + "displayNameEvent": "Power changed", + "displayNameAction": "Set power", + "type": "bool", + "defaultValue": false, + "writable": true + } + ] + } + ] + } + ] +} diff --git a/genericinterfaces/genericinterfaces.pro b/genericinterfaces/genericinterfaces.pro new file mode 100644 index 0000000..d66633d --- /dev/null +++ b/genericinterfaces/genericinterfaces.pro @@ -0,0 +1,12 @@ +include(../plugins.pri) + +TARGET = $$qtLibraryTarget(nymea_deviceplugingenericinterfaces) + +SOURCES += \ + deviceplugingenericinterfaces.cpp + +HEADERS += \ + deviceplugingenericinterfaces.h + + + diff --git a/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts new file mode 100644 index 0000000..f7f66d8 --- /dev/null +++ b/genericinterfaces/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/nymea-plugins.pro b/nymea-plugins.pro index 8985227..b682ed0 100644 --- a/nymea-plugins.pro +++ b/nymea-plugins.pro @@ -16,6 +16,7 @@ PLUGIN_DIRS = \ eq-3 \ flowercare \ genericelements \ + genericinterfaces \ gpio \ httpcommander \ intertechno \ From 602c71e105e9639810f647cf57bd110eb5d874bf Mon Sep 17 00:00:00 2001 From: nymea Date: Sat, 8 Jun 2019 22:02:48 +0200 Subject: [PATCH 02/10] added outputs to shadings --- .../deviceplugingenericinterfaces.cpp | 32 ++++++----- .../deviceplugingenericinterfaces.json | 54 +++++++++++++++++++ 2 files changed, 73 insertions(+), 13 deletions(-) diff --git a/genericinterfaces/deviceplugingenericinterfaces.cpp b/genericinterfaces/deviceplugingenericinterfaces.cpp index b88ebb6..ce28d30 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.cpp +++ b/genericinterfaces/deviceplugingenericinterfaces.cpp @@ -1,3 +1,4 @@ + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2019 Bernhard Trinnes deviceClassId() == awningDeviceClassId) { if (action.actionTypeId() == awningOpenActionTypeId) { + device->setStateValue(awningClosingOutputStateTypeId, false); + device->setStateValue(awningOpeningOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == awningStopActionTypeId) { + device->setStateValue(awningOpeningOutputStateTypeId, false); + device->setStateValue(awningClosingOutputStateTypeId, false); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == awningCloseActionTypeId) { + device->setStateValue(awningOpeningOutputStateTypeId, false); + device->setStateValue(awningClosingOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; @@ -97,12 +104,18 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == blindDeviceClassId ) { if (action.actionTypeId() == blindOpenActionTypeId) { + device->setStateValue(blindClosingOutputStateTypeId, false); + device->setStateValue(blindOpeningOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == blindStopActionTypeId) { + device->setStateValue(blindOpeningOutputStateTypeId, false); + device->setStateValue(blindClosingOutputStateTypeId, false); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == blindCloseActionTypeId) { + device->setStateValue(blindOpeningOutputStateTypeId, false); + device->setStateValue(blindClosingOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; @@ -110,25 +123,18 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == shutterDeviceClassId) { if (action.actionTypeId() == shutterOpenActionTypeId) { + device->setStateValue(shutterClosingOutputStateTypeId, false); + device->setStateValue(shutterOpeningOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == shutterStopActionTypeId) { + device->setStateValue(shutterOpeningOutputStateTypeId, false); + device->setStateValue(shutterClosingOutputStateTypeId, false); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == shutterCloseActionTypeId) { - return DeviceManager::DeviceErrorNoError; - } - return DeviceManager::DeviceErrorActionTypeNotFound; - } - - if (device->deviceClassId() == awningDeviceClassId) { - if (action.actionTypeId() == awningOpenActionTypeId) { - return DeviceManager::DeviceErrorNoError; - } - if (action.actionTypeId() == awningStopActionTypeId) { - return DeviceManager::DeviceErrorNoError; - } - if (action.actionTypeId() == awningCloseActionTypeId) { + device->setStateValue(shutterOpeningOutputStateTypeId, false); + device->setStateValue(shutterClosingOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json index 9f1c5ac..fd292ba 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -14,6 +14,24 @@ "displayName": "Awning", "createMethods": ["user"], "interfaces": ["awning"], + "stateTypes": [ + { + "id": "7cda95f1-beb8-464e-aa75-ef415ed6744c", + "name": "openingOutput", + "displayName": "Opening output", + "displayNameEvent": "Opening output changed", + "type": "bool", + "defaultValue": false + }, + { + "id": "9b673430-572d-4a9c-85d3-dafadbe541cd", + "name": "closingOutput", + "displayName": "Closing output", + "displayNameEvent": "Closing output changed", + "type": "bool", + "defaultValue": false + } + ], "actionTypes": [ { "id": "979e9c51-5a93-4635-85e3-01874306b229", @@ -38,6 +56,24 @@ "displayName": "Blind", "createMethods": ["user"], "interfaces": ["blind"], + "stateTypes": [ + { + "id": "7cda95f1-beb8-464e-aa75-ef415ed6744c", + "name": "openingOutput", + "displayName": "Opening output", + "displayNameEvent": "Opening output changed", + "type": "bool", + "defaultValue": false + }, + { + "id": "9b673430-572d-4a9c-85d3-dafadbe541cd", + "name": "closingOutput", + "displayName": "Closing output", + "displayNameEvent": "Closing output changed", + "type": "bool", + "defaultValue": false + } + ], "actionTypes": [ { "id": "120dc265-dbbb-4f19-9d31-c372c23479c0", @@ -62,6 +98,24 @@ "displayName": "Shutter", "createMethods": ["user"], "interfaces": ["shutter"], + "stateTypes": [ + { + "id": "7cda95f1-beb8-464e-aa75-ef415ed6744c", + "name": "openingOutput", + "displayName": "Opening output", + "displayNameEvent": "Opening output changed", + "type": "bool", + "defaultValue": false + }, + { + "id": "9b673430-572d-4a9c-85d3-dafadbe541cd", + "name": "closingOutput", + "displayName": "Closing output", + "displayNameEvent": "Closing output changed", + "type": "bool", + "defaultValue": false + } + ], "actionTypes": [ { "id": "9deb662d-2378-4345-a898-8742d41e43c1", From 2d1ff9ab425f7bb11620ea8fcc82dd5e76e5d74c Mon Sep 17 00:00:00 2001 From: nymea Date: Sat, 8 Jun 2019 23:26:20 +0200 Subject: [PATCH 03/10] fixed state value of power devices --- genericinterfaces/deviceplugingenericinterfaces.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/genericinterfaces/deviceplugingenericinterfaces.cpp b/genericinterfaces/deviceplugingenericinterfaces.cpp index ce28d30..fa4163d 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.cpp +++ b/genericinterfaces/deviceplugingenericinterfaces.cpp @@ -142,6 +142,7 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == socketDeviceClassId) { if (action.actionTypeId() == socketPowerActionTypeId) { + device->setStateValue(socketPowerStateTypeId, action.param(socketPowerActionPowerParamTypeId).value()); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; @@ -149,6 +150,7 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == lightDeviceClassId) { if (action.actionTypeId() == lightPowerActionTypeId) { + device->setStateValue(lightPowerStateTypeId, action.param(lightPowerActionPowerParamTypeId).value()); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; @@ -156,6 +158,7 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == heatingDeviceClassId) { if (action.actionTypeId() == heatingPowerActionTypeId) { + device->setStateValue(heatingPowerStateTypeId, action.param(heatingPowerActionPowerParamTypeId).value()); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; From 0ceefdb2186baac90eb431080862eb6bbaf3be49 Mon Sep 17 00:00:00 2001 From: nymea Date: Sun, 9 Jun 2019 00:54:55 +0200 Subject: [PATCH 04/10] added status state to shading devices --- .../deviceplugingenericinterfaces.cpp | 9 +++++ .../deviceplugingenericinterfaces.json | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/genericinterfaces/deviceplugingenericinterfaces.cpp b/genericinterfaces/deviceplugingenericinterfaces.cpp index fa4163d..8dae75c 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.cpp +++ b/genericinterfaces/deviceplugingenericinterfaces.cpp @@ -85,16 +85,19 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * { if (device->deviceClassId() == awningDeviceClassId) { if (action.actionTypeId() == awningOpenActionTypeId) { + device->setStateValue(awningStatusStateTypeId, "Opening"); device->setStateValue(awningClosingOutputStateTypeId, false); device->setStateValue(awningOpeningOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == awningStopActionTypeId) { + device->setStateValue(awningStatusStateTypeId, "Stopped"); device->setStateValue(awningOpeningOutputStateTypeId, false); device->setStateValue(awningClosingOutputStateTypeId, false); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == awningCloseActionTypeId) { + device->setStateValue(awningStatusStateTypeId, "Closing"); device->setStateValue(awningOpeningOutputStateTypeId, false); device->setStateValue(awningClosingOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; @@ -104,16 +107,19 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == blindDeviceClassId ) { if (action.actionTypeId() == blindOpenActionTypeId) { + device->setStateValue(blindStatusStateTypeId, "Opening"); device->setStateValue(blindClosingOutputStateTypeId, false); device->setStateValue(blindOpeningOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == blindStopActionTypeId) { + device->setStateValue(blindStatusStateTypeId, "Stopped"); device->setStateValue(blindOpeningOutputStateTypeId, false); device->setStateValue(blindClosingOutputStateTypeId, false); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == blindCloseActionTypeId) { + device->setStateValue(blindStatusStateTypeId, "Closing"); device->setStateValue(blindOpeningOutputStateTypeId, false); device->setStateValue(blindClosingOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; @@ -123,16 +129,19 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * if (device->deviceClassId() == shutterDeviceClassId) { if (action.actionTypeId() == shutterOpenActionTypeId) { + device->setStateValue(shutterStatusStateTypeId, "Opening"); device->setStateValue(shutterClosingOutputStateTypeId, false); device->setStateValue(shutterOpeningOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == shutterStopActionTypeId) { + device->setStateValue(shutterStatusStateTypeId, "Stopped"); device->setStateValue(shutterOpeningOutputStateTypeId, false); device->setStateValue(shutterClosingOutputStateTypeId, false); return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == shutterCloseActionTypeId) { + device->setStateValue(shutterStatusStateTypeId, "Closing"); device->setStateValue(shutterOpeningOutputStateTypeId, false); device->setStateValue(shutterClosingOutputStateTypeId, true); return DeviceManager::DeviceErrorNoError; diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json index fd292ba..02be8b3 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -30,6 +30,19 @@ "displayNameEvent": "Closing output changed", "type": "bool", "defaultValue": false + }, + { + "id": "13c6dd56-368e-41be-873e-1c1706fe78a9", + "name": "status", + "displayName": "Status", + "displayNameEvent": "Status changed", + "type": "QString", + "possibleValues": [ + "Opening", + "Stopped", + "Closing" + ], + "defaultValue": "Stopped" } ], "actionTypes": [ @@ -72,6 +85,19 @@ "displayNameEvent": "Closing output changed", "type": "bool", "defaultValue": false + }, + { + "id": "13c6dd56-368e-41be-873e-1c1706fe78a9", + "name": "status", + "displayName": "Status", + "displayNameEvent": "Status changed", + "type": "QString", + "possibleValues": [ + "Opening", + "Stopped", + "Closing" + ], + "defaultValue": "Stopped" } ], "actionTypes": [ @@ -114,6 +140,19 @@ "displayNameEvent": "Closing output changed", "type": "bool", "defaultValue": false + }, + { + "id": "13c6dd56-368e-41be-873e-1c1706fe78a9", + "name": "status", + "displayName": "Status", + "displayNameEvent": "Status changed", + "type": "QString", + "possibleValues": [ + "Opening", + "Stopped", + "Closing" + ], + "defaultValue": "Stopped" } ], "actionTypes": [ From b2039c4e70c4fdf120d851dca10857c9ab98fe4b Mon Sep 17 00:00:00 2001 From: nymea Date: Sun, 9 Jun 2019 01:01:47 +0200 Subject: [PATCH 05/10] fixed state value of power devices --- genericinterfaces/deviceplugingenericinterfaces.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json index 02be8b3..b0576df 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -54,12 +54,12 @@ { "id": "555cafe4-bd12-42c6-bab1-8cd59af6468e", "name": "stop", - "displayName": "stop" + "displayName": "Stop" }, { "id": "53b5ba77-9a34-4cd6-ad24-fb01fc465f98", "name": "close", - "displayName": "close" + "displayName": "Close" } ] }, @@ -109,12 +109,12 @@ { "id": "1a924c9a-5dcb-4b1c-8fd6-ab101098e007", "name": "stop", - "displayName": "stop" + "displayName": "Stop" }, { "id": "86e9cf21-7487-47c4-b4be-4a940d7235fb", "name": "close", - "displayName": "close" + "displayName": "Close" } ] }, @@ -164,12 +164,12 @@ { "id": "db5f3332-1f4e-4f9e-84d2-93c5d7de315c", "name": "stop", - "displayName": "stop" + "displayName": "Stop" }, { "id": "cf5303f1-67c7-4cef-b11c-eb9de6fc8a87", "name": "close", - "displayName": "close" + "displayName": "Close" } ] }, From 73f585550ada1de624fb692dfe9a40c9f5092ce8 Mon Sep 17 00:00:00 2001 From: nymea Date: Sat, 13 Jul 2019 17:56:23 +0200 Subject: [PATCH 06/10] updated device API --- .../deviceplugingenericinterfaces.cpp | 58 +++++++++---------- .../deviceplugingenericinterfaces.h | 6 +- .../deviceplugingenericinterfaces.json | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/genericinterfaces/deviceplugingenericinterfaces.cpp b/genericinterfaces/deviceplugingenericinterfaces.cpp index 8dae75c..b3535a9 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.cpp +++ b/genericinterfaces/deviceplugingenericinterfaces.cpp @@ -44,7 +44,7 @@ #include "deviceplugingenericinterfaces.h" -#include "devicemanager.h" +#include "devices/devicemanager.h" #include "plugininfo.h" #include @@ -53,56 +53,56 @@ DevicePluginGenericInterfaces::DevicePluginGenericInterfaces() { } -DeviceManager::DeviceSetupStatus DevicePluginGenericInterfaces::setupDevice(Device *device) +Device::DeviceSetupStatus DevicePluginGenericInterfaces::setupDevice(Device *device) { if (device->deviceClassId() == awningDeviceClassId) { - return DeviceManager::DeviceSetupStatusSuccess; + return Device::DeviceSetupStatusSuccess; } if (device->deviceClassId() == blindDeviceClassId) { - return DeviceManager::DeviceSetupStatusSuccess; + return Device::DeviceSetupStatusSuccess; } if (device->deviceClassId() == shutterDeviceClassId) { - return DeviceManager::DeviceSetupStatusSuccess; + return Device::DeviceSetupStatusSuccess; } if (device->deviceClassId() == socketDeviceClassId) { - return DeviceManager::DeviceSetupStatusSuccess; + return Device::DeviceSetupStatusSuccess; } if (device->deviceClassId() == lightDeviceClassId) { - return DeviceManager::DeviceSetupStatusSuccess; + return Device::DeviceSetupStatusSuccess; } if (device->deviceClassId() == heatingDeviceClassId) { - return DeviceManager::DeviceSetupStatusSuccess; + return Device::DeviceSetupStatusSuccess; } - return DeviceManager::DeviceSetupStatusFailure; + return Device::DeviceSetupStatusFailure; } -DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *device, const Action &action) +Device::DeviceError DevicePluginGenericInterfaces::executeAction(Device *device, const Action &action) { if (device->deviceClassId() == awningDeviceClassId) { if (action.actionTypeId() == awningOpenActionTypeId) { device->setStateValue(awningStatusStateTypeId, "Opening"); device->setStateValue(awningClosingOutputStateTypeId, false); device->setStateValue(awningOpeningOutputStateTypeId, true); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } if (action.actionTypeId() == awningStopActionTypeId) { device->setStateValue(awningStatusStateTypeId, "Stopped"); device->setStateValue(awningOpeningOutputStateTypeId, false); device->setStateValue(awningClosingOutputStateTypeId, false); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } if (action.actionTypeId() == awningCloseActionTypeId) { device->setStateValue(awningStatusStateTypeId, "Closing"); device->setStateValue(awningOpeningOutputStateTypeId, false); device->setStateValue(awningClosingOutputStateTypeId, true); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } - return DeviceManager::DeviceErrorActionTypeNotFound; + return Device::DeviceErrorActionTypeNotFound; } if (device->deviceClassId() == blindDeviceClassId ) { @@ -110,21 +110,21 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * device->setStateValue(blindStatusStateTypeId, "Opening"); device->setStateValue(blindClosingOutputStateTypeId, false); device->setStateValue(blindOpeningOutputStateTypeId, true); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } if (action.actionTypeId() == blindStopActionTypeId) { device->setStateValue(blindStatusStateTypeId, "Stopped"); device->setStateValue(blindOpeningOutputStateTypeId, false); device->setStateValue(blindClosingOutputStateTypeId, false); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } if (action.actionTypeId() == blindCloseActionTypeId) { device->setStateValue(blindStatusStateTypeId, "Closing"); device->setStateValue(blindOpeningOutputStateTypeId, false); device->setStateValue(blindClosingOutputStateTypeId, true); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } - return DeviceManager::DeviceErrorActionTypeNotFound; + return Device::DeviceErrorActionTypeNotFound; } if (device->deviceClassId() == shutterDeviceClassId) { @@ -132,45 +132,45 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device * device->setStateValue(shutterStatusStateTypeId, "Opening"); device->setStateValue(shutterClosingOutputStateTypeId, false); device->setStateValue(shutterOpeningOutputStateTypeId, true); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } if (action.actionTypeId() == shutterStopActionTypeId) { device->setStateValue(shutterStatusStateTypeId, "Stopped"); device->setStateValue(shutterOpeningOutputStateTypeId, false); device->setStateValue(shutterClosingOutputStateTypeId, false); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } if (action.actionTypeId() == shutterCloseActionTypeId) { device->setStateValue(shutterStatusStateTypeId, "Closing"); device->setStateValue(shutterOpeningOutputStateTypeId, false); device->setStateValue(shutterClosingOutputStateTypeId, true); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } - return DeviceManager::DeviceErrorActionTypeNotFound; + return Device::DeviceErrorActionTypeNotFound; } if (device->deviceClassId() == socketDeviceClassId) { if (action.actionTypeId() == socketPowerActionTypeId) { device->setStateValue(socketPowerStateTypeId, action.param(socketPowerActionPowerParamTypeId).value()); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } - return DeviceManager::DeviceErrorActionTypeNotFound; + return Device::DeviceErrorActionTypeNotFound; } if (device->deviceClassId() == lightDeviceClassId) { if (action.actionTypeId() == lightPowerActionTypeId) { device->setStateValue(lightPowerStateTypeId, action.param(lightPowerActionPowerParamTypeId).value()); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } - return DeviceManager::DeviceErrorActionTypeNotFound; + return Device::DeviceErrorActionTypeNotFound; } if (device->deviceClassId() == heatingDeviceClassId) { if (action.actionTypeId() == heatingPowerActionTypeId) { device->setStateValue(heatingPowerStateTypeId, action.param(heatingPowerActionPowerParamTypeId).value()); - return DeviceManager::DeviceErrorNoError; + return Device::DeviceErrorNoError; } - return DeviceManager::DeviceErrorActionTypeNotFound; + return Device::DeviceErrorActionTypeNotFound; } - return DeviceManager::DeviceErrorDeviceClassNotFound; + return Device::DeviceErrorDeviceClassNotFound; } diff --git a/genericinterfaces/deviceplugingenericinterfaces.h b/genericinterfaces/deviceplugingenericinterfaces.h index a7ed4a8..d63d500 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.h +++ b/genericinterfaces/deviceplugingenericinterfaces.h @@ -23,7 +23,7 @@ #ifndef DEVICEPLUGINGENERICINTERFACES_H #define DEVICEPLUGINGENERICINTERFACES_H -#include "plugin/deviceplugin.h" +#include "devices/deviceplugin.h" class DevicePluginGenericInterfaces : public DevicePlugin { @@ -34,10 +34,10 @@ class DevicePluginGenericInterfaces : public DevicePlugin public: explicit DevicePluginGenericInterfaces(); - DeviceManager::DeviceSetupStatus setupDevice(Device *device) override; + Device::DeviceSetupStatus setupDevice(Device *device) override; public slots: - DeviceManager::DeviceError executeAction(Device *device, const Action &action) override; + Device::DeviceError executeAction(Device *device, const Action &action) override; }; diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json index b0576df..162ed52 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -9,7 +9,7 @@ "id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6", "deviceClasses": [ { - "id": "", + "id": "9e69585f-90ba-44e4-ad90-5b4bffbe345a", "name": "awning", "displayName": "Awning", "createMethods": ["user"], From f7cc6e7f65ffdeb8887c82109c39ea353a674995 Mon Sep 17 00:00:00 2001 From: nymea Date: Sat, 13 Jul 2019 18:13:02 +0200 Subject: [PATCH 07/10] fixed duplicated uuids --- .../deviceplugingenericinterfaces.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json index 162ed52..dfafb4c 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -16,7 +16,7 @@ "interfaces": ["awning"], "stateTypes": [ { - "id": "7cda95f1-beb8-464e-aa75-ef415ed6744c", + "id": "4bb951a4-ea23-4cf0-9269-41d2c4eaf5a4", "name": "openingOutput", "displayName": "Opening output", "displayNameEvent": "Opening output changed", @@ -24,7 +24,7 @@ "defaultValue": false }, { - "id": "9b673430-572d-4a9c-85d3-dafadbe541cd", + "id": "59bfd575-709f-4e43-9726-de26e6d4ca8b", "name": "closingOutput", "displayName": "Closing output", "displayNameEvent": "Closing output changed", @@ -32,7 +32,7 @@ "defaultValue": false }, { - "id": "13c6dd56-368e-41be-873e-1c1706fe78a9", + "id": "ff6f2565-2a2e-4d34-b10f-d3f73b676399", "name": "status", "displayName": "Status", "displayNameEvent": "Status changed", @@ -71,7 +71,7 @@ "interfaces": ["blind"], "stateTypes": [ { - "id": "7cda95f1-beb8-464e-aa75-ef415ed6744c", + "id": "b2dbf25c-27e5-4f7e-a57d-2ef6d087fa2b", "name": "openingOutput", "displayName": "Opening output", "displayNameEvent": "Opening output changed", @@ -87,7 +87,7 @@ "defaultValue": false }, { - "id": "13c6dd56-368e-41be-873e-1c1706fe78a9", + "id": "5fdec1e0-51f6-48b9-b743-ba572504b2c1", "name": "status", "displayName": "Status", "displayNameEvent": "Status changed", @@ -126,7 +126,7 @@ "interfaces": ["shutter"], "stateTypes": [ { - "id": "7cda95f1-beb8-464e-aa75-ef415ed6744c", + "id": "cc547728-b309-4695-b355-49748ef2521c", "name": "openingOutput", "displayName": "Opening output", "displayNameEvent": "Opening output changed", @@ -134,7 +134,7 @@ "defaultValue": false }, { - "id": "9b673430-572d-4a9c-85d3-dafadbe541cd", + "id": "1c35df0e-4c41-455f-893a-0145377952a0", "name": "closingOutput", "displayName": "Closing output", "displayNameEvent": "Closing output changed", @@ -142,7 +142,7 @@ "defaultValue": false }, { - "id": "13c6dd56-368e-41be-873e-1c1706fe78a9", + "id": "6d6e72dc-4d2b-4ec1-82c2-54405a682711", "name": "status", "displayName": "Status", "displayNameEvent": "Status changed", From 5d355f08b13a8aa18915dca47c083c26f1a731dd Mon Sep 17 00:00:00 2001 From: nymea Date: Mon, 15 Jul 2019 23:07:26 +0200 Subject: [PATCH 08/10] corrected device names --- genericinterfaces/deviceplugingenericinterfaces.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/genericinterfaces/deviceplugingenericinterfaces.json b/genericinterfaces/deviceplugingenericinterfaces.json index dfafb4c..98bf5f7 100644 --- a/genericinterfaces/deviceplugingenericinterfaces.json +++ b/genericinterfaces/deviceplugingenericinterfaces.json @@ -11,7 +11,7 @@ { "id": "9e69585f-90ba-44e4-ad90-5b4bffbe345a", "name": "awning", - "displayName": "Awning", + "displayName": "Awning interface", "createMethods": ["user"], "interfaces": ["awning"], "stateTypes": [ @@ -66,7 +66,7 @@ { "id": "17ee3657-6ad8-4ae2-8959-3cf66cec8d13", "name": "blind", - "displayName": "Blind", + "displayName": "Blind interface", "createMethods": ["user"], "interfaces": ["blind"], "stateTypes": [ @@ -121,7 +121,7 @@ { "id": "7917c2e7-d7d2-4c47-a38d-41f7dd7693d9", "name": "shutter", - "displayName": "Shutter", + "displayName": "Shutter interface", "createMethods": ["user"], "interfaces": ["shutter"], "stateTypes": [ @@ -176,7 +176,7 @@ { "id": "4e7261af-a27b-4446-8346-914ea59f7547", "name": "socket", - "displayName": "Socket", + "displayName": "Socket interface", "createMethods": ["user"], "interfaces": ["powersocket"], "stateTypes": [ @@ -195,7 +195,7 @@ { "id": "c50d3216-f307-4f9f-8190-4391510c385c", "name": "light", - "displayName": "Light", + "displayName": "Light interface", "createMethods": ["user"], "interfaces": ["light"], "stateTypes": [ @@ -214,7 +214,7 @@ { "id": "392854c4-3d14-4cf8-96cd-d933526bd197", "name": "heating", - "displayName": "Heating", + "displayName": "Heating interface", "createMethods": ["user"], "interfaces": ["heating"], "stateTypes": [ From 5c515b7fd602694f1907a1ccdf60abc976294389 Mon Sep 17 00:00:00 2001 From: nymea Date: Fri, 26 Jul 2019 09:15:47 +0200 Subject: [PATCH 09/10] added plug-in to debian folder --- debian/control | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/debian/control b/debian/control index 109179e..c180846 100644 --- a/debian/control +++ b/debian/control @@ -245,6 +245,21 @@ Description: nymea.io plugin for genericelements This package will install the nymea.io plugin for genericelements +Package: nymea-plugin-genericinterfaces +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, + nymea-plugins-translations, +Description: nymea.io plugin for generic interfaces + 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 generic interfaces + + Package: nymea-plugin-gpio Architecture: any Depends: ${shlibs:Depends}, @@ -764,6 +779,7 @@ Depends: nymea-plugin-boblight, nymea-plugin-tcpcommander, nymea-plugin-httpcommander, nymea-plugin-genericelements, + nymea-plugin-genericinterfaces, nymea-plugin-avahimonitor, nymea-plugin-anel, nymea-plugin-gpio, From 2d3b0f8e74c7bdb4268096d31967604f68224bce Mon Sep 17 00:00:00 2001 From: nymea Date: Fri, 26 Jul 2019 09:18:53 +0200 Subject: [PATCH 10/10] added plug-in to debian folder --- debian/nymea-plugin-genericinterfaces.install.in | 1 + 1 file changed, 1 insertion(+) create mode 100644 debian/nymea-plugin-genericinterfaces.install.in diff --git a/debian/nymea-plugin-genericinterfaces.install.in b/debian/nymea-plugin-genericinterfaces.install.in new file mode 100644 index 0000000..a5e9bc1 --- /dev/null +++ b/debian/nymea-plugin-genericinterfaces.install.in @@ -0,0 +1 @@ +usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_deviceplugingenericinterfaces.so