From 56353e4f004d53ea654d0430d4e447516f477378 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Wed, 13 Mar 2024 14:09:58 +0100 Subject: [PATCH] implement Battery::needsCharging() currently this is only supported by the Pylontech battery provider, as it reports a "charge battery immediately" alarm. this will also be implemented by the JK BMS provider, and possibly also by the smart shunt provider. the method will be used to determine whether or not to start charging the battery using the (Huawei) charger. --- include/BatteryStats.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/BatteryStats.h b/include/BatteryStats.h index c11f45f95..2a1ee4a63 100644 --- a/include/BatteryStats.h +++ b/include/BatteryStats.h @@ -35,6 +35,10 @@ class BatteryStats { bool isSoCValid() const { return _lastUpdateSoC > 0; } bool isVoltageValid() const { return _lastUpdateVoltage > 0; } + // returns true if the battery reached a critically low voltage/SoC, + // such that it is in need of charging to prevent degredation. + virtual bool needsCharging() const { return false; } + protected: virtual void mqttPublish() const; @@ -67,6 +71,7 @@ class PylontechBatteryStats : public BatteryStats { public: void getLiveViewData(JsonVariant& root) const final; void mqttPublish() const final; + bool needsCharging() const final { return _chargeImmediately; } private: void setManufacturer(String&& m) { _manufacturer = std::move(m); }