Skip to content

Commit

Permalink
remove timestamp bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SW-Niko committed Sep 1, 2024
1 parent bbd5c26 commit e5a2312
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions include/VictronSmartBatterySense.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class VictronSmartBatterySense : public BatteryProvider {
std::shared_ptr<BatteryStats> getStats() const final { return _stats; }

private:
// static char constexpr _serialPortOwner[] = "SmartBatterySense";

uint32_t _lastUpdate = 0;
std::shared_ptr<VictronSmartBatterySenseStats> _stats =
std::make_shared<VictronSmartBatterySenseStats>();
Expand Down
3 changes: 2 additions & 1 deletion src/BatteryStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,9 @@ void VictronSmartShuntStats::mqttPublish() const {
void VictronSmartBatterySenseStats::updateFrom(uint32_t volt, int32_t temp, uint32_t timeStamp) {

// we just get battery voltage and temperature from the "Smart Battery Sense" device
BatteryStats::setVoltage(volt/ 1000.0f, timeStamp);
BatteryStats::setVoltage(volt / 1000.0f, timeStamp);
_temperature = temp / 1000.0f;
_manufacturer = "Smart Battery Sense";
}

void VictronSmartBatterySenseStats::getLiveViewData(JsonVariant& root) const {
Expand Down
5 changes: 2 additions & 3 deletions src/VictronSmartBatterySense.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include "VictronMppt.h"
#include "MessageOutput.h"
#include "VictronSmartBatterySense.h"
Expand Down Expand Up @@ -36,10 +35,10 @@ void VictronSmartBatterySense::loop()
if ((mpptData->SmartBatterySenseTemperatureMilliCelsius.first != 0) && (VictronMppt.isDataValid(idx))) {
volt = mpptData->batteryVoltage_V_mV;
temp = mpptData->SmartBatterySenseTemperatureMilliCelsius.second;
_lastUpdate = VictronMppt.getDataAgeMillis(idx) + millis();
_lastUpdate = millis() - VictronMppt.getDataAgeMillis(idx);
break;
}
}

_stats->updateFrom(volt, temp, _lastUpdate);
_stats->updateFrom(volt, temp, _lastUpdate);
}

0 comments on commit e5a2312

Please sign in to comment.