Update charging state of energystorage

master
Simon Stürz 2021-12-10 13:43:59 +01:00
parent 94dbfaa660
commit 48aeac0c19
2 changed files with 16 additions and 18 deletions

View File

@ -86,7 +86,7 @@ void FroniusStorage::updateThingInfo(const QByteArray &data)
// copy retrieved information to thing states
if (storageInfoMap.contains("StateOfCharge_Relative")) {
pluginThing()->setStateValue(storageBatteryLevelStateTypeId, storageInfoMap.value("StateOfCharge_Relative").toInt());
if (!pluginThing()->stateValue(storageChargingStateTypeId).toBool() && (storageInfoMap.value("StateOfCharge_Relative").toInt() < 5)) {
if (pluginThing()->stateValue(storageChargingStateStateTypeId).toString() == "charging" && (storageInfoMap.value("StateOfCharge_Relative").toInt() < 5)) {
pluginThing()->setStateValue(storageBatteryCriticalStateTypeId, true);
} else {
pluginThing()->setStateValue(storageBatteryCriticalStateTypeId, false);
@ -126,6 +126,11 @@ void FroniusStorage::updateActivityInfo(const QByteArray &data)
QVariantMap dataMap = jsonDoc.toVariant().toMap().value("Body").toMap().value("Data").toMap();
float charge_akku = dataMap.value("Site").toMap().value("P_Akku").toFloat();
pluginThing()->setStateValue(storageCurrentPowerStateTypeId, charge_akku);
pluginThing()->setStateValue(storageDischargingStateTypeId, charge_akku < 0);
pluginThing()->setStateValue(storageChargingStateTypeId, charge_akku > 0);
if (charge_akku < 0) {
pluginThing()->setStateValue(storageChargingStateStateTypeId, "discharging");
} else if (charge_akku > 0) {
pluginThing()->setStateValue(storageChargingStateStateTypeId, "charging");
} else {
pluginThing()->setStateValue(storageChargingStateStateTypeId, "idle");
}
}

View File

@ -384,7 +384,7 @@
"name": "storage",
"displayName": "Fronius solar storage",
"createMethods": ["auto"],
"interfaces": [ "energystorage", "connectable" ],
"interfaces": [ "energystorage"],
"paramTypes": [
{
"id": "49087f31-abf5-4bb8-946b-a3626ee80566",
@ -414,20 +414,13 @@
"cached": false
},
{
"id": "2de34a1f-de2e-43ad-8998-8a5460dff9ae",
"name": "charging",
"displayName": "Charging",
"displayNameEvent": "Charging changed",
"type": "bool",
"defaultValue": false
},
{
"id": "be90d35c-081c-485b-b4cc-8271e7da5796",
"name": "discharging",
"displayName": "Discharging",
"displayNameEvent": "Discharging changed",
"type": "bool",
"defaultValue": false
"id": "7a045257-d829-4e58-a769-047b3aeec7c5",
"name": "chargingState",
"displayName": "Charging state",
"displayNameEvent": "Charging state changed",
"type": "QString",
"possibleValues": ["idle", "charging", "discharging"],
"defaultValue": "idle"
},
{
"id": "5a89cd3f-3abf-4f51-ab2b-4039f1d211d9",