diff --git a/include/BatteryStats.h b/include/BatteryStats.h index 14672aeaa..bef2e7d67 100644 --- a/include/BatteryStats.h +++ b/include/BatteryStats.h @@ -111,6 +111,7 @@ class VictronSmartShuntStats : public BatteryStats { float _voltage; float _current; float _temperature; + bool _tempPresent; uint8_t _chargeCycles; uint32_t _timeToGo; float _chargedEnergy; diff --git a/lib/VeDirectFrameHandler/VeDirectShuntController.cpp b/lib/VeDirectFrameHandler/VeDirectShuntController.cpp index 7a1fa59a5..27357a1d1 100644 --- a/lib/VeDirectFrameHandler/VeDirectShuntController.cpp +++ b/lib/VeDirectFrameHandler/VeDirectShuntController.cpp @@ -23,6 +23,7 @@ void VeDirectShuntController::textRxEvent(char* name, char* value) if (strcmp(name, "T") == 0) { _tmpFrame.T = atoi(value); + _tmpFrame.tempPresent = true; } else if (strcmp(name, "P") == 0) { _tmpFrame.P = atoi(value); diff --git a/lib/VeDirectFrameHandler/VeDirectShuntController.h b/lib/VeDirectFrameHandler/VeDirectShuntController.h index 115af35b6..9e1a5f131 100644 --- a/lib/VeDirectFrameHandler/VeDirectShuntController.h +++ b/lib/VeDirectFrameHandler/VeDirectShuntController.h @@ -11,6 +11,7 @@ class VeDirectShuntController : public VeDirectFrameHandler { struct veShuntStruct : veStruct { int32_t T; // Battery temperature + bool tempPresent = false; // Battery temperature sensor is attached to the shunt int32_t P; // Instantaneous power int32_t CE; // Consumed Amp Hours int32_t SOC; // State-of-charge diff --git a/src/BatteryStats.cpp b/src/BatteryStats.cpp index b1f616b1b..912deeab3 100644 --- a/src/BatteryStats.cpp +++ b/src/BatteryStats.cpp @@ -214,6 +214,8 @@ void VictronSmartShuntStats::updateFrom(VeDirectShuntController::veShuntStruct c _chargedEnergy = shuntData.H18 / 100; _dischargedEnergy = shuntData.H17 / 100; _manufacturer = "Victron " + _modelName; + _temperature = shuntData.T; + _tempPresent = shuntData.tempPresent; // shuntData.AR is a bitfield, so we need to check each bit individually _alarmLowVoltage = shuntData.AR & 1; @@ -235,6 +237,9 @@ void VictronSmartShuntStats::getLiveViewData(JsonVariant& root) const { addLiveViewValue(root, "chargeCycles", _chargeCycles, "", 0); addLiveViewValue(root, "chargedEnergy", _chargedEnergy, "KWh", 1); addLiveViewValue(root, "dischargedEnergy", _dischargedEnergy, "KWh", 1); + if (_tempPresent) { + addLiveViewValue(root, "temperature", _temperature, "°C", 0); + } addLiveViewAlarm(root, "lowVoltage", _alarmLowVoltage); addLiveViewAlarm(root, "highVoltage", _alarmHighVoltage);