diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index 843f2e2..6424d1d 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -243,6 +243,14 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) timer->stop(); } }); + } else if (thing->thingClassId() == thermostatThingClassId) { + thermostatCheckPowerOutputState(thing); // check the initial values + connect(thing, &Thing::settingChanged, thing, [this, thing] (const ParamTypeId ¶mTypeId, const QVariant &value) { + Q_UNUSED(value) + if (paramTypeId == thermostatSettingsTemperatureDifferenceParamTypeId) { + thermostatCheckPowerOutputState(thing); + } + }); } info->finish(Thing::ThingErrorNoError); } @@ -626,6 +634,19 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) } Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); + } else if (thing->thingClassId() == thermostatThingClassId) { + if (action.actionTypeId() == thermostatTemperatureSensorInputActionTypeId) { + thing->setStateValue(thermostatTemperatureSensorInputStateTypeId, action.param(thermostatTemperatureSensorInputActionTemperatureSensorInputParamTypeId).value()); + } else if (action.actionTypeId() == thermostatTargetTemperatureActionTypeId) { + thing->setStateValue(thermostatTargetTemperatureStateTypeId, action.param(thermostatTargetTemperatureActionTargetTemperatureParamTypeId).value()); + } else if (action.actionTypeId() == thermostatPowerActionTypeId) { + thing->setStateValue(thermostatPowerStateTypeId, action.param(thermostatPowerActionPowerParamTypeId).value()); + } else { + Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); + } + thermostatCheckPowerOutputState(thing); + info->finish(Thing::ThingErrorNoError); + return; } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8()); } @@ -779,3 +800,18 @@ void IntegrationPluginGenericThings::moveBlindToAngle(Action action, Thing *thin qCDebug(dcGenericThings()) << "Move to angle doesn't support this thingClass"; } } + +void IntegrationPluginGenericThings::thermostatCheckPowerOutputState(Thing *thing) +{ + double targetTemperature = thing->stateValue(thermostatTargetTemperatureStateTypeId).toDouble(); + double actualTemperature = thing->stateValue(thermostatTemperatureSensorInputStateTypeId).toDouble(); + double temperatureDifference = thing->setting(thermostatSettingsTemperatureDifferenceParamTypeId).toDouble(); + if (actualTemperature <= (targetTemperature-temperatureDifference)) { + thing->setStateValue(thermostatPowerStateTypeId, true); + } else if (actualTemperature >= targetTemperature) { + thing->setStateValue(thermostatPowerStateTypeId, false); + } else { + //Keep actual state + //Possible improvement add boost action where powerState = true is forced inside the hysteresis + } +} diff --git a/genericthings/integrationplugingenericthings.h b/genericthings/integrationplugingenericthings.h index e831b8b..84f188f 100644 --- a/genericthings/integrationplugingenericthings.h +++ b/genericthings/integrationplugingenericthings.h @@ -70,6 +70,8 @@ private: void setBlindState(BlindState state, Thing *thing); void moveBlindToPercentage(Action action, Thing *thing); void moveBlindToAngle(Action action, Thing *thing); + + void thermostatCheckPowerOutputState(Thing *thing); }; #endif // INTEGRATIONPLUGINGENERICTHINGS_H diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 190706e..2812ec8 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -1029,6 +1029,65 @@ "ioType": "digitalOutput" } ] + }, + { + "id": "6a34ba99-e5ec-4fc9-a61f-695ed8573fa1", + "name": "thermostat", + "displayName": "Generic thermostat", + "createMethods": ["user"], + "interfaces": ["thermostat", "heating"], + "settingsTypes": [ + { + "id": "64bf308f-a543-4e02-b787-1a1714c1f978", + "name": "temperatureDifference", + "displayName": "Temperature difference", + "type": "double", + "unit": "DegreeCelsius", + "minValue": 0.00, + "defaultValue": 2.00 + } + ], + "stateTypes": [ + { + "id": "0f808803-0e63-47df-b024-9685998ba663", + "name": "temperatureSensorInput", + "displayName": "Temperature sensor input", + "displayNameEvent": "Temperature sensor input changed", + "displayNameAction": "Set temperature sensor input", + "type": "double", + "defaultValue": 0, + "minValue": -20, + "maxValue": 50, + "unit": "DegreeCelsius", + "writable": true, + "ioType": "analogOutput" + }, + { + "id": "60169ebf-c1e3-41ed-a1bb-4b858e93ec50", + "name": "targetTemperature", + "displayName": "Target temperature", + "displayNameEvent": "Target temperature changed", + "displayNameAction": "Set target temperature", + "type": "double", + "defaultValue": 21, + "minValue": -20, + "maxValue": 50, + "unit": "DegreeCelsius", + "writable": true, + "ioType": "analogInput" + }, + { + "id": "1f6a0c39-4417-4e31-86db-9926cf81c345", + "name": "power", + "displayName": "On/off", + "displayNameEvent": "Turned on/off", + "displayNameAction": "Turn on/off", + "type": "bool", + "defaultValue": false, + "writable": true, + "ioType": "digitalInput" + } + ] } ] } diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index 2777f39..25fd04e 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -653,46 +653,46 @@ The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass Angle end to end time [ms] The name of the ParamType (ThingClass: venetianBlind, Type: settings, ID: {6c8340bf-7fd3-43e3-a75b-dfa2f6426e11}) - + Winkel Endlage zu Endlage dauer [ms] Closing duration [ms] The name of the ParamType (ThingClass: venetianBlind, Type: settings, ID: {4c0bf07d-aaab-4f67-af65-00ceaefbaa84}) ---------- The name of the ParamType (ThingClass: extendedBlind, Type: settings, ID: {27a95b8d-7f97-441b-a3be-0646c517cb06}) - + Schließzeit [ms] Garage door with position control The name of the ThingClass ({7341e689-4495-4422-851a-3e7c790394b8}) - + Garagentor mit Lageeinstellung Generic blind with position control The name of the ThingClass ({40aa9f3c-a23c-4f7f-8786-fcf3554f3e19}) - + Generisches Rollo mit Lageneinstellung Impulse The name of the ParamType (ThingClass: impulseGaragedooor, EventType: impulse, ID: {5ccaf0aa-01a4-441f-b6ca-18940da096a5}) ---------- The name of the StateType ({5ccaf0aa-01a4-441f-b6ca-18940da096a5}) of ThingClass impulseGaragedooor - + Impuls Impulse based garage door The name of the ThingClass ({d6699a12-f4a6-4c50-951c-f4f1cd0501dc}) - + Impulsgesteuertes Garagentor Impulse changed The name of the EventType ({5ccaf0aa-01a4-441f-b6ca-18940da096a5}) of ThingClass impulseGaragedooor - + Impuls geändert Impulse duration The name of the ParamType (ThingClass: impulseGaragedooor, Type: settings, ID: {962b356c-e975-4d33-b114-10f655eaf74c}) - + Impulsdauer Open position @@ -701,98 +701,165 @@ The name of the StateType ({5ccaf0aa-01a4-441f-b6ca-18940da096a5}) of ThingClass The name of the ParamType (ThingClass: extendedStatefulGaragedoor, EventType: percentage, ID: {f9244c14-0bc9-49ce-90a5-437e66245594}) ---------- The name of the StateType ({f9244c14-0bc9-49ce-90a5-437e66245594}) of ThingClass extendedStatefulGaragedoor - + Position offen Open position changed The name of the EventType ({f9244c14-0bc9-49ce-90a5-437e66245594}) of ThingClass extendedStatefulGaragedoor - + Position offen geändert Opening duration [ms] The name of the ParamType (ThingClass: extendedStatefulGaragedoor, Type: settings, ID: {04fb7724-a870-4df9-a79e-fab693931238}) - + Öffnungsdauer [ms] Operate The name of the ActionType ({ff5461c6-70fc-435e-8424-96fa59ed321e}) of ThingClass impulseGaragedooor - + Betätigen Set open position The name of the ActionType ({f9244c14-0bc9-49ce-90a5-437e66245594}) of ThingClass extendedStatefulGaragedoor - + Setze Position offen Simple garage door The name of the ThingClass ({572403b1-bc22-4620-8170-53147a546033}) - + Einfaches Garagentor State The name of the ParamType (ThingClass: extendedStatefulGaragedoor, EventType: state, ID: {0cc74edb-7116-47cf-953a-409933f26557}) ---------- The name of the StateType ({0cc74edb-7116-47cf-953a-409933f26557}) of ThingClass extendedStatefulGaragedoor - + Status State changed The name of the EventType ({0cc74edb-7116-47cf-953a-409933f26557}) of ThingClass extendedStatefulGaragedoor - + Status geändert CO2 The name of the ParamType (ThingClass: co2Sensor, EventType: co2, ID: {755c4c7f-093e-41dd-a38d-9ee18c9890d6}) ---------- The name of the StateType ({755c4c7f-093e-41dd-a38d-9ee18c9890d6}) of ThingClass co2Sensor - + CO2 CO2 changed The name of the EventType ({755c4c7f-093e-41dd-a38d-9ee18c9890d6}) of ThingClass co2Sensor - + CO2 geändert Generic CO2 sensor The name of the ThingClass ({a58a2dae-4148-4a4d-ab34-2a11124454a0}) - + Generischer CO2-Sensor Generic pressure sensor The name of the ThingClass ({9a8d804b-d1dc-450a-8c41-be491e5cdda0}) - + Generischer Drucksensor Maximum CO2 The name of the ParamType (ThingClass: co2Sensor, Type: settings, ID: {a3029bee-8b13-4aed-8ebd-eaceb603f8ef}) - + Maximum CO2 Maximum pressure The name of the ParamType (ThingClass: pressureSensor, Type: settings, ID: {06e21251-8b4f-44a1-8504-6b51f8526bd0}) - + Maximaldruck Minimum CO2 The name of the ParamType (ThingClass: co2Sensor, Type: settings, ID: {a0d8a6ec-599a-4ded-ae03-2950561f0b72}) - + Minimum CO2 Minimum pressure The name of the ParamType (ThingClass: pressureSensor, Type: settings, ID: {035e2619-f9c2-4e8f-95dd-f124ad9402d0}) - + Minimaldruck Pressure The name of the ParamType (ThingClass: pressureSensor, EventType: pressure, ID: {e645a979-1465-4592-b8b0-f4c123db0800}) ---------- The name of the StateType ({e645a979-1465-4592-b8b0-f4c123db0800}) of ThingClass pressureSensor - + Druck Pressure changed The name of the EventType ({e645a979-1465-4592-b8b0-f4c123db0800}) of ThingClass pressureSensor - + Druck geändert + + + Generic thermostat + 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 + Setze Zieltemperatur + + + Target temperature + The name of the ParamType (ThingClass: thermostat, ActionType: targetTemperature, ID: {60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) +---------- +The name of the ParamType (ThingClass: thermostat, EventType: targetTemperature, ID: {60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) +---------- +The name of the StateType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass thermostat + Zieltemperatur + + + Target temperature changed + 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 + Setze Temperatursensoreingang + + + Temperature difference + The name of the ParamType (ThingClass: thermostat, Type: settings, ID: {64bf308f-a543-4e02-b787-1a1714c1f978}) + Temperaturdifferenz + + + 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, EventType: temperatureSensorInput, ID: {0f808803-0e63-47df-b024-9685998ba663}) +---------- +The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat + Temperatursensoreingang + + + Temperature sensor input changed + The name of the EventType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat + Temperatursensoreingang geändert 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 c833ffc..0e11f3d 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -794,6 +794,73 @@ The name of the StateType ({0cc74edb-7116-47cf-953a-409933f26557}) of ThingClass The name of the EventType ({0cc74edb-7116-47cf-953a-409933f26557}) of ThingClass extendedStatefulGaragedoor + + Generic thermostat + 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 + + + + Target temperature + The name of the ParamType (ThingClass: thermostat, ActionType: targetTemperature, ID: {60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) +---------- +The name of the ParamType (ThingClass: thermostat, EventType: targetTemperature, ID: {60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) +---------- +The name of the StateType ({60169ebf-c1e3-41ed-a1bb-4b858e93ec50}) of ThingClass thermostat + + + + Target temperature changed + 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 + + + + Temperature difference + The name of the ParamType (ThingClass: thermostat, Type: settings, ID: {64bf308f-a543-4e02-b787-1a1714c1f978}) + + + + 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, EventType: temperatureSensorInput, ID: {0f808803-0e63-47df-b024-9685998ba663}) +---------- +The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat + + + + Temperature sensor input changed + The name of the EventType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat + + IntegrationPluginGenericThings