More Home Assistant discovery problems - still a mystery to me

Is it possible to improve this behaviour? I’ve had to reboot my server a number of times again today and I’ve lost all the retained messages again.

I’ve now added persistence to my mqtt broker (of course I forgot to do this) before) so it should not happen again - but it’s a real pain to have to set everything up again, especially in the absence of deny lists for 433 devices. Each time I turn on auto discovery I end up with hundreds of devices I have to delete from Home Assistant.

I have several other devices that have auto discovery (eg AI on the edge) and they don’t seem to have any problem when I restart everything.

Not sure if there is a way to get them back.

By the way why using mosquitto not managed by HA ?

If you need to stick with a separate mosquitto container, verify that persistence works by checking that the retained topics stay recorded upon mosquitto container restart.
If yes try to restart HA also.
If you keep the data you are good to go.

The difficulty here is the link between the unique identification of the sensor and the Home Assistant MQTT discovery convention; even if we publish a unique ID for each entity, HA seems to have some mystery on how it handles the link to its database.

Thanks. I had mosquitto running with a load of Tasmota energy sensors and a Grafana dashboard long before I got into Home Assistant - so it made sense to keep it as it was.

I was wrong about the AI on the edge device - its data also stopped showing up in Home Assistant. But it has a UI feature:
which works.

I don’t get problems like this wilth all the Tasmota devices I have - but, I realised that HA has a separate dedicated integration for Tasmota and that probably helps.

I think for now I’m going to have to manually create a YAML file with the few sensors I am interested in. It’s just too painful to recreate them with auto discover.

ps, even if I use MQTT persistence on shutdown/reboot I realised that won’t help if there’s a system crash/power issue. (Everything is on UPS but you never know)

At least Mosquitto has the option to saved retained/persistent messages to disk. As this is done in the interval set by autosave_interval. So unless a cash happens exactly in between a new discovery and the autosave_interval all the discovery messages will be saved to disk and leaded again at startup.

So a very unlikely case and you should not be worried about loosing any messages once you have all the persistence, persistence_file, persistence_location and autosave_interval set correctly. Just make sure autosave_interval does not have a value of 0.

I have configured autosave_interval etc. in mosquitto but still having problems.

As all three of my gateways again were greyed out in Home Assistant I did a mosquitto_pub -t “home/OpenMQTTGateway/commands/MQTTtoSYS/config” -m ‘{“disc”:true}’ to each gateway and re-enabled auto discovery again.

All of my sensors continued to show as unavailable,
I had to go away for a few days, came back and all of the gateways are again showing as unavailable.
I really don’t understand what is happening.

part of this mystery solved - “someone” unplugged 'em all, that at least explains why the gateways went unavailable in HA :smiley: