MQTT Auto-Discovery remove device

Tags: #<Tag:0x00007f73aca15c30>

Hi! I am using on a raspberry pi 3 to control some sonoff devices (with espurna firmware) and it works great! Now I tried to use the MQTT Discovery function which is also supported in espurna to automatically connect Sonoff devices to Home Assistant. This also works as it should and makes live much more easy. But I can’t find a way to remove unused devices (previously discovered by HA) from Home Assistant. Is there a way to manually remove such devices?

On a ‘normal’ device the quickest way is to stop the mqtt service, stop the homeassistant service, delete the mqtt database file, restart the mqtt service, restart the homeassistant service.

I have no idea how easy that is to do with hassio.

If not, you’ll have to send a blank message on the correct topic, I believe. But that never works for me here, or at least whatever I try doesn’t work, and I think that’s what I’m doing.

1 Like

Thank you for your solution. Restarting des services is no problem :slight_smile: … but I have no idea how to delete the mqtt database manually. But uninstalling / reinstalling the Mosquitto broker solved my problem after a restart of
Thanks for your advice!


if this is about clearing retained messages, this is what i always do (have some mileage here unfortunately…)

first check for the messages to show their exact origin and syntax:

mosquitto_sub -h [ip_address] -p 1883 -u [username] -P [password] -v -d -R -t '#'

then clear these with:

mosquitto_pub -h [ip_address] -p 1883 -u [username] -P [password] -t "homeassistant/device/whatevercomesnext" -r -n



Worked like a charm, thank you.