Remove autodiscovered MQTT Device - Hassio

Hi all,
I am running Home Assistant on a Raspberry Pi 3, Hassio.
I have the addon Zigbee2mqtt and use the Mosquitto broker. All works perfectly fine and I have now several devices to track and control

When starting, I flashed a cc2531 to test with a router software to play around and I no longer use them due to the limited range. It does however show up on the zigbee2mqtt networkmap:


link to the zigbee2mqtt map:

Is there a way I can remove this device from wherever it is stored?
I tried to find the solution in several places, but have not succeeded (from uninstalling, rebooting and re-installing the mosquitto broker, using MQTT.fx, ).
also tried with mosquitto_pub -h 192.168.1.52 -p 1883 -u myuser -P mypassword -t "zigbee2mqtt/0x00124b00014d2777" -r -n but this doesn´t do anything.

Really have no clue anymore… My main first doubt: am I using the right topic?
thanks for any insight!

I’m pretty sure that the info for the map comes from the zigbee2mqtt database. So to get rid of that device you need to remove it from the database. To do that you have to issue a remove command in MQTT:

from that page:

zigbee2mqtt/bridge/config/remove

Allows you to remove devices from the network. Payload should be the friendly_name , e.g. 0x00158d0001b79111 . On successful remove a device_removed message is send.

1 Like

Thanks finity! you gave me the right direction!!!
I don´t know how I can have missed the most basic documentation…

I got it removed as you suggested using SSH CLI command :
mosquitto_pub -h 192.168.1.52 -u myuser -P mypassword -t zigbee2mqtt/bridge/config/remove -m 0x00124b00014d2777 and the confirmation is seen in the zigbee2mqtt log:

zigbee2mqtt:warn 2019-2-23 10:32:59 Failed to remove '0x00124b00014d2777', trying force remove...
zigbee2mqtt:info 2019-2-23 10:32:59 Successfully removed 0x00124b00014d2777
zigbee2mqtt:info 2019-2-23 10:32:59 MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"device_removed","message":"0x00124b00014d2777"}'

Always have done this, but my issue is that the devices remains in home-assistant.

Do i need to remove those retained messages from the mqtt broker myself or is this supposed/ can be to be deleted automagically by a script?

It’s really a lot more work then pairing a device.

I had the same issue today, since the topic was retained on my broker. However there’s a very useful tool called MQTT Explorer which lets you easily remove retained messages.

1 Like

Thanks for pointing out to MQTT Explorer. I will have it a spin.
It will stil be nice to have devices being “auto-deleted” like we have with mqtt “auto-discovery”. Maybe this will come in the future🤷

I’m having this issue with a sonoff tasmota device which I added by following the tasmota wiki:

# Example automations.yaml entry
- alias: "Enable MQTT discovery for all devices"
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/SetOption19"
        payload: "1"

I had to change the topic to sonoff/cmnd/SetOption19 for it to auto-discover.
However this is a bit misleading as it created a device in HA which is called switch.sonoff and if I’m understanding this correctly If I connected 5 sonoffs and left their topic default it wouldn’t be able to distinguish them so I’m not sure how much use this is? To differentiate I would have to enter a different topic for each one and then edit the configuration.yaml to have this for each? Defeats the object of auto discover but anyway I digress…

I’m trying to change the name of this sonoff away from the generic switch.sonoff to the one I have set under Client and Topic in the tasmota GUI. However it still appears as switch.sonoff in HA after deleting and removing every instance I can find. I would rename manually but it has multiple sensors and it’s not the point, why doesn’t HA pick up the new client name and topic name?? I’ve tried this to stop it from remembering this name but no luck:

-Removed MQTT from integrations.
-Stopped HASS and removed from core.restore_state. core.entity_registry and core.device_registry doesn’t feature it as it was removed from integrations already.
-Restarted Mosquitto and checked the topic wasn’t kept with MQTT explorer.