diff --git a/include/BatteryStats.h b/include/BatteryStats.h index ebdca11fd..6dc816a8c 100644 --- a/include/BatteryStats.h +++ b/include/BatteryStats.h @@ -95,4 +95,6 @@ class JkBmsBatteryStats : public BatteryStats { private: JkBms::DataPointContainer _dataPoints; + mutable uint32_t _lastMqttPublish = 0; + mutable uint32_t _lastFullMqttPublish = 0; }; diff --git a/include/JkBmsDataPoints.h b/include/JkBmsDataPoints.h index db7cd37ab..bf3a0f9bd 100644 --- a/include/JkBmsDataPoints.h +++ b/include/JkBmsDataPoints.h @@ -185,6 +185,10 @@ class DataPoint { std::string const& getUnitText() const { return _strUnit; } uint32_t getTimestamp() const { return _timestamp; } + bool operator==(DataPoint const& other) const { + return _value == other._value; + } + private: std::string _strLabel; std::string _strValue; diff --git a/src/BatteryStats.cpp b/src/BatteryStats.cpp index 2c4997e97..fb1d2f2de 100644 --- a/src/BatteryStats.cpp +++ b/src/BatteryStats.cpp @@ -1,5 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include "BatteryStats.h" +#include "Configuration.h" #include "MqttSettings.h" #include "JkBmsDataPoints.h" @@ -145,6 +148,34 @@ void PylontechBatteryStats::mqttPublish() const void JkBmsBatteryStats::mqttPublish() const { BatteryStats::mqttPublish(); + + using Label = JkBms::DataPointLabel; + + static std::vector