From 41908add142dc343226e89cf82007ba243481a8c Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 1 Apr 2021 12:56:46 +0200 Subject: [PATCH] GenericThings: Add a generic presense sensor --- .../integrationplugingenericthings.cpp | 11 ++ .../integrationplugingenericthings.json | 51 +++--- ...b3188696-2585-4806-bf98-30ab576ce5c8-de.ts | 155 ++++++++++++++---- ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 139 ++++++++++++---- 4 files changed, 271 insertions(+), 85 deletions(-) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index eac714b..d467cd2 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -741,6 +741,17 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) info->finish(Thing::ThingErrorNoError); return; } + } else if (thing->thingClassId() == presenceSensorThingClassId) { + if (action.actionTypeId() == presenceSensorIsPresentActionTypeId) { + bool isPresent = action.paramValue(presenceSensorIsPresentActionIsPresentParamTypeId).toBool(); + qCDebug(dcGenericThings()) << "Presence sensor is now" << (isPresent ? "present" : "not present"); + thing->setStateValue(presenceSensorIsPresentStateTypeId, isPresent); + if (isPresent) { + thing->setStateValue(presenceSensorLastSeenTimeStateTypeId, QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000); + } + 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 f649e1a..9fcd2f3 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -1180,26 +1180,6 @@ } ] }, - { - "id": "e808fc5b-12fb-46d4-bb5d-25a4586bc0ba", - "name": "heating", - "displayName": "Generic heater", - "createMethods": ["user"], - "interfaces": ["heating"], - "stateTypes": [ - { - "id": "bb6b5e3a-d4d9-4440-a098-0720c14ad679", - "name": "power", - "displayName": "Heater on/off", - "displayNameEvent": "Heater turned on/off", - "displayNameAction": "Turn heater on/off", - "type": "bool", - "defaultValue": false, - "writable": true, - "ioType": "digitalInput" - } - ] - }, { "id": "09edbc07-d382-48a4-9b16-99992014aff9", "name": "cooling", @@ -1284,7 +1264,7 @@ "id": "7f5fdc2b-7916-4e90-9c24-558162304f71", "name": "closed", "displayName": "Closed", - "displayNameEvent": "Opned or closed", + "displayNameEvent": "Opened or closed", "displayNameAction": "Set open or closed", "type": "bool", "defaultValue": false, @@ -1292,6 +1272,35 @@ "ioType": "digitalOutput" } ] + }, + { + "id": "339a0c54-4086-404f-8d36-bcf20621b785", + "name": "presenceSensor", + "displayName": "Generic presence sensor", + "createMethods": ["user"], + "interfaces": ["presencesensor"], + "stateTypes": [ + { + "id": "22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c", + "name": "isPresent", + "displayName": "Presence detected", + "displayNameEvent": "Presense changed", + "displayNameAction": "Set presence", + "type": "bool", + "defaultValue": false, + "ioType": "digitalOutput", + "writable": true + }, + { + "id": "be4842cb-140c-425f-9630-8bb19fdb943e", + "name": "lastSeenTime", + "displayName": "Last seen time", + "displayNameEvent": "Last seen time changed", + "type": "int", + "unit": "UnixTime", + "defaultValue": 0 + } + ] } ] } diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index d311860..a3333d1 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -250,7 +250,9 @@ The name of the EventType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass Maximum temperature - The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {8b5947ab-127f-4995-853b-eeeb628811e3}) + The name of the ParamType (ThingClass: thermostat, Type: settings, ID: {85608dd5-7e67-4c98-9e62-b97411681048}) +---------- +The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {8b5947ab-127f-4995-853b-eeeb628811e3}) Maximale Temperatur @@ -265,7 +267,9 @@ The name of the EventType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass Minimum temperature - The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {c86ae5d3-9335-4b6e-8231-bf3ed6670dff}) + The name of the ParamType (ThingClass: thermostat, Type: settings, ID: {67451c97-50e1-4ea6-ac43-4386fbd26698}) +---------- +The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {c86ae5d3-9335-4b6e-8231-bf3ed6670dff}) Minimale Temperatur @@ -811,15 +815,6 @@ The name of the StateType ({e645a979-1465-4592-b8b0-f4c123db0800}) of ThingClass The name of the ThingClass ({6a34ba99-e5ec-4fc9-a61f-695ed8573fa1}) Generisches Thermostat - - On/off - The name of the ParamType (ThingClass: thermostat, ActionType: power, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) ----------- -The name of the ParamType (ThingClass: thermostat, EventType: power, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) ----------- -The name of the StateType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat - Ein/aus - Set target temperature The name of the ActionType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass thermostat @@ -839,16 +834,6 @@ The name of the StateType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass The name of the EventType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass thermostat Zieltemperature geändert - - Turn on/off - The name of the ActionType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat - Schalte ein/aus - - - Turned on/off - The name of the EventType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat - Ein/aus geschalten - Set temperature sensor input The name of the ActionType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat @@ -861,9 +846,9 @@ The name of the StateType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass Temperature sensor input - The name of the ParamType (ThingClass: thermostat, ActionType: temperatureSensorInput, ID: {0f808803-0e63-47df-b024-9685998ba663}) + The name of the ParamType (ThingClass: thermostat, ActionType: temperature, ID: {0f808803-0e63-47df-b024-9685998ba663}) ---------- -The name of the ParamType (ThingClass: thermostat, EventType: temperatureSensorInput, ID: {0f808803-0e63-47df-b024-9685998ba663}) +The name of the ParamType (ThingClass: thermostat, EventType: temperature, ID: {0f808803-0e63-47df-b024-9685998ba663}) ---------- The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat Temperatursensoreingang @@ -954,49 +939,147 @@ The name of the StateType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass 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 - + Geschlossen 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 - + Generischer Tür- und Fenstersensor Set open or closed The name of the ActionType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor - + Setze offen oder geschlossen Generic light sensor The name of the ThingClass ({d4d873fd-f0fc-433f-b615-91c1506a1890}) - + Generischer Lichtsensor Light intensity The name of the ParamType (ThingClass: lightSensor, EventType: lightIntensity, ID: {fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) ---------- The name of the StateType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass lightSensor - + Helligkeit Light intensity changed The name of the EventType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass lightSensor - + Helligkeit geändert Maximum Lux The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {7fe74404-d7f0-41af-a8d4-dd1bda27f752}) - + Höchster Lux-Wert Minimum Lux The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {6dea7384-b079-443b-8cc2-1479138fa212}) - + Tiefster Lux-Wert + + + Cooler on/off + The name of the ParamType (ThingClass: cooling, ActionType: power, ID: {918cfd2c-6692-4faa-acc6-18ebf93611ec}) +---------- +The name of the ParamType (ThingClass: cooling, EventType: power, ID: {918cfd2c-6692-4faa-acc6-18ebf93611ec}) +---------- +The name of the StateType ({918cfd2c-6692-4faa-acc6-18ebf93611ec}) of ThingClass cooling + Kühlung an/aus + + + Cooler turned on/off + The name of the EventType ({918cfd2c-6692-4faa-acc6-18ebf93611ec}) of ThingClass cooling + Kühlung ein- oder ausgeschaltet + + + Cooling On/off + The name of the ParamType (ThingClass: thermostat, ActionType: coolingOn, ID: {cab7d4bd-f612-4d12-b3a4-0649e189810f}) +---------- +The name of the ParamType (ThingClass: thermostat, EventType: coolingOn, ID: {cab7d4bd-f612-4d12-b3a4-0649e189810f}) +---------- +The name of the StateType ({cab7d4bd-f612-4d12-b3a4-0649e189810f}) of ThingClass thermostat + Kühlung ein/aus + + + Cooling turned on/off + The name of the EventType ({cab7d4bd-f612-4d12-b3a4-0649e189810f}) of ThingClass thermostat + Kühlung ein- oder ausgeschaltet + + + Generic cooler + The name of the ThingClass ({09edbc07-d382-48a4-9b16-99992014aff9}) + Generische Kühlung + + + Generic presence sensor + The name of the ThingClass ({339a0c54-4086-404f-8d36-bcf20621b785}) + Generischer Anwesenheitssensor + + + Heating On/off + The name of the ParamType (ThingClass: thermostat, ActionType: heatingOn, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) +---------- +The name of the ParamType (ThingClass: thermostat, EventType: heatingOn, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) +---------- +The name of the StateType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat + Heizung ein/aus + + + Heating turned on/off + The name of the EventType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat + Heizung ein- oder ausgeschaltet + + + Last seen time + The name of the ParamType (ThingClass: presenceSensor, EventType: lastSeenTime, ID: {be4842cb-140c-425f-9630-8bb19fdb943e}) +---------- +The name of the StateType ({be4842cb-140c-425f-9630-8bb19fdb943e}) of ThingClass presenceSensor + Zuletzt gesehen + + + Last seen time changed + The name of the EventType ({be4842cb-140c-425f-9630-8bb19fdb943e}) of ThingClass presenceSensor + Zuletzt gesehen geändert + + + Presence detected + The name of the ParamType (ThingClass: presenceSensor, ActionType: isPresent, ID: {22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) +---------- +The name of the ParamType (ThingClass: presenceSensor, EventType: isPresent, ID: {22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) +---------- +The name of the StateType ({22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) of ThingClass presenceSensor + Anwesenheit erkannt + + + Presense changed + The name of the EventType ({22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) of ThingClass presenceSensor + Anwesenheit geändert + + + Set presence + The name of the ActionType ({22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) of ThingClass presenceSensor + Setze Anwesenheit + + + Turn cooler on/off + The name of the ActionType ({918cfd2c-6692-4faa-acc6-18ebf93611ec}) of ThingClass cooling + Kühlung ein- oder ausschalten + + + Turn cooling on/off + The name of the ActionType ({cab7d4bd-f612-4d12-b3a4-0649e189810f}) of ThingClass thermostat + Kühlung ein- oder ausschalten + + + Turn heating on/off + The name of the ActionType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat + Heizung ein- oder ausschalten + + + Opened or closed + The name of the EventType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + Geöffnet oder geschlossen 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 309a01f..54bf1a2 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -250,7 +250,9 @@ The name of the EventType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass Maximum temperature - The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {8b5947ab-127f-4995-853b-eeeb628811e3}) + The name of the ParamType (ThingClass: thermostat, Type: settings, ID: {85608dd5-7e67-4c98-9e62-b97411681048}) +---------- +The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {8b5947ab-127f-4995-853b-eeeb628811e3}) @@ -265,7 +267,9 @@ The name of the EventType ({fed37466-1264-4ac1-84fd-aff3a1f7ff04}) of ThingClass Minimum temperature - The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {c86ae5d3-9335-4b6e-8231-bf3ed6670dff}) + The name of the ParamType (ThingClass: thermostat, Type: settings, ID: {67451c97-50e1-4ea6-ac43-4386fbd26698}) +---------- +The name of the ParamType (ThingClass: temperatureSensor, Type: settings, ID: {c86ae5d3-9335-4b6e-8231-bf3ed6670dff}) @@ -811,15 +815,6 @@ The name of the StateType ({0cc74edb-7116-47cf-953a-409933f26557}) of ThingClass The name of the ThingClass ({6a34ba99-e5ec-4fc9-a61f-695ed8573fa1}) - - On/off - The name of the ParamType (ThingClass: thermostat, ActionType: power, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) ----------- -The name of the ParamType (ThingClass: thermostat, EventType: power, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) ----------- -The name of the StateType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat - - Set target temperature The name of the ActionType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass thermostat @@ -839,16 +834,6 @@ The name of the StateType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass The name of the EventType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass thermostat - - Turn on/off - The name of the ActionType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat - - - - Turned on/off - The name of the EventType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat - - Set temperature sensor input The name of the ActionType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat @@ -861,9 +846,9 @@ The name of the StateType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass Temperature sensor input - The name of the ParamType (ThingClass: thermostat, ActionType: temperatureSensorInput, ID: {0f808803-0e63-47df-b024-9685998ba663}) + The name of the ParamType (ThingClass: thermostat, ActionType: temperature, ID: {0f808803-0e63-47df-b024-9685998ba663}) ---------- -The name of the ParamType (ThingClass: thermostat, EventType: temperatureSensorInput, ID: {0f808803-0e63-47df-b024-9685998ba663}) +The name of the ParamType (ThingClass: thermostat, EventType: temperature, ID: {0f808803-0e63-47df-b024-9685998ba663}) ---------- The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat @@ -961,11 +946,6 @@ The name of the StateType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass 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 @@ -998,6 +978,109 @@ The name of the StateType ({fe12ef32-9f2f-41cd-acb7-6b8e4acffa3b}) of ThingClass The name of the ParamType (ThingClass: lightSensor, Type: settings, ID: {6dea7384-b079-443b-8cc2-1479138fa212}) + + Cooler on/off + The name of the ParamType (ThingClass: cooling, ActionType: power, ID: {918cfd2c-6692-4faa-acc6-18ebf93611ec}) +---------- +The name of the ParamType (ThingClass: cooling, EventType: power, ID: {918cfd2c-6692-4faa-acc6-18ebf93611ec}) +---------- +The name of the StateType ({918cfd2c-6692-4faa-acc6-18ebf93611ec}) of ThingClass cooling + + + + Cooler turned on/off + The name of the EventType ({918cfd2c-6692-4faa-acc6-18ebf93611ec}) of ThingClass cooling + + + + Cooling On/off + The name of the ParamType (ThingClass: thermostat, ActionType: coolingOn, ID: {cab7d4bd-f612-4d12-b3a4-0649e189810f}) +---------- +The name of the ParamType (ThingClass: thermostat, EventType: coolingOn, ID: {cab7d4bd-f612-4d12-b3a4-0649e189810f}) +---------- +The name of the StateType ({cab7d4bd-f612-4d12-b3a4-0649e189810f}) of ThingClass thermostat + + + + Cooling turned on/off + The name of the EventType ({cab7d4bd-f612-4d12-b3a4-0649e189810f}) of ThingClass thermostat + + + + Generic cooler + The name of the ThingClass ({09edbc07-d382-48a4-9b16-99992014aff9}) + + + + Generic presence sensor + The name of the ThingClass ({339a0c54-4086-404f-8d36-bcf20621b785}) + + + + Heating On/off + The name of the ParamType (ThingClass: thermostat, ActionType: heatingOn, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) +---------- +The name of the ParamType (ThingClass: thermostat, EventType: heatingOn, ID: {1f6a0c39-4417-4e31-86db-9926cf81c345}) +---------- +The name of the StateType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat + + + + Heating turned on/off + The name of the EventType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat + + + + Last seen time + The name of the ParamType (ThingClass: presenceSensor, EventType: lastSeenTime, ID: {be4842cb-140c-425f-9630-8bb19fdb943e}) +---------- +The name of the StateType ({be4842cb-140c-425f-9630-8bb19fdb943e}) of ThingClass presenceSensor + + + + Last seen time changed + The name of the EventType ({be4842cb-140c-425f-9630-8bb19fdb943e}) of ThingClass presenceSensor + + + + Presence detected + The name of the ParamType (ThingClass: presenceSensor, ActionType: isPresent, ID: {22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) +---------- +The name of the ParamType (ThingClass: presenceSensor, EventType: isPresent, ID: {22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) +---------- +The name of the StateType ({22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) of ThingClass presenceSensor + + + + Presense changed + The name of the EventType ({22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) of ThingClass presenceSensor + + + + Set presence + The name of the ActionType ({22c1eac6-9bb5-4cc1-ac0d-e3e1499edd3c}) of ThingClass presenceSensor + + + + Turn cooler on/off + The name of the ActionType ({918cfd2c-6692-4faa-acc6-18ebf93611ec}) of ThingClass cooling + + + + Turn cooling on/off + The name of the ActionType ({cab7d4bd-f612-4d12-b3a4-0649e189810f}) of ThingClass thermostat + + + + Turn heating on/off + The name of the ActionType ({1f6a0c39-4417-4e31-86db-9926cf81c345}) of ThingClass thermostat + + + + Opened or closed + The name of the EventType ({7f5fdc2b-7916-4e90-9c24-558162304f71}) of ThingClass doorSensor + + IntegrationPluginGenericThings