battery critical only when not charging

master
Boernsman 2021-01-19 09:44:42 +01:00
parent cdff51655f
commit 7e1df2a3e1
1 changed files with 5 additions and 1 deletions

View File

@ -84,7 +84,11 @@ 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());
pluginThing()->setStateValue(storageBatteryCriticalStateTypeId, storageInfoMap.value("StateOfCharge_Relative").toInt() < 5);
if ((pluginThing()->stateValue(storageChargingStateTypeId) != "charging") && (storageInfoMap.value("StateOfCharge_Relative").toInt() < 5)) {
pluginThing()->setStateValue(storageBatteryCriticalStateTypeId, true);
} else {
pluginThing()->setStateValue(storageBatteryCriticalStateTypeId, false);
}
}
if (storageInfoMap.contains("Temperature_Cell"))