dont queue publish on change if not connected, keep flag

This commit is contained in:
MichaelDvP
2023-09-18 16:24:24 +02:00
parent a6b0c74f5f
commit 42a4c792ad
3 changed files with 16 additions and 5 deletions

View File

@@ -927,9 +927,12 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (telegram->type_id == publish_id_) {
publish_id_ = 0;
}
emsdevice->has_update(false); // reset flag
if (!Mqtt::publish_single()) {
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
// dont publish if not connected and don't reset flag, so publish is done after reconnect
if (Mqtt::connected()) {
emsdevice->has_update(false); // reset flag
if (!Mqtt::publish_single()) {
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
}
}
}
}