replace BatteryStats::isValid() method
in the respective context, the DPL only needs to be sure that the SoC value is not outdated. it should not even care about other values reported by the battery interface. hence, the isValid() method shall be concerned with the SoC value timestamp only. the method is renamed for clarity.
This commit is contained in:
parent
3595725f8a
commit
7c069b1cc4
@ -32,7 +32,7 @@ class BatteryStats {
|
|||||||
// if they did not change. used to calculate Home Assistent expiration.
|
// if they did not change. used to calculate Home Assistent expiration.
|
||||||
virtual uint32_t getMqttFullPublishIntervalMs() const;
|
virtual uint32_t getMqttFullPublishIntervalMs() const;
|
||||||
|
|
||||||
bool isValid() const { return _lastUpdateSoC > 0 && _lastUpdate > 0; }
|
bool isSoCValid() const { return _lastUpdateSoC > 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mqttPublish() const;
|
virtual void mqttPublish() const;
|
||||||
|
|||||||
@ -610,12 +610,13 @@ bool PowerLimiterClass::testThreshold(float socThreshold, float voltThreshold,
|
|||||||
CONFIG_T& config = Configuration.get();
|
CONFIG_T& config = Configuration.get();
|
||||||
|
|
||||||
// prefer SoC provided through battery interface, unless disabled by user
|
// prefer SoC provided through battery interface, unless disabled by user
|
||||||
|
auto stats = Battery.getStats();
|
||||||
if (!config.PowerLimiter.IgnoreSoc
|
if (!config.PowerLimiter.IgnoreSoc
|
||||||
&& config.Battery.Enabled
|
&& config.Battery.Enabled
|
||||||
&& socThreshold > 0.0
|
&& socThreshold > 0.0
|
||||||
&& Battery.getStats()->isValid()
|
&& stats->isSoCValid()
|
||||||
&& Battery.getStats()->getSoCAgeSeconds() < 60) {
|
&& stats->getSoCAgeSeconds() < 60) {
|
||||||
return compare(Battery.getStats()->getSoC(), socThreshold);
|
return compare(stats->getSoC(), socThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use voltage threshold as fallback
|
// use voltage threshold as fallback
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user