Show battery temperature when sensor is present (#511)

This commit is contained in:
Philipp Sandhaus 2023-10-23 13:22:10 +02:00 committed by GitHub
parent c5427dedce
commit 8ba9048f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View File

@ -111,6 +111,7 @@ class VictronSmartShuntStats : public BatteryStats {
float _voltage;
float _current;
float _temperature;
bool _tempPresent;
uint8_t _chargeCycles;
uint32_t _timeToGo;
float _chargedEnergy;

View File

@ -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);

View File

@ -11,6 +11,7 @@ public:
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

View File

@ -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);