Skip to content

Commit

Permalink
Merge PR #490: genericthings: Update generic SG-Ready thing and add h…
Browse files Browse the repository at this point in the history
…eat pump interfaces
  • Loading branch information
nymea-jenkins committed Oct 22, 2021
2 parents a998dfc + 7f54456 commit 15f35b7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 38 deletions.
55 changes: 30 additions & 25 deletions genericthings/integrationplugingenericthings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
} 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));
QString operatingModeString = sgReadyOperatingMode(relay1, relay2);
thing->setStateValue(sgReadySgReadyModeStateTypeId, operatingModeString);
thing->setStateValue(sgReadyOperatingModeDescriptionStateTypeId, sgReadyOperatingModeDescription(operatingModeString));
} else if (thing->thingClassId() == batteryThingClassId) {
connect(thing, &Thing::settingChanged, [thing](const ParamTypeId &settingTypeId, const QVariant &value){
if (settingTypeId == batterySettingsCriticalLevelParamTypeId) {
Expand Down Expand Up @@ -815,34 +815,34 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
} 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);
QString operatingMode = sgReadyOperatingMode(thing->stateValue(sgReadyRelay1StateTypeId).toBool(), thing->stateValue(sgReadyRelay2StateTypeId).toBool());
thing->setStateValue(sgReadySgReadyModeStateTypeId, 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);
QString operatingMode = sgReadyOperatingMode(thing->stateValue(sgReadyRelay1StateTypeId).toBool(), thing->stateValue(sgReadyRelay2StateTypeId).toBool());
thing->setStateValue(sgReadySgReadyModeStateTypeId, 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);
if (action.actionTypeId() == sgReadySgReadyModeActionTypeId) {
QString operatingMode = action.paramValue(sgReadySgReadyModeActionSgReadyModeParamTypeId).toString();
thing->setStateValue(sgReadySgReadyModeStateTypeId, operatingMode);
thing->setStateValue(sgReadyOperatingModeDescriptionStateTypeId, sgReadyOperatingModeDescription(operatingMode));
if (operatingMode == 1) {
if (operatingMode == "Off") {
thing->setStateValue(sgReadyRelay1StateTypeId, true);
thing->setStateValue(sgReadyRelay2StateTypeId, false);
} else if (operatingMode == 2) {
} else if (operatingMode == "Low") {
thing->setStateValue(sgReadyRelay1StateTypeId, false);
thing->setStateValue(sgReadyRelay2StateTypeId, false);
} else if (operatingMode == 3) {
} else if (operatingMode == "Standard") {
thing->setStateValue(sgReadyRelay1StateTypeId, false);
thing->setStateValue(sgReadyRelay2StateTypeId, true);
} else if (operatingMode == 4) {
} else if (operatingMode == "High") {
thing->setStateValue(sgReadyRelay1StateTypeId, true);
thing->setStateValue(sgReadyRelay2StateTypeId, true);
}
Expand Down Expand Up @@ -900,6 +900,11 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
thing->setStateValue(carBatteryCriticalStateTypeId, action.paramValue(carBatteryLevelActionBatteryLevelParamTypeId).toInt() < 10);
info->finish(Thing::ThingErrorNoError);
}
} else if (thing->thingClassId() == simpleHeatPumpThingClassId) {
if (action.actionTypeId() == simpleHeatPumpBoostActionTypeId) {
thing->setStateValue(simpleHeatPumpBoostStateTypeId, action.paramValue(simpleHeatPumpBoostActionBoostParamTypeId).toBool());
info->finish(Thing::ThingErrorNoError);
}
} else {
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
}
Expand Down Expand Up @@ -1072,44 +1077,44 @@ void IntegrationPluginGenericThings::thermostatCheckPowerOutputState(Thing *thin
}
}

QString IntegrationPluginGenericThings::sgReadyOperatingModeDescription(int operatingMode)
QString IntegrationPluginGenericThings::sgReadyOperatingModeDescription(const QString &operatingModeString)
{
if (operatingMode == 1) {
if (operatingModeString == "Off") {
return "Stop heating.";
} else if (operatingMode == 2) {
} else if (operatingModeString == "Low") {
return "Normal mode, with partial heat storage filling.";
} else if (operatingMode == 3) {
} else if (operatingModeString == "Standard") {
return "Increased room and heat storage temperature.";
} else if (operatingMode == 4) {
} else if (operatingModeString == "High") {
return "Start heating.";
}
return QString("Unknown operating mode %1").arg(operatingMode);
return QString("Unknown operating mode %1").arg(operatingModeString);
}

int IntegrationPluginGenericThings::sgReadyOperatingMode(bool relay1, bool relay2)
QString 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;
return "Off";
} 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;
return "Low";
} 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;
return "Standard";
} else {
/*
* Operating state 4 (Relay state 1: 1):
Expand All @@ -1118,6 +1123,6 @@ int IntegrationPluginGenericThings::sgReadyOperatingMode(bool relay1, bool relay
* 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;
return "High";
}
}
4 changes: 2 additions & 2 deletions genericthings/integrationplugingenericthings.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class IntegrationPluginGenericThings: public IntegrationPlugin

void thermostatCheckPowerOutputState(Thing *thing);

int sgReadyOperatingMode(bool relay1, bool relay2);
QString sgReadyOperatingModeDescription(int operatingMode);
QString sgReadyOperatingMode(bool relay1, bool relay2);
QString sgReadyOperatingModeDescription(const QString &operatingModeString);
};

#endif // INTEGRATIONPLUGINGENERICTHINGS_H
50 changes: 39 additions & 11 deletions genericthings/integrationplugingenericthings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@
"name": "sgReady",
"displayName": "SG-Ready",
"createMethods": ["user"],
"interfaces": [],
"interfaces": [ "smartgridheatpump" ],
"settingsTypes": [
],
"stateTypes": [
Expand All @@ -1616,21 +1616,27 @@
"displayNameEvent": "Relay 2 changed",
"displayNameAction": "Set relay 2",
"type": "bool",
"defaultValue": false,
"defaultValue": true,
"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,
"id": "1e694bc2-12e1-4e1d-a0ec-70af2c7b16ab",
"name": "sgReadyMode",
"displayName": "Smart grid mode",
"displayNameEvent": "Smart grid mode changed",
"displayNameAction": "Set smart grid mode",
"type": "QString",
"possibleValues": [
"Off",
"Low",
"Standard",
"High"
],
"defaultValue": "Standard",
"writable": true,
"defaultValue": 2
"cached": true,
"suggestLogging": true
},
{
"id": "b421d098-f6e9-40e2-b536-58acdb3a49fe",
Expand Down Expand Up @@ -1815,6 +1821,28 @@
"defaultValue": 100
}
]
},
{
"id": "9fdb33bb-8e38-4108-8234-3b1d07bbc801",
"name": "simpleHeatPump",
"displayName": "Generic simple heat pump",
"createMethods": ["user"],
"interfaces": ["simpleheatpump"],
"stateTypes": [
{
"id": "ac2ac0f9-058c-4586-8871-2d9dbc6e1758",
"name": "boost",
"displayName": "Boost production enabled",
"displayNameEvent": "Boost production changed",
"displayNameAction": "Boost production",
"type": "bool",
"writable": true,
"defaultValue": false,
"cached": true,
"ioType": "digitalInput",
"suggestLogging": true
}
]
}
]
}
Expand Down

0 comments on commit 15f35b7

Please sign in to comment.