Open Vertikar opened 1 week ago
Thinking a bit further, I think to fix this for now, just use retain on the config messages, and look into the other stuff later, as it would require a bit more work.
Looks like the retain option is set to false here: https://github.com/aaronwmorris/indi-allsky/blob/0a883ad3efec6d6be0fb29d26fd72b24358a40f3/misc/home_assistant_auto_discovery.py#L423 and here https://github.com/aaronwmorris/indi-allsky/blob/0a883ad3efec6d6be0fb29d26fd72b24358a40f3/misc/home_assistant_auto_discovery.py#L436
Just tested this and confirmed my above thoughts.
I took this in a slightly more nuanced direction. There was a reason I set the retain flag to False, but I do not remember the exact reason. There has been a lot of discussion around retaining vs not-retaining discovery topics.
Edit... looks like retain should be True according to https://github.com/home-assistant/home-assistant.io/pull/21540
Merged #1356 to make the default to retain.
I ran into this issue the other day, I think after either a Home Assistant or indi-allsky restart or having the service stopped for a while, whereby all the sensors in Home Assistant were showing unavailable, even though the topics were still being published in MQTT
How to reproduce:
Restart home assistant, sensors will all become unavailable.
It seems the fix for this is to either trigger the discovery script to run when indi-allsky comes online, and it detects a Birth or Will message from home assistant - see here
Or use retained config messages - https://www.home-assistant.io/integrations/mqtt/#using-retained-config-messages
This then leads into adding a device container to hold all the sensors within home assistant, and setting availability on the device, but that can wait for a future enhancement