add new Victron SmartShunt values to liveView and MQTT (HASS)

This commit is contained in:
PhilJaro 2024-03-17 18:31:11 +01:00 committed by Bernhard Kirchen
parent 45c7243937
commit 4f0385285c
6 changed files with 33 additions and 5 deletions

View File

@ -152,6 +152,9 @@ class VictronSmartShuntStats : public BatteryStats {
float _chargedEnergy;
float _dischargedEnergy;
String _modelName;
int32_t _instantaneousPower;
float _consumedAmpHours;
int32_t _lastFullCharge;
bool _alarmLowVoltage;
bool _alarmHighVoltage;

View File

@ -384,7 +384,9 @@ void VictronSmartShuntStats::updateFrom(VeDirectShuntController::veShuntStruct c
_manufacturer = "Victron " + _modelName;
_temperature = shuntData.T;
_tempPresent = shuntData.tempPresent;
_instantaneousPower = shuntData.P;
_consumedAmpHours = static_cast<float>(shuntData.CE) / 1000;
_lastFullCharge = shuntData.H9 / 60;
// shuntData.AR is a bitfield, so we need to check each bit individually
_alarmLowVoltage = shuntData.AR & 1;
_alarmHighVoltage = shuntData.AR & 2;
@ -403,6 +405,9 @@ void VictronSmartShuntStats::getLiveViewData(JsonVariant& root) const {
addLiveViewValue(root, "chargeCycles", _chargeCycles, "", 0);
addLiveViewValue(root, "chargedEnergy", _chargedEnergy, "kWh", 2);
addLiveViewValue(root, "dischargedEnergy", _dischargedEnergy, "kWh", 2);
addLiveViewValue(root, "instantaneousPower", _instantaneousPower, "W", 0);
addLiveViewValue(root, "consumedAmpHours", _consumedAmpHours, "Ah", 3);
addLiveViewValue(root, "lastFullCharge", _lastFullCharge, "min", 0);
if (_tempPresent) {
addLiveViewValue(root, "temperature", _temperature, "°C", 0);
}
@ -421,4 +426,7 @@ void VictronSmartShuntStats::mqttPublish() const {
MqttSettings.publish(F("battery/chargeCycles"), String(_chargeCycles));
MqttSettings.publish(F("battery/chargedEnergy"), String(_chargedEnergy));
MqttSettings.publish(F("battery/dischargedEnergy"), String(_dischargedEnergy));
MqttSettings.publish(F("battery/instantaneousPower"), String(_instantaneousPower));
MqttSettings.publish(F("battery/consumedAmpHours"), String(_consumedAmpHours));
MqttSettings.publish(F("battery/lastFullCharge"), String(_lastFullCharge));
}

View File

@ -111,6 +111,14 @@ void MqttHandleBatteryHassClass::loop()
case 2: // SoC from MQTT
break;
case 3: // Victron SmartShunt
publishSensor("Voltage", "mdi:battery-charging", "voltage", "voltage", "measurement", "V");
publishSensor("Current", "mdi:current-dc", "current", "current", "measurement", "A");
publishSensor("Instantaneous Power", NULL, "instantaneousPower", "power", "measurement", "W");
publishSensor("Charged Energy", NULL, "chargedEnergy", "energy", "total_increasing", "kWh");
publishSensor("Discharged Energy", NULL, "dischargedEnergy", "energy", "total_increasing", "kWh");
publishSensor("Charge Cycles", "mdi:counter", "chargeCycles");
publishSensor("Consumed Amp Hours", NULL, "consumedAmpHours", NULL, "measurement", "Ah");
publishSensor("Last Full Charge", "mdi:timelapse", "lastFullCharge", NULL, NULL, "min");
break;
}

View File

@ -901,6 +901,9 @@
"bmsInternal": "BMS intern",
"chargeCycles": "Ladezyklen",
"chargedEnergy": "Geladene Energie",
"dischargedEnergy": "Entladene Energie"
"dischargedEnergy": "Entladene Energie",
"instantaneousPower": "Aktuelle Leistung",
"consumedAmpHours": "Verbrauche Amperestunden",
"lastFullCharge": "Letztes mal Vollgeladen"
}
}

View File

@ -908,6 +908,9 @@
"bmsInternal": "BMS internal",
"chargeCycles": "Charge cycles",
"chargedEnergy": "Charged energy",
"dischargedEnergy": "Discharged energy"
"dischargedEnergy": "Discharged energy",
"instantaneousPower": "Instantaneous Power",
"consumedAmpHours": "Consumed Amp Hours",
"lastFullCharge": "Last full Charge"
}
}

View File

@ -816,7 +816,7 @@
"Close": "close",
"SetVoltageLimit": "Voltage limit:",
"SetCurrentLimit": "Current limit:",
"CurrentLimit": "Current limit:"
"CurrentLimit": "Current limit:"
},
"acchargeradmin": {
"ChargerSettings": "AC Charger Settings",
@ -899,6 +899,9 @@
"bmsInternal": "BMS internal",
"chargeCycles": "Charge cycles",
"chargedEnergy": "Charged energy",
"dischargedEnergy": "Discharged energy"
"dischargedEnergy": "Discharged energy",
"instantaneousPower": "Instantaneous Power",
"consumedAmpHours": "Consumed Amp Hours",
"lastFullCharge": "Last full Charge"
}
}