Deleting Auto discovered Sensor entity

Hi,

I have done an amount of searching, but my problem is twofold, and would appreciate some advice.

Running HASSOS on a RPI.

I have been playing around with MQTT and autodiscovery, and in the process of this, I beleive some entities were created by autodiscovery and they now no longer exist. I am now trying to get rid of them, but I cannot delete them, and I dont/cant see what integration discovered them (I deleted the mqtt integration to see if that was the case, and it is not).

Is there a way I can see/confirm how these were added, and finally get rid of them. The names of the entities are from my alarm system, which I had connected to HASS by MQTT, and also using a node red flow (was playing with both to see which would work for me), so the entities I know what physical device they are referring to, I just ant figure out how to remove them now.

I checked my configuration.yaml file also, and they are not there.

Regards,
Eamon

The easiest way is to install MQTT Explorer on a PC and connect to your broker.

Under the /homeassistant topic you will see retained discovery messages for binary_sensors, sensors, etc…

Deleting these retained discovery messages (trashcan icon to the right) will delete the entities from Home Assistant.

The other way is to send a blank retained message to the topic.

Be very careful what you delete.

Thanks, that worked a treat.

Regards
Eamon

Quick and dirty python script to ‘delete’ mqtt topics

import paho.mqtt.client as mqtt

# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))

    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe("homeassistant/#")

# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
    if 'BME' in msg.topic:
        print(msg.topic)
        #client.publish(msg.topic, payload=None, retain=True, qos=0)

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.username_pw_set('Username', password='Pass')
client.connect("mqtt.server", 1883, 60)

# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client.loop_forever()