Merge PR #349: GenericThings: Add SG-Ready thingClassId

pull/1/head
Jenkins nymea 2020-12-21 18:01:45 +01:00
commit 6a78689d7a
5 changed files with 301 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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": ""
}
]
}
]
}

View File

@ -861,6 +861,80 @@ The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass
<extracomment>The name of the EventType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat</extracomment>
<translation>Temperatursensoreingang geändert</translation>
</message>
<message>
<source>Operating mode</source>
<extracomment>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</extracomment>
<translation>Betriebszustand</translation>
</message>
<message>
<source>Operating mode changed</source>
<extracomment>The name of the EventType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady</extracomment>
<translation>Betriebszustand geändert</translation>
</message>
<message>
<source>Operating mode description</source>
<extracomment>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</extracomment>
<translation>Betriebszustandsbeschreibung</translation>
</message>
<message>
<source>Operating mode description changed</source>
<extracomment>The name of the EventType ({b421d098-f6e9-40e2-b536-58acdb3a49fe}) of ThingClass sgReady</extracomment>
<translation>Betriebszustandsbeschreibung geändert</translation>
</message>
<message>
<source>Relay 1</source>
<extracomment>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</extracomment>
<translation>Relais 1</translation>
</message>
<message>
<source>Relay 1 changed</source>
<extracomment>The name of the EventType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady</extracomment>
<translation>Relais 1 geändert</translation>
</message>
<message>
<source>Relay 2</source>
<extracomment>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</extracomment>
<translation>Relais 2</translation>
</message>
<message>
<source>Relay 2 changed</source>
<extracomment>The name of the EventType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady</extracomment>
<translation>Relais 2 geändert</translation>
</message>
<message>
<source>SG-Ready</source>
<extracomment>The name of the ThingClass ({83cf138d-02dc-4015-9b03-6360c2f3cfb1})</extracomment>
<translation>SG-Ready</translation>
</message>
<message>
<source>Set operating mode</source>
<extracomment>The name of the ActionType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady</extracomment>
<translation>Setze Betriebszustand</translation>
</message>
<message>
<source>Set relay 1</source>
<extracomment>The name of the ActionType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady</extracomment>
<translation>Setze Relais 1</translation>
</message>
<message>
<source>Set relay 2</source>
<extracomment>The name of the ActionType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady</extracomment>
<translation>Setze Relais 2</translation>
</message>
</context>
<context>
<name>IntegrationPluginGenericThings</name>

View File

@ -861,6 +861,80 @@ The name of the StateType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass
<extracomment>The name of the EventType ({0f808803-0e63-47df-b024-9685998ba663}) of ThingClass thermostat</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Operating mode</source>
<extracomment>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</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Operating mode changed</source>
<extracomment>The name of the EventType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Operating mode description</source>
<extracomment>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</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Operating mode description changed</source>
<extracomment>The name of the EventType ({b421d098-f6e9-40e2-b536-58acdb3a49fe}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relay 1</source>
<extracomment>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</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relay 1 changed</source>
<extracomment>The name of the EventType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relay 2</source>
<extracomment>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</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Relay 2 changed</source>
<extracomment>The name of the EventType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>SG-Ready</source>
<extracomment>The name of the ThingClass ({83cf138d-02dc-4015-9b03-6360c2f3cfb1})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set operating mode</source>
<extracomment>The name of the ActionType ({85667640-d719-4be4-a5fa-e41193eea162}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set relay 1</source>
<extracomment>The name of the ActionType ({d080466e-7271-441f-9916-1199a6668545}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Set relay 2</source>
<extracomment>The name of the ActionType ({caf22937-fdf7-41e1-a87b-d11e66c4f4c6}) of ThingClass sgReady</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>IntegrationPluginGenericThings</name>