From 7e1df2a3e15841b0289d3070605bf563f3c3a05e Mon Sep 17 00:00:00 2001 From: Boernsman Date: Tue, 19 Jan 2021 09:44:42 +0100 Subject: [PATCH] battery critical only when not charging --- fronius/froniusstorage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fronius/froniusstorage.cpp b/fronius/froniusstorage.cpp index 762127ba..49492c68 100644 --- a/fronius/froniusstorage.cpp +++ b/fronius/froniusstorage.cpp @@ -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"))