added status state to shading devices

This commit is contained in:
nymea 2019-06-09 00:54:55 +02:00
parent 2d1ff9ab42
commit 0ceefdb218
2 changed files with 48 additions and 0 deletions

View File

@ -85,16 +85,19 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *
{ {
if (device->deviceClassId() == awningDeviceClassId) { if (device->deviceClassId() == awningDeviceClassId) {
if (action.actionTypeId() == awningOpenActionTypeId) { if (action.actionTypeId() == awningOpenActionTypeId) {
device->setStateValue(awningStatusStateTypeId, "Opening");
device->setStateValue(awningClosingOutputStateTypeId, false); device->setStateValue(awningClosingOutputStateTypeId, false);
device->setStateValue(awningOpeningOutputStateTypeId, true); device->setStateValue(awningOpeningOutputStateTypeId, true);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
if (action.actionTypeId() == awningStopActionTypeId) { if (action.actionTypeId() == awningStopActionTypeId) {
device->setStateValue(awningStatusStateTypeId, "Stopped");
device->setStateValue(awningOpeningOutputStateTypeId, false); device->setStateValue(awningOpeningOutputStateTypeId, false);
device->setStateValue(awningClosingOutputStateTypeId, false); device->setStateValue(awningClosingOutputStateTypeId, false);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
if (action.actionTypeId() == awningCloseActionTypeId) { if (action.actionTypeId() == awningCloseActionTypeId) {
device->setStateValue(awningStatusStateTypeId, "Closing");
device->setStateValue(awningOpeningOutputStateTypeId, false); device->setStateValue(awningOpeningOutputStateTypeId, false);
device->setStateValue(awningClosingOutputStateTypeId, true); device->setStateValue(awningClosingOutputStateTypeId, true);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
@ -104,16 +107,19 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *
if (device->deviceClassId() == blindDeviceClassId ) { if (device->deviceClassId() == blindDeviceClassId ) {
if (action.actionTypeId() == blindOpenActionTypeId) { if (action.actionTypeId() == blindOpenActionTypeId) {
device->setStateValue(blindStatusStateTypeId, "Opening");
device->setStateValue(blindClosingOutputStateTypeId, false); device->setStateValue(blindClosingOutputStateTypeId, false);
device->setStateValue(blindOpeningOutputStateTypeId, true); device->setStateValue(blindOpeningOutputStateTypeId, true);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
if (action.actionTypeId() == blindStopActionTypeId) { if (action.actionTypeId() == blindStopActionTypeId) {
device->setStateValue(blindStatusStateTypeId, "Stopped");
device->setStateValue(blindOpeningOutputStateTypeId, false); device->setStateValue(blindOpeningOutputStateTypeId, false);
device->setStateValue(blindClosingOutputStateTypeId, false); device->setStateValue(blindClosingOutputStateTypeId, false);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
if (action.actionTypeId() == blindCloseActionTypeId) { if (action.actionTypeId() == blindCloseActionTypeId) {
device->setStateValue(blindStatusStateTypeId, "Closing");
device->setStateValue(blindOpeningOutputStateTypeId, false); device->setStateValue(blindOpeningOutputStateTypeId, false);
device->setStateValue(blindClosingOutputStateTypeId, true); device->setStateValue(blindClosingOutputStateTypeId, true);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
@ -123,16 +129,19 @@ DeviceManager::DeviceError DevicePluginGenericInterfaces::executeAction(Device *
if (device->deviceClassId() == shutterDeviceClassId) { if (device->deviceClassId() == shutterDeviceClassId) {
if (action.actionTypeId() == shutterOpenActionTypeId) { if (action.actionTypeId() == shutterOpenActionTypeId) {
device->setStateValue(shutterStatusStateTypeId, "Opening");
device->setStateValue(shutterClosingOutputStateTypeId, false); device->setStateValue(shutterClosingOutputStateTypeId, false);
device->setStateValue(shutterOpeningOutputStateTypeId, true); device->setStateValue(shutterOpeningOutputStateTypeId, true);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
if (action.actionTypeId() == shutterStopActionTypeId) { if (action.actionTypeId() == shutterStopActionTypeId) {
device->setStateValue(shutterStatusStateTypeId, "Stopped");
device->setStateValue(shutterOpeningOutputStateTypeId, false); device->setStateValue(shutterOpeningOutputStateTypeId, false);
device->setStateValue(shutterClosingOutputStateTypeId, false); device->setStateValue(shutterClosingOutputStateTypeId, false);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;
} }
if (action.actionTypeId() == shutterCloseActionTypeId) { if (action.actionTypeId() == shutterCloseActionTypeId) {
device->setStateValue(shutterStatusStateTypeId, "Closing");
device->setStateValue(shutterOpeningOutputStateTypeId, false); device->setStateValue(shutterOpeningOutputStateTypeId, false);
device->setStateValue(shutterClosingOutputStateTypeId, true); device->setStateValue(shutterClosingOutputStateTypeId, true);
return DeviceManager::DeviceErrorNoError; return DeviceManager::DeviceErrorNoError;

View File

@ -30,6 +30,19 @@
"displayNameEvent": "Closing output changed", "displayNameEvent": "Closing output changed",
"type": "bool", "type": "bool",
"defaultValue": false "defaultValue": false
},
{
"id": "13c6dd56-368e-41be-873e-1c1706fe78a9",
"name": "status",
"displayName": "Status",
"displayNameEvent": "Status changed",
"type": "QString",
"possibleValues": [
"Opening",
"Stopped",
"Closing"
],
"defaultValue": "Stopped"
} }
], ],
"actionTypes": [ "actionTypes": [
@ -72,6 +85,19 @@
"displayNameEvent": "Closing output changed", "displayNameEvent": "Closing output changed",
"type": "bool", "type": "bool",
"defaultValue": false "defaultValue": false
},
{
"id": "13c6dd56-368e-41be-873e-1c1706fe78a9",
"name": "status",
"displayName": "Status",
"displayNameEvent": "Status changed",
"type": "QString",
"possibleValues": [
"Opening",
"Stopped",
"Closing"
],
"defaultValue": "Stopped"
} }
], ],
"actionTypes": [ "actionTypes": [
@ -114,6 +140,19 @@
"displayNameEvent": "Closing output changed", "displayNameEvent": "Closing output changed",
"type": "bool", "type": "bool",
"defaultValue": false "defaultValue": false
},
{
"id": "13c6dd56-368e-41be-873e-1c1706fe78a9",
"name": "status",
"displayName": "Status",
"displayNameEvent": "Status changed",
"type": "QString",
"possibleValues": [
"Opening",
"Stopped",
"Closing"
],
"defaultValue": "Stopped"
} }
], ],
"actionTypes": [ "actionTypes": [