added "availability" section in HA Discovery

This will allow to not remove discovery topics during each ems-esp restart (MQTT init), so it can solve issue #910.

After applying this fix (and removing from the code commands that delete discovery topics) HA no longer reports errors/warnings in the log. I'm testing if for over a week.
Now it is enough to delete discovery topics only when it is really needed (e.g. the entity has been removed by customization, discovery prefix has been changed or the HA option has been disabled in the configuration).
This commit is contained in:
pswid
2023-02-22 13:16:05 +01:00
parent ff1cf12e0c
commit 971df73f13
6 changed files with 109 additions and 37 deletions

View File

@@ -240,6 +240,9 @@ class Mqtt {
static std::string tag_to_topic(uint8_t device_type, uint8_t tag);
static void
add_avty_to_doc(const char * state_t, const JsonObject & doc, const char * cond1 = nullptr, const char * cond2 = nullptr, const char * negcond = nullptr);
struct QueuedMqttMessage {
const uint32_t id_;
const std::shared_ptr<const MqttMessage> content_;