Skip to content

Commit 561f4be

Browse files
swingstateschlimmchen
authored andcommitted
Feature: SmartShunt: process midpoint voltage and deviation
1 parent 63370e8 commit 561f4be

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

include/BatteryStats.h

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ class VictronSmartShuntStats : public BatteryStats {
159159
float _dischargedEnergy;
160160
String _modelName;
161161
int32_t _instantaneousPower;
162+
float _midpointVoltage;
163+
float _midpointDeviation;
162164
float _consumedAmpHours;
163165
int32_t _lastFullCharge;
164166

lib/VeDirectFrameHandler/VeDirectData.h

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct veShuntStruct : veStruct {
8282
int32_t H16; // Maximum auxiliary (battery) voltage
8383
int32_t H17; // Amount of discharged energy
8484
int32_t H18; // Amount of charged energy
85+
int32_t VM; // Mid-point voltage of the battery bank
86+
int32_t DM; // Mid-point deviation of the battery bank
8587
int8_t dcMonitorMode_MON; // DC monitor mode
8688
};
8789

lib/VeDirectFrameHandler/VeDirectShuntController.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ bool VeDirectShuntController::processTextDataDerived(std::string const& name, st
108108
_tmpFrame.H17 = atoi(value.c_str());
109109
return true;
110110
}
111+
if (name == "VM") {
112+
_tmpFrame.VM = atoi(value.c_str());
113+
return true;
114+
}
115+
if (name == "DM") {
116+
_tmpFrame.DM = atoi(value.c_str());
117+
return true;
118+
}
111119
if (name == "H18") {
112120
_tmpFrame.H18 = atoi(value.c_str());
113121
return true;

src/BatteryStats.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ void VictronSmartShuntStats::updateFrom(VeDirectShuntController::data_t const& s
391391
_manufacturer = "Victron " + _modelName;
392392
_temperature = shuntData.T;
393393
_tempPresent = shuntData.tempPresent;
394+
_midpointVoltage = static_cast<float>(shuntData.VM) / 1000;
395+
_midpointDeviation = static_cast<float>(shuntData.DM) / 10;
394396
_instantaneousPower = shuntData.P;
395397
_consumedAmpHours = static_cast<float>(shuntData.CE) / 1000;
396398
_lastFullCharge = shuntData.H9 / 60;
@@ -414,6 +416,8 @@ void VictronSmartShuntStats::getLiveViewData(JsonVariant& root) const {
414416
addLiveViewValue(root, "dischargedEnergy", _dischargedEnergy, "kWh", 2);
415417
addLiveViewValue(root, "instantaneousPower", _instantaneousPower, "W", 0);
416418
addLiveViewValue(root, "consumedAmpHours", _consumedAmpHours, "Ah", 3);
419+
addLiveViewValue(root, "midpointVoltage", _midpointVoltage, "V", 2);
420+
addLiveViewValue(root, "midpointDeviation", _midpointDeviation, "%", 1);
417421
addLiveViewValue(root, "lastFullCharge", _lastFullCharge, "min", 0);
418422
if (_tempPresent) {
419423
addLiveViewValue(root, "temperature", _temperature, "°C", 0);
@@ -436,4 +440,6 @@ void VictronSmartShuntStats::mqttPublish() const {
436440
MqttSettings.publish("battery/instantaneousPower", String(_instantaneousPower));
437441
MqttSettings.publish("battery/consumedAmpHours", String(_consumedAmpHours));
438442
MqttSettings.publish("battery/lastFullCharge", String(_lastFullCharge));
443+
MqttSettings.publish("battery/midpointVoltage", String(_midpointVoltage));
444+
MqttSettings.publish("battery/midpointDeviation", String(_midpointDeviation));
439445
}

src/MqttHandleBatteryHass.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ void MqttHandleBatteryHassClass::loop()
122122
publishSensor("Charge Cycles", "mdi:counter", "chargeCycles");
123123
publishSensor("Consumed Amp Hours", NULL, "consumedAmpHours", NULL, "measurement", "Ah");
124124
publishSensor("Last Full Charge", "mdi:timelapse", "lastFullCharge", NULL, NULL, "min");
125+
publishSensor("Midpoint Voltage", NULL, "midpointVoltage", "voltage", "measurement", "V");
126+
publishSensor("Midpoint Deviation", NULL, "midpointDeviation", "battery", "measurement", "%");
125127
break;
126128
}
127129

webapp/src/locales/de.json

+2
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,8 @@
942942
"dischargedEnergy": "Entladene Energie",
943943
"instantaneousPower": "Aktuelle Leistung",
944944
"consumedAmpHours": "Verbrauchte Amperestunden",
945+
"midpointVoltage": "Mittelpunktspannung",
946+
"midpointDeviation": "Mittelpunktsabweichung",
945947
"lastFullCharge": "Letztes mal Vollgeladen"
946948
}
947949
}

webapp/src/locales/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,8 @@
949949
"dischargedEnergy": "Discharged energy",
950950
"instantaneousPower": "Instantaneous Power",
951951
"consumedAmpHours": "Consumed Amp Hours",
952+
"midpointVoltage": "Midpoint Voltage",
953+
"midpointDeviation": "Midpoint Deviation",
952954
"lastFullCharge": "Last full Charge"
953955
}
954956
}

webapp/src/locales/fr.json

+2
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@
934934
"dischargedEnergy": "Discharged energy",
935935
"instantaneousPower": "Instantaneous Power",
936936
"consumedAmpHours": "Consumed Amp Hours",
937+
"midpointVoltage": "Midpoint Voltage",
938+
"midpointDeviation": "Midpoint Deviation",
937939
"lastFullCharge": "Last full Charge"
938940
}
939941
}

0 commit comments

Comments
 (0)