From ca36496b46ebc36b55cccdf9476b78a537ccb06e Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 17 Jan 2021 15:44:11 +0100 Subject: [PATCH 1/2] GenericThings: Add a generic door/window sensor --- .../integrationplugingenericthings.cpp | 8 ++++++++ .../integrationplugingenericthings.json | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index cb96c4a7..f27d9090 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -693,6 +693,14 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) return; } Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); + } else if (thing->thingClassId() == doorSensorThingClassId) { + if (action.actionTypeId() == doorSensorClosedActionTypeId) { + bool closed = action.paramValue(doorSensorClosedActionClosedParamTypeId).toBool(); + qCDebug(dcGenericThings()) << "Door sensor is now" << (closed ? "open" : "closed"); + thing->setStateValue(doorSensorClosedStateTypeId, closed); + info->finish(Thing::ThingErrorNoError); + return; + } } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8()); } diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 54a6097c..7610273c 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -1141,6 +1141,26 @@ "defaultValue": "" } ] + }, + { + "id": "2d936f56-48ee-4be1-9b3e-28a335ad8085", + "name": "doorSensor", + "displayName": "Gerneric door or window sensor", + "createMethods": ["user"], + "interfaces": ["closablesensor"], + "stateTypes": [ + { + "id": "7f5fdc2b-7916-4e90-9c24-558162304f71", + "name": "closed", + "displayName": "Closed", + "displayNameEvent": "Opned or closed", + "displayNameAction": "Set open or closed", + "type": "bool", + "defaultValue": false, + "writable": true, + "ioType": "digitalOutput" + } + ] } ] } From fec38d7f412f975bea57b3d3c15948610fc86a4b Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 14 Feb 2021 14:46:39 +0100 Subject: [PATCH 2/2] Update translations --- ...b3188696-2585-4806-bf98-30ab576ce5c8-de.ts | 24 +++++++++++++++++++ ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index d88fe5e2..a552310b 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -935,6 +935,30 @@ The name of the StateType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass The name of the ActionType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady Setze Relais 2 + + Closed + The name of the ParamType (ThingClass: doorSensor, ActionType: closed, ID: {7f5fdc2b-7916-4e90-9c24-558162304f71}) +---------- +The name of the ParamType (ThingClass: doorSensor, EventType: closed, ID: {7f5fdc2b-7916-4e90-9c24-558162304f71}) +---------- +The name of the StateType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + + + Gerneric door or window sensor + The name of the ThingClass ({2d936f56-48ee-4be1-9b3e-28a335ad8085}) + + + + Opned or closed + The name of the EventType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + + + Set open or closed + The name of the ActionType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + IntegrationPluginGenericThings diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts index 0843a9bd..9e50e748 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -935,6 +935,30 @@ The name of the StateType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass The name of the ActionType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + + Closed + The name of the ParamType (ThingClass: doorSensor, ActionType: closed, ID: {7f5fdc2b-7916-4e90-9c24-558162304f71}) +---------- +The name of the ParamType (ThingClass: doorSensor, EventType: closed, ID: {7f5fdc2b-7916-4e90-9c24-558162304f71}) +---------- +The name of the StateType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + + + Gerneric door or window sensor + The name of the ThingClass ({2d936f56-48ee-4be1-9b3e-28a335ad8085}) + + + + Opned or closed + The name of the EventType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + + + Set open or closed + The name of the ActionType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + IntegrationPluginGenericThings