Feature: SmartShunt: process midpoint voltage and deviation

This commit is contained in:
swingstate 2023-12-19 16:38:34 +01:00 committed by Bernhard Kirchen
parent 63370e8a83
commit 561f4be6d6
8 changed files with 26 additions and 0 deletions

View File

@ -159,6 +159,8 @@ class VictronSmartShuntStats : public BatteryStats {
float _dischargedEnergy; float _dischargedEnergy;
String _modelName; String _modelName;
int32_t _instantaneousPower; int32_t _instantaneousPower;
float _midpointVoltage;
float _midpointDeviation;
float _consumedAmpHours; float _consumedAmpHours;
int32_t _lastFullCharge; int32_t _lastFullCharge;

View File

@ -82,6 +82,8 @@ struct veShuntStruct : veStruct {
int32_t H16; // Maximum auxiliary (battery) voltage int32_t H16; // Maximum auxiliary (battery) voltage
int32_t H17; // Amount of discharged energy int32_t H17; // Amount of discharged energy
int32_t H18; // Amount of charged energy int32_t H18; // Amount of charged energy
int32_t VM; // Mid-point voltage of the battery bank
int32_t DM; // Mid-point deviation of the battery bank
int8_t dcMonitorMode_MON; // DC monitor mode int8_t dcMonitorMode_MON; // DC monitor mode
}; };

View File

@ -108,6 +108,14 @@ bool VeDirectShuntController::processTextDataDerived(std::string const& name, st
_tmpFrame.H17 = atoi(value.c_str()); _tmpFrame.H17 = atoi(value.c_str());
return true; return true;
} }
if (name == "VM") {
_tmpFrame.VM = atoi(value.c_str());
return true;
}
if (name == "DM") {
_tmpFrame.DM = atoi(value.c_str());
return true;
}
if (name == "H18") { if (name == "H18") {
_tmpFrame.H18 = atoi(value.c_str()); _tmpFrame.H18 = atoi(value.c_str());
return true; return true;

View File

@ -391,6 +391,8 @@ void VictronSmartShuntStats::updateFrom(VeDirectShuntController::data_t const& s
_manufacturer = "Victron " + _modelName; _manufacturer = "Victron " + _modelName;
_temperature = shuntData.T; _temperature = shuntData.T;
_tempPresent = shuntData.tempPresent; _tempPresent = shuntData.tempPresent;
_midpointVoltage = static_cast<float>(shuntData.VM) / 1000;
_midpointDeviation = static_cast<float>(shuntData.DM) / 10;
_instantaneousPower = shuntData.P; _instantaneousPower = shuntData.P;
_consumedAmpHours = static_cast<float>(shuntData.CE) / 1000; _consumedAmpHours = static_cast<float>(shuntData.CE) / 1000;
_lastFullCharge = shuntData.H9 / 60; _lastFullCharge = shuntData.H9 / 60;
@ -414,6 +416,8 @@ void VictronSmartShuntStats::getLiveViewData(JsonVariant& root) const {
addLiveViewValue(root, "dischargedEnergy", _dischargedEnergy, "kWh", 2); addLiveViewValue(root, "dischargedEnergy", _dischargedEnergy, "kWh", 2);
addLiveViewValue(root, "instantaneousPower", _instantaneousPower, "W", 0); addLiveViewValue(root, "instantaneousPower", _instantaneousPower, "W", 0);
addLiveViewValue(root, "consumedAmpHours", _consumedAmpHours, "Ah", 3); addLiveViewValue(root, "consumedAmpHours", _consumedAmpHours, "Ah", 3);
addLiveViewValue(root, "midpointVoltage", _midpointVoltage, "V", 2);
addLiveViewValue(root, "midpointDeviation", _midpointDeviation, "%", 1);
addLiveViewValue(root, "lastFullCharge", _lastFullCharge, "min", 0); addLiveViewValue(root, "lastFullCharge", _lastFullCharge, "min", 0);
if (_tempPresent) { if (_tempPresent) {
addLiveViewValue(root, "temperature", _temperature, "°C", 0); addLiveViewValue(root, "temperature", _temperature, "°C", 0);
@ -436,4 +440,6 @@ void VictronSmartShuntStats::mqttPublish() const {
MqttSettings.publish("battery/instantaneousPower", String(_instantaneousPower)); MqttSettings.publish("battery/instantaneousPower", String(_instantaneousPower));
MqttSettings.publish("battery/consumedAmpHours", String(_consumedAmpHours)); MqttSettings.publish("battery/consumedAmpHours", String(_consumedAmpHours));
MqttSettings.publish("battery/lastFullCharge", String(_lastFullCharge)); MqttSettings.publish("battery/lastFullCharge", String(_lastFullCharge));
MqttSettings.publish("battery/midpointVoltage", String(_midpointVoltage));
MqttSettings.publish("battery/midpointDeviation", String(_midpointDeviation));
} }

View File

@ -122,6 +122,8 @@ void MqttHandleBatteryHassClass::loop()
publishSensor("Charge Cycles", "mdi:counter", "chargeCycles"); publishSensor("Charge Cycles", "mdi:counter", "chargeCycles");
publishSensor("Consumed Amp Hours", NULL, "consumedAmpHours", NULL, "measurement", "Ah"); publishSensor("Consumed Amp Hours", NULL, "consumedAmpHours", NULL, "measurement", "Ah");
publishSensor("Last Full Charge", "mdi:timelapse", "lastFullCharge", NULL, NULL, "min"); publishSensor("Last Full Charge", "mdi:timelapse", "lastFullCharge", NULL, NULL, "min");
publishSensor("Midpoint Voltage", NULL, "midpointVoltage", "voltage", "measurement", "V");
publishSensor("Midpoint Deviation", NULL, "midpointDeviation", "battery", "measurement", "%");
break; break;
} }

View File

@ -942,6 +942,8 @@
"dischargedEnergy": "Entladene Energie", "dischargedEnergy": "Entladene Energie",
"instantaneousPower": "Aktuelle Leistung", "instantaneousPower": "Aktuelle Leistung",
"consumedAmpHours": "Verbrauchte Amperestunden", "consumedAmpHours": "Verbrauchte Amperestunden",
"midpointVoltage": "Mittelpunktspannung",
"midpointDeviation": "Mittelpunktsabweichung",
"lastFullCharge": "Letztes mal Vollgeladen" "lastFullCharge": "Letztes mal Vollgeladen"
} }
} }

View File

@ -949,6 +949,8 @@
"dischargedEnergy": "Discharged energy", "dischargedEnergy": "Discharged energy",
"instantaneousPower": "Instantaneous Power", "instantaneousPower": "Instantaneous Power",
"consumedAmpHours": "Consumed Amp Hours", "consumedAmpHours": "Consumed Amp Hours",
"midpointVoltage": "Midpoint Voltage",
"midpointDeviation": "Midpoint Deviation",
"lastFullCharge": "Last full Charge" "lastFullCharge": "Last full Charge"
} }
} }

View File

@ -934,6 +934,8 @@
"dischargedEnergy": "Discharged energy", "dischargedEnergy": "Discharged energy",
"instantaneousPower": "Instantaneous Power", "instantaneousPower": "Instantaneous Power",
"consumedAmpHours": "Consumed Amp Hours", "consumedAmpHours": "Consumed Amp Hours",
"midpointVoltage": "Midpoint Voltage",
"midpointDeviation": "Midpoint Deviation",
"lastFullCharge": "Last full Charge" "lastFullCharge": "Last full Charge"
} }
} }