diff --git a/include/VictronSmartShunt.h b/include/VictronSmartShunt.h index c532db6c2..ffb91ee5b 100644 --- a/include/VictronSmartShunt.h +++ b/include/VictronSmartShunt.h @@ -11,6 +11,7 @@ class VictronSmartShunt : public BatteryProvider { std::shared_ptr getStats() const final { return _stats; } private: + uint32_t _lastUpdate = 0; std::shared_ptr _stats = std::make_shared(); }; diff --git a/src/VictronSmartShunt.cpp b/src/VictronSmartShunt.cpp index 5524157f8..7b6da145a 100644 --- a/src/VictronSmartShunt.cpp +++ b/src/VictronSmartShunt.cpp @@ -28,5 +28,9 @@ bool VictronSmartShunt::init(bool verboseLogging) void VictronSmartShunt::loop() { VeDirectShunt.loop(); + + if (VeDirectShunt.getLastUpdate() <= _lastUpdate) { return; } + _stats->updateFrom(VeDirectShunt.veFrame); + _lastUpdate = VeDirectShunt.getLastUpdate(); }