JK BMS: fix SoC last update timestamp (#439)
for the MQTT integration, JkBms::DataPointContainer::updateFrom() was changed such that the data points timestamp reflects the last change of the data point value. that timestamp was used to set the SoC last update timestamp. however, that timestampt must reflect the last time the SoC was successfully received from the JK BMS so we could make sure the value was up to date.
This commit is contained in:
parent
954a98dbc8
commit
b501d25ab6
@ -180,12 +180,10 @@ void JkBmsBatteryStats::mqttPublish() const
|
||||
|
||||
void JkBmsBatteryStats::updateFrom(JkBms::DataPointContainer const& dp)
|
||||
{
|
||||
_dataPoints.updateFrom(dp);
|
||||
|
||||
using Label = JkBms::DataPointLabel;
|
||||
|
||||
_manufacturer = "JKBMS";
|
||||
auto oProductId = _dataPoints.get<Label::ProductId>();
|
||||
auto oProductId = dp.get<Label::ProductId>();
|
||||
if (oProductId.has_value()) {
|
||||
_manufacturer = oProductId->c_str();
|
||||
auto pos = oProductId->rfind("JK");
|
||||
@ -194,12 +192,14 @@ void JkBmsBatteryStats::updateFrom(JkBms::DataPointContainer const& dp)
|
||||
}
|
||||
}
|
||||
|
||||
auto oSoCValue = _dataPoints.get<Label::BatterySoCPercent>();
|
||||
auto oSoCValue = dp.get<Label::BatterySoCPercent>();
|
||||
if (oSoCValue.has_value()) {
|
||||
_SoC = *oSoCValue;
|
||||
auto oSoCDataPoint = _dataPoints.getDataPointFor<Label::BatterySoCPercent>();
|
||||
auto oSoCDataPoint = dp.getDataPointFor<Label::BatterySoCPercent>();
|
||||
_lastUpdateSoC = oSoCDataPoint->getTimestamp();
|
||||
}
|
||||
|
||||
_dataPoints.updateFrom(dp);
|
||||
|
||||
_lastUpdate = millis();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user