Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added "availability" section in HA Discovery #1077

Closed
wants to merge 1 commit into from
Closed

Conversation

pswid
Copy link
Contributor

@pswid pswid commented Feb 22, 2023

This will allow to not remove discovery topics during each ems-esp restart (MQTT init), so it first step to 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 will allow to not remove discovery topics during each ems-esp restart (MQTT init), so it can solve issue emsesp#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).
@proddy
Copy link
Contributor

proddy commented Feb 22, 2023

err, hang on, this could be a solution to #1067 which we've been working on

are you saying by introducing the discovery availability attribute we no longer need to clean up old HA discovery config topics when EMS-ESP starts? That's quite cool.

@proddy
Copy link
Contributor

proddy commented Feb 22, 2023

could you merge this into the tech-upgrade branch?

@proddy
Copy link
Contributor

proddy commented Feb 22, 2023

could you merge this into the tech-upgrade branch?

never mind, I've added it manually so I can test it. I'll report back here.

@proddy proddy self-requested a review February 22, 2023 16:45
proddy added a commit that referenced this pull request Feb 22, 2023
@proddy
Copy link
Contributor

proddy commented Feb 22, 2023

merged with tech-upgrade branch

@proddy proddy closed this Feb 22, 2023
@JokerGermany
Copy link

Pls be good, this would be huge for me.

@pswid
Copy link
Contributor Author

pswid commented Mar 6, 2023

err, hang on, this could be a solution to #1067 which we've been working on

are you saying by introducing the discovery availability attribute we no longer need to clean up old HA discovery config topics when EMS-ESP starts? That's quite cool.

It seems so. If no specific value exists in the topic ems-esp/xxx_data, then such an entity becomes "unavailable" in HA. This does not result errors in HA log.

Besides, all EMS-ESP entities become unavailable if topic ems-esp/status is different from online. During (re)generation of HA discovery topics, you could publish the status as, for example, starting. It will be visible in HA. Of course system_status entity would have to be changed from binary_sensor to sensor.

It is only necessary(?) to ensure that in a situation where HA discovery is generated (at the start of EMS-ESP or when the user changes format in the EMS-ESP MQTT configuration), data topics do not have value inconsistent with previous discovery definition. In such situations, it would be the best(?) to delete ems-esp/xxx_data topics, publish new (modified) HA discovery, and only then start publishing ems_esp/xxx_data again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants