From 9bda2e8e0d7f890d3c87fa275e097cc36437dc4b Mon Sep 17 00:00:00 2001 From: nymea Date: Sat, 8 Jun 2019 22:02:48 +0200 Subject: [PATCH] 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 b88ebb6d..ce28d30a 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 9f1c5ac7..fd292ba5 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",