Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add VE.Direct "RELAY" to live view, MQTT, and HASS
Browse files Browse the repository at this point in the history
SW-Niko committed Nov 7, 2024
1 parent 8a2192e commit dfb9edd
Showing 8 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/VeDirectFrameHandler/VeDirectData.h
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ struct veMpptStruct : veStruct {
std::pair<uint32_t, bool> loadOutputState_LOAD; // physical load output or virtual load output state (on if battery voltage
// reaches upper limit, off if battery reaches lower limit)
std::pair<uint32_t, uint32_t> loadCurrent_IL_mA; // Load current in mA (Available only for models with a physical load output)
std::pair<uint32_t, bool> relayState_RELAY; // relay alarm state. On=true, Off=false

// these are values communicated through the HEX protocol. the pair's first
// value is the timestamp the respective info was last received. if it is
6 changes: 6 additions & 0 deletions lib/VeDirectFrameHandler/VeDirectMpptController.cpp
Original file line number Diff line number Diff line change
@@ -31,6 +31,11 @@ bool VeDirectMpptController::processTextDataDerived(std::string const& name, std
_tmpFrame.loadOutputState_LOAD.first = millis();
return true;
}
if (name == "RELAY") {
_tmpFrame.relayState_RELAY.second = (value == "ON");
_tmpFrame.relayState_RELAY.first = millis();
return true;
}
if (name == "CS") {
_tmpFrame.currentState_CS = atoi(value.c_str());
return true;
@@ -130,6 +135,7 @@ void VeDirectMpptController::loop()
// Check if optional TEXT-Data is outdated
resetTimestamp(_tmpFrame.loadOutputState_LOAD);
resetTimestamp(_tmpFrame.loadCurrent_IL_mA);
resetTimestamp(_tmpFrame.relayState_RELAY);

// Third we check if HEX-Data is outdated
if (!isHexCommandPossible()) { return; }
1 change: 1 addition & 0 deletions src/MqttHandleVedirect.cpp
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ void MqttHandleVedirectClass::publish_mppt_data(const VeDirectMpptController::da
MqttSettings.publish(topic + t, String(val)); \
}

PUBLISH_OPT(relayState_RELAY, "RELAY", currentData.relayState_RELAY.second ? "ON" : "OFF");
PUBLISH_OPT(loadOutputState_LOAD, "LOAD", currentData.loadOutputState_LOAD.second ? "ON" : "OFF");
PUBLISH_OPT(loadCurrent_IL_mA, "IL", currentData.loadCurrent_IL_mA.second / 1000.0);
PUBLISH_OPT(NetworkTotalDcInputPowerMilliWatts, "NetworkTotalDcInputPower", currentData.NetworkTotalDcInputPowerMilliWatts.second / 1000.0);
3 changes: 3 additions & 0 deletions src/MqttHandleVedirectHass.cpp
Original file line number Diff line number Diff line change
@@ -88,6 +88,9 @@ void MqttHandleVedirectHassClass::publishConfig()
publishSensor("Panel maximum power yesterday", NULL, "H23", "power", "measurement", "W", *optMpptData);

// optional info, provided only if the charge controller delivers the information
if (optMpptData->relayState_RELAY.first != 0) {
publishBinarySensor("MPPT error relay state", "mdi:export", "RELAY", "ON", "OFF", *optMpptData);
}
if (optMpptData->loadOutputState_LOAD.first != 0) {
publishBinarySensor("MPPT load output state", "mdi:export", "LOAD", "ON", "OFF", *optMpptData);
}
3 changes: 3 additions & 0 deletions src/WebApi_ws_vedirect_live.cpp
Original file line number Diff line number Diff line change
@@ -181,6 +181,9 @@ void WebApiWsVedirectLiveClass::populateJson(const JsonObject &root, const VeDir
device["CS"] = mpptData.getCsAsString();
device["MPPT"] = mpptData.getMpptAsString();
device["OR"] = mpptData.getOrAsString();
if (mpptData.relayState_RELAY.first > 0) {
device["RELAY"] = mpptData.relayState_RELAY.second ? "ON" : "OFF";
}
device["ERR"] = mpptData.getErrAsString();
device["HSDS"]["v"] = mpptData.daySequenceNr_HSDS;
device["HSDS"]["u"] = "d";
1 change: 1 addition & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
@@ -180,6 +180,7 @@
"CS": "Betriebszustand",
"MPPT": "Betriebszustand des Trackers",
"OR": "Grund für das Ausschalten",
"RELAY": "Status Fehlerrelais",
"ERR": "Fehlerbeschreibung",
"HSDS": "Anzahl der Tage (0..364)",
"MpptTemperature": "Ladereglertemperatur"
1 change: 1 addition & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
@@ -180,6 +180,7 @@
"CS": "State of operation",
"MPPT": "Tracker operation mode",
"OR": "Off reason",
"RELAY": "Error relay state",
"ERR": "Error code",
"HSDS": "Day sequence number (0..364)",
"MpptTemperature": "Charge controller temperature"
1 change: 1 addition & 0 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
@@ -180,6 +180,7 @@
"CS": "State of operation",
"MPPT": "Tracker operation mode",
"OR": "Off reason",
"RELAY": "Error relay state",
"ERR": "Error code",
"HSDS": "Day sequence number (0..364)",
"MpptTemperature": "Charge controller temperature"

0 comments on commit dfb9edd

Please sign in to comment.