How to rediscover deleted MQTT devices

Hello team,

I am an absolute newbie to Home Assistant and started just last week.
I have been able to do a discovery of most of my MQTT devices after which I changed a number of sensors hanging on those MQTT devices. Therefore I deleted all my MQTT devices from HA in the assumption it would be a piece of cake to do a rediscovery of all the devices. But as I am new to HA I have not been able to figure out how start such a process.

Also I had expected that all the configuration file would be written out in some configuration format (?configuration.yaml?) but that seems not the case, so for an experienced UNIX guy I have no clue where to look, but there must be someone that can help.

My environment is per below.

Thanks in advance, Yann

Home Assistant 0.112.4

Path to configuration.yaml: /config
|arch|armv7l|
|chassis|embedded|
|dev|false|
|docker|true|
|docker_version|19.03.8|
|hassio|true|
|host_os|HassOS 4.11|
|installation_type|Home Assistant OS|
|os_name|Linux|
|os_version|4.19.127-v7|
|python_version|3.7.7|
|supervisor|228|
|timezone|Europe/Amsterdam|
|version|0.112.4|
|virtualenv|false|

Lovelace

|dashboards|2|
|mode|storage|
|resources|0|
|views|5|

Sometimes discovery depends on the brand of devices you use. Which one do you use?
ESP, Tasmota, …?
In hass.io version > 0.111 you will see your devices in the UI on /config/integrations --> xx devices.
Your discoverd devices and the entities are stored in home-assistant_v2.db - database or any other database if you choosed another one.

I am using tasmota for my MQTT devices.

When surfing to http://mycastle:8123/config/devices/dashboard I can see devices that are there but no new ones popping up.

And I indeed see the DB file http://mycastle:8123/config/home-assistant_v2.db , but then the question would be how to access this file? I guess ordinary vi will not do the job :slight_smile:

You can’t access a database file with vi… better your shouldn’t.
For tasmota and hass you need to have a look in the tasmota documentation.

In tasmota you need to

SetOption19 Home Assistant automatic discovery.
WARNING On version 6.4.1.x enabling may cause a watchdog reset if used on a device with a configured sensor
0 = disabled (default)
1 = enabled and also sets SetOption59 1
If you enable and then disable SetOption19 , doing so does not set SetOption59 = 0 and does not revert to default %prefix%/%topic%/ FullTopic

2 Likes

This is incorrect. The db stores the states of your entities and events that happened and it only stores this data according to your configuration of the history integration. The information about your devices like id, manufacturer etc. are stored in the files in the .storage directory. One should not mess with these files only if you know what you are doing.

Things that you configure through the UI will not be written to configuration.yaml instead it will be stored in .json format in the files in the .storage directory.

In JSON? Does it mean there is now a preference of JSON over YAML ?

Yes in JSON. No there’s no preference for YAML over JSON in general. Maybe this topic will shed some light to the dark.

Basically the configuration for integrations will slowly move from YAML to UI only, there are already lots of integrations, which can only be configured through the UI. This condig will then be written as JSON to the storage files and they are not meant to be edited. Scripts, automations etc. will continue to work through YAML and automations that you create through the UI will be stored in YAML format (with some non-sense sorting and comment removing magic stuff) in automations.yaml.

Go to the tasmota console of your deleted devices, and issue

setoption19 0
setoption19 1
3 Likes

@Burningstone
sorry and thanks for the clarification … I forgot this detail!

Entity not available: switch.birdie
Entity not available: sensor.ruth_load_m1
Entity not available: sensor.ruth_load_m5
Entity not available: sensor.ruth_load_m15

And why do the above error messages not go away that appear in some card

I don’t exactly understand your comment.
Did you check with an independent mqtt client if e.g. switch.birdie still sends messages.
And for your card, if these are really unavailable, you have to delete them from your card. They won’t delete themselves.