Add victron serial to mqtt topics
This commit is contained in:
parent
37d3bb0eb0
commit
82ecf6cd6d
@ -46,7 +46,8 @@ void MqttHandleVedirectHassClass::publishConfig()
|
||||
if (!MqttSettings.getConnected()) {
|
||||
return;
|
||||
}
|
||||
if (VeDirect.veMap.find("SER") == VeDirect.veMap.end()) {
|
||||
// ensure data is revieved from victron
|
||||
if (VeDirect.veMap.find("SER") == VeDirect.veMap.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,16 @@ void MqttHandleVedirectClass::loop()
|
||||
|
||||
if (!MqttSettings.getConnected() || !config.Vedirect_Enabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String serial;
|
||||
auto pos = VeDirect.veMap.find("SER");
|
||||
if (pos == VeDirect.veMap.end()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
serial = pos->second;
|
||||
}
|
||||
|
||||
if (millis() - _lastPublish > (config.Mqtt_PublishInterval * 1000)) {
|
||||
String key;
|
||||
@ -44,7 +53,7 @@ void MqttHandleVedirectClass::loop()
|
||||
|
||||
// publish only changed key, values pairs
|
||||
if (!config.Vedirect_UpdatesOnly || (bChanged && config.Vedirect_UpdatesOnly)) {
|
||||
topic = "victron/";
|
||||
topic = "victron/" + serial + "/";
|
||||
topic.concat(key);
|
||||
MqttSettings.publish(topic.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user