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.
This commit is contained in:
Bernhard Kirchen 2024-03-13 14:09:58 +01:00
parent 784e369482
commit 56353e4f00

View File

@ -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); }