mqqt hass discovery complete
This commit is contained in:
parent
997023e52f
commit
ed12f814dd
@ -51,11 +51,29 @@ void MqttHandleVedirectHassClass::publishConfig()
|
||||
return;
|
||||
}
|
||||
|
||||
publishBinarySensor("Load output state", "LOAD", "ON", "OFF");
|
||||
// device info
|
||||
publishBinarySensor("MPPT load output state", "LOAD", "ON", "OFF");
|
||||
publishSensor("MPPT serial number", "SER");
|
||||
publishSensor("MPPT firmware number", "FW");
|
||||
publishSensor("MPPT state of operation", "CS");
|
||||
publishSensor("MPPT error code", "ERR");
|
||||
publishSensor("MPPT off reason", "OR");
|
||||
publishSensor("MPPT tracker operation mode", "MPPT");
|
||||
publishSensor("MPPT Day sequence number (0...364)", "HSDS", "duration", "total_increasing", "d");
|
||||
|
||||
// battery info
|
||||
publishSensor("Battery voltage", "V", "voltage", "measurement", "mV");
|
||||
publishSensor("Battery current", "I", "current", "measurement", "mA");
|
||||
publishSensor("Battery voltage", "V", "voltage", "measurement", "V");
|
||||
publishSensor("Battery current", "I", "current", "measurement", "A");
|
||||
|
||||
// panel info
|
||||
publishSensor("Panel voltage", "VPV", "voltage", "measurement", "V");
|
||||
publishSensor("Panel power", "PPV", "power", "measurement", "W");
|
||||
publishSensor("Panel power", "PPV", "power", "measurement", "W");
|
||||
publishSensor("Panel yield total", "H19", "energy", "total_increasing", "kWh");
|
||||
publishSensor("Panel yield today", "H20", "energy", "total_increasing", "kWh");
|
||||
publishSensor("Panel maximum power today", "H21", "power", "measurement", "W");
|
||||
publishSensor("Panel yield yesterday", "H22", "energy", "measurement", "kWh");
|
||||
publishSensor("Panel maximum power yesterday", "H23", "power", "measurement", "W");
|
||||
|
||||
yield();
|
||||
}
|
||||
|
||||
@ -54,7 +54,32 @@ void MqttHandleVedirectClass::loop()
|
||||
// publish only changed key, values pairs
|
||||
if (!config.Vedirect_UpdatesOnly || (bChanged && config.Vedirect_UpdatesOnly)) {
|
||||
topic = "victron/" + serial + "/";
|
||||
topic.concat(key);
|
||||
topic.concat(key);
|
||||
if (key.equals("PID")) {
|
||||
value = VeDirect.getPidAsString(value.c_str());
|
||||
}
|
||||
else if (key.equals("CS")) {
|
||||
value = VeDirect.getCsAsString(value.c_str());
|
||||
}
|
||||
else if (key.equals("ERR")) {
|
||||
value = VeDirect.getErrAsString(value.c_str());
|
||||
}
|
||||
else if (key.equals("OR")) {
|
||||
value = VeDirect.getOrAsString(value.c_str());
|
||||
}
|
||||
else if (key.equals("MPPT")) {
|
||||
value = VeDirect.getMpptAsString(value.c_str());
|
||||
}
|
||||
else if (key.equals("V") ||
|
||||
key.equals("I") ||
|
||||
key.equals("VPV")) {
|
||||
value = round(value.toDouble() / 10.0) / 100.0;
|
||||
}
|
||||
else if (key.equals("H19") ||
|
||||
key.equals("H20") ||
|
||||
key.equals("H22")) {
|
||||
value = value.toDouble() / 100.0;
|
||||
}
|
||||
MqttSettings.publish(topic.c_str(), value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user