diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index 6424d1d..cb96c4a 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -251,6 +251,12 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) thermostatCheckPowerOutputState(thing); } }); + } else if (thing->thingClassId() == sgReadyThingClassId) { + bool relay1 = thing->stateValue(sgReadyRelay1StateTypeId).toBool(); + bool relay2 = thing->stateValue(sgReadyRelay2StateTypeId).toBool(); + int operatingMode = sgReadyOperatingMode(relay1, relay2); + thing->setStateValue(sgReadyOperatingModeStateTypeId, operatingMode); + thing->setStateValue(sgReadyOperatingModeDescriptionStateTypeId, sgReadyOperatingModeDescription(operatingMode)); } info->finish(Thing::ThingErrorNoError); } @@ -634,6 +640,7 @@ 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()); @@ -647,6 +654,45 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) thermostatCheckPowerOutputState(thing); info->finish(Thing::ThingErrorNoError); return; + + } else if (thing->thingClassId() == sgReadyThingClassId) { + if (action.actionTypeId() == sgReadyRelay1ActionTypeId) { + thing->setStateValue(sgReadyRelay1StateTypeId, action.param(sgReadyRelay1ActionRelay1ParamTypeId).value()); + int operatingMode = sgReadyOperatingMode(thing->stateValue(sgReadyRelay1StateTypeId).toBool(), thing->stateValue(sgReadyRelay2StateTypeId).toBool()); + thing->setStateValue(sgReadyOperatingModeStateTypeId, operatingMode); + thing->setStateValue(sgReadyOperatingModeDescriptionStateTypeId, sgReadyOperatingModeDescription(operatingMode)); + info->finish(Thing::ThingErrorNoError); + return; + } + if (action.actionTypeId() == sgReadyRelay2ActionTypeId) { + thing->setStateValue(sgReadyRelay2StateTypeId, action.param(sgReadyRelay2ActionRelay2ParamTypeId).value()); + int operatingMode = sgReadyOperatingMode(thing->stateValue(sgReadyRelay1StateTypeId).toBool(), thing->stateValue(sgReadyRelay2StateTypeId).toBool()); + thing->setStateValue(sgReadyOperatingModeStateTypeId, operatingMode); + thing->setStateValue(sgReadyOperatingModeDescriptionStateTypeId, sgReadyOperatingModeDescription(operatingMode)); + info->finish(Thing::ThingErrorNoError); + return; + } + if (action.actionTypeId() == sgReadyOperatingModeActionTypeId) { + int operatingMode = action.param(sgReadyOperatingModeActionOperatingModeParamTypeId).value().toInt(); + thing->setStateValue(sgReadyOperatingModeStateTypeId, operatingMode); + thing->setStateValue(sgReadyOperatingModeDescriptionStateTypeId, sgReadyOperatingModeDescription(operatingMode)); + if (operatingMode == 1) { + thing->setStateValue(sgReadyRelay1StateTypeId, true); + thing->setStateValue(sgReadyRelay2StateTypeId, false); + } else if (operatingMode == 2) { + thing->setStateValue(sgReadyRelay1StateTypeId, false); + thing->setStateValue(sgReadyRelay2StateTypeId, false); + } else if (operatingMode == 3) { + thing->setStateValue(sgReadyRelay1StateTypeId, false); + thing->setStateValue(sgReadyRelay2StateTypeId, true); + } else if (operatingMode == 4) { + thing->setStateValue(sgReadyRelay1StateTypeId, true); + thing->setStateValue(sgReadyRelay2StateTypeId, true); + } + info->finish(Thing::ThingErrorNoError); + return; + } + Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8()); } @@ -801,6 +847,7 @@ void IntegrationPluginGenericThings::moveBlindToAngle(Action action, Thing *thin } } + void IntegrationPluginGenericThings::thermostatCheckPowerOutputState(Thing *thing) { double targetTemperature = thing->stateValue(thermostatTargetTemperatureStateTypeId).toDouble(); @@ -815,3 +862,53 @@ void IntegrationPluginGenericThings::thermostatCheckPowerOutputState(Thing *thin //Possible improvement add boost action where powerState = true is forced inside the hysteresis } } + +QString IntegrationPluginGenericThings::sgReadyOperatingModeDescription(int operatingMode) +{ + if (operatingMode == 1) { + return "Stop heating."; + } else if (operatingMode == 2) { + return "Normal mode, with partial heat storage filling."; + } else if (operatingMode == 3) { + return "Increased room and heat storage temperature."; + } else if (operatingMode == 4) { + return "Start heating."; + } + return QString("Unknown operating mode %1").arg(operatingMode); +} + +int IntegrationPluginGenericThings::sgReadyOperatingMode(bool relay1, bool relay2) +{ + if (relay1 && !relay2) { + /* + * Operating state 1 (Relay state: 1: 0): + * This operating state is downward compatible with the often fixed times + * activated EVU lock and includes a maximum of 2 hours of "hard" lock time. + */ + return 1; + } else if (!relay1 && !relay2) { + /* + * Operating state 2 (Relay state: 0: 0): + * In this circuit, the heat pump runs in energy-efficient normal mode + * with partial heat storage filling for the maximum two-hour EVU lock. + */ + return 2; + } else if (!relay1 && relay2) { + /* + * Operating state 3 (Relay state: 0: 1): + * In this operating state, the heat pump within the controller runs in amplified mode + * Operation for space heating and hot water preparation. It's not one + * definitive start-up command, but a switch-on recommendation according to the current increase. + */ + return 3; + } else { + /* + * Operating state 4 (Relay state 1: 1): + * This is a definitive start-up command, insofar as this is possible within the framework of the rule settings. + * For this operating state, different control models must be set on the controller for different tariff and usage models: + * Variant 1: The heat pump (compressor) is actively switched on. + * Variant 2: The heat pump (compressor and electrical auxiliary heating) is actively switched on, optional: higher temperature in the heat storage + */ + return 4; + } +} diff --git a/genericthings/integrationplugingenericthings.h b/genericthings/integrationplugingenericthings.h index 84f188f..8f531d5 100644 --- a/genericthings/integrationplugingenericthings.h +++ b/genericthings/integrationplugingenericthings.h @@ -72,6 +72,9 @@ private: void moveBlindToAngle(Action action, Thing *thing); void thermostatCheckPowerOutputState(Thing *thing); + + int sgReadyOperatingMode(bool relay1, bool relay2); + QString sgReadyOperatingModeDescription(int operatingMode); }; #endif // INTEGRATIONPLUGINGENERICTHINGS_H diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 2812ec8..2bcc9ea 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -1088,6 +1088,59 @@ "ioType": "digitalInput" } ] + }, + { + "id": "83cf138d-02dc-4015-9b03-6360c2f3cfb1", + "name": "sgReady", + "displayName": "SG-Ready", + "createMethods": ["user"], + "interfaces": [], + "settingsTypes": [ + ], + "stateTypes": [ + { + "id": "d080466e-7271-441f-9916-1199a6668545", + "name": "relay1", + "displayName": "Relay 1", + "displayNameEvent": "Relay 1 changed", + "displayNameAction": "Set relay 1", + "type": "bool", + "defaultValue": false, + "ioType": "digitalInput", + "writable": true + }, + { + "id": "caf22937-fdf7-41e1-a87b-d11e66c4f4c6", + "name": "relay2", + "displayName": "Relay 2", + "displayNameEvent": "Relay 2 changed", + "displayNameAction": "Set relay 2", + "type": "bool", + "defaultValue": false, + "ioType": "digitalInput", + "writable": true + }, + { + "id": "85667640-d719-4be4-a5fa-e41193eea162", + "name": "operatingMode", + "displayName": "Operating mode", + "displayNameAction": "Set operating mode", + "displayNameEvent": "Operating mode changed", + "type": "int", + "minValue": 1, + "maxValue": 4, + "writable": true, + "defaultValue": 2 + }, + { + "id": "b421d098-f6e9-40e2-b536-58acdb3a49fe", + "name": "operatingModeDescription", + "displayName": "Operating mode description", + "displayNameEvent": "Operating mode description changed", + "type": "QString", + "defaultValue": "" + } + ] } ] } diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index 25fd04e..d88fe5e 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -861,6 +861,80 @@ The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass The name of the EventType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat Temperatursensoreingang geändert + + Operating mode + The name of the ParamType (ThingClass: sgReady, ActionType: operatingMode, ID: {85667640-d719-4be4-a5fa-e41193eea162}) +---------- +The name of the ParamType (ThingClass: sgReady, EventType: operatingMode, ID: {85667640-d719-4be4-a5fa-e41193eea162}) +---------- +The name of the StateType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady + Betriebszustand + + + Operating mode changed + The name of the EventType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady + Betriebszustand geändert + + + Operating mode description + The name of the ParamType (ThingClass: sgReady, EventType: operatingModeDescription, ID: {b421d098-f6e9-40e2-b536-58acdb3a49fe}) +---------- +The name of the StateType ({b421d098-f6e9-40e2-b536-58acdb3a49fe}) of ThingClass sgReady + Betriebszustandsbeschreibung + + + Operating mode description changed + The name of the EventType ({b421d098-f6e9-40e2-b536-58acdb3a49fe}) of ThingClass sgReady + Betriebszustandsbeschreibung geändert + + + Relay 1 + The name of the ParamType (ThingClass: sgReady, ActionType: relay1, ID: {d080466e-7271-441f-9916-1199a6668545}) +---------- +The name of the ParamType (ThingClass: sgReady, EventType: relay1, ID: {d080466e-7271-441f-9916-1199a6668545}) +---------- +The name of the StateType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady + Relais 1 + + + Relay 1 changed + The name of the EventType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady + Relais 1 geändert + + + Relay 2 + The name of the ParamType (ThingClass: sgReady, ActionType: relay2, ID: {caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) +---------- +The name of the ParamType (ThingClass: sgReady, EventType: relay2, ID: {caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) +---------- +The name of the StateType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + Relais 2 + + + Relay 2 changed + The name of the EventType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + Relais 2 geändert + + + SG-Ready + The name of the ThingClass ({83cf138d-02dc-4015-9b03-6360c2f3cfb1}) + SG-Ready + + + Set operating mode + The name of the ActionType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady + Setze Betriebszustand + + + Set relay 1 + The name of the ActionType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady + Setze Relais 1 + + + Set relay 2 + The name of the ActionType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + Setze Relais 2 + 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 0e11f3d..0843a9b 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -861,6 +861,80 @@ The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass The name of the EventType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat + + Operating mode + The name of the ParamType (ThingClass: sgReady, ActionType: operatingMode, ID: {85667640-d719-4be4-a5fa-e41193eea162}) +---------- +The name of the ParamType (ThingClass: sgReady, EventType: operatingMode, ID: {85667640-d719-4be4-a5fa-e41193eea162}) +---------- +The name of the StateType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady + + + + Operating mode changed + The name of the EventType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady + + + + Operating mode description + The name of the ParamType (ThingClass: sgReady, EventType: operatingModeDescription, ID: {b421d098-f6e9-40e2-b536-58acdb3a49fe}) +---------- +The name of the StateType ({b421d098-f6e9-40e2-b536-58acdb3a49fe}) of ThingClass sgReady + + + + Operating mode description changed + The name of the EventType ({b421d098-f6e9-40e2-b536-58acdb3a49fe}) of ThingClass sgReady + + + + Relay 1 + The name of the ParamType (ThingClass: sgReady, ActionType: relay1, ID: {d080466e-7271-441f-9916-1199a6668545}) +---------- +The name of the ParamType (ThingClass: sgReady, EventType: relay1, ID: {d080466e-7271-441f-9916-1199a6668545}) +---------- +The name of the StateType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady + + + + Relay 1 changed + The name of the EventType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady + + + + Relay 2 + The name of the ParamType (ThingClass: sgReady, ActionType: relay2, ID: {caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) +---------- +The name of the ParamType (ThingClass: sgReady, EventType: relay2, ID: {caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) +---------- +The name of the StateType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + + + + Relay 2 changed + The name of the EventType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + + + + SG-Ready + The name of the ThingClass ({83cf138d-02dc-4015-9b03-6360c2f3cfb1}) + + + + Set operating mode + The name of the ActionType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady + + + + Set relay 1 + The name of the ActionType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady + + + + Set relay 2 + The name of the ActionType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady + + IntegrationPluginGenericThings