Skip to content

Commit

Permalink
implement Battery::needsCharging()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schlimmchen committed Mar 13, 2024
1 parent 784e369 commit 56353e4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/BatteryStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

0 comments on commit 56353e4

Please sign in to comment.