Feature: add VE.Direct "RELAY" to live view, MQTT, and HASS
This commit is contained in:
parent
1d5816d57f
commit
4beea357e7
@ -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
|
||||
|
||||
@ -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; }
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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:electric-switch", "RELAY", "ON", "OFF", *optMpptData);
|
||||
}
|
||||
if (optMpptData->loadOutputState_LOAD.first != 0) {
|
||||
publishBinarySensor("MPPT load output state", "mdi:export", "LOAD", "ON", "OFF", *optMpptData);
|
||||
}
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -185,6 +185,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"
|
||||
|
||||
@ -185,6 +185,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"
|
||||
|
||||
@ -185,6 +185,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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user