Ignore ESPHome discovered devices

Does anyone know how can I delete/ignore the discovered devices below?

I have deleted via ssl all the relevant files but they won’t go away. They not causing any issues but I would like to have a clean workspace

I don’t know of a “correct” way of renaming the project so when I did the old project name appears as a discovered device. It is not really an existing device.

1 Like

Have you tried adopting then deleting them?

Are you sure you have deleted the yaml files, eg athom-plug-1.yaml?

Yes. As soon as I delete after adopting the discovered devices reappears.

Yes. Positive. I went through all the folders under esphome

This is what windows search returns for “athom-plug-1” which is the one I want to keep.
image

There is nothing under"aathom-plug-1"
image

I even restarted HA after deleting the files with no change.

The yaml file is not in a sub-directory. Is there a aathom-plug-1.yaml?

Nope.
Nothing in the entire Home Assistant file structure :no_mouth: .

I am wondering if there is file similar to “known_devices” that stores discovered entities.

I AM NOT AN EXPERT. And I am usually wrong.

From my notebook:
“Problem with autodiscovered mqtt devices is this: you have to remove the retained messages on your broker first, before you remove them from HA. Or else HA will rediscover them the moment HA restarts, because your broker sends the retained messages when HA starts”

Also from my notebook:
" Stale retained messages
When adding new entities, you might run into trouble with old entities still appearing in Home Assistant’s front-end. This is because in order to have Home Assistant “discover” your devices on restart, all discovery MQTT messages need to be retained. Therefore the old entities will also re-appear on every Home Assistant restart even though they’re not in ESPHome anymore.

To fix this, ESPHome has a simple helper script that purges stale retained messages for you: clean-mqtt (Under the three dots on the dashboard)"

Hope this helps.

Could you please, maybe, share a screenshot so I see which 3 dots menu you are referring to? By now I have the impression I have exhausted all the places that can host button :sweat_smile:

On the ESPHome page:

That’s assuming they are using MQTT and not the API. Which is fair enough as we have been assuming they were using the API.

I am not sure what method is used underneath.
I bought a preflashed Athom plug it got recognised by HA but did not appear in ESPHome, so to have full access to the code I added a new device put the code and downloaded the firmware. Flashed it via the captive portal OTA and voiala. I ended up having the first ghost in ESPHome.

In this code you downloaded, does it say “mqtt” or “api” or both?

Hello Tom!

Thank you for the reply. I didn’t know what answers the original question. Thank you form making it specific.

It says “api”.

substitutions:
  name: "athom-smart-plug"
  friendly_name: "Athom Smart Plug"
  project_name: "athom.smart-plug"
  project_version: "1.0"
  relay_restore_mode: RESTORE_DEFAULT_OFF

esphome:
  name: "${name}"
  name_add_mac_suffix: true
  project:
    name: "${project_name}"
    version: "${project_version}"

esp8266:
  board: esp8285
  restore_from_flash: true

api:

ota:

logger:

web_server:
  port: 80

The full code can be found here: athom-configs/athom-smart-plug.yaml at 8d1a9bcb8ebbb3b1e9b66dc7efba4a09a5cdde64 · athom-tech/athom-configs · GitHub
It is provided in the official Athom page: https://www.athom.tech/blank-1/esphome-uk-plug

So mqtt clean won’t help.

Yep. So back to square-1 :sweat_smile:

Make a copy of the device yaml files in config/esphome. Keep them somewhere safe.

Uninstall the esphome addon.

Delete the config/esphome folder

Delete the esphome* files from config/.storage

Restart.

Install the esphome addon.

Copy your device yaml files back to config/esphome.

Open the esphome web UI …

1 Like

Hello Tom,

I was waiting for the weekend to try out your suggestion. In the meanwhile 2022.3.0 came out. After updating issue got solved. So I believe your suggestion would have worked.

Thank you for your contribution!

I had the same issue with an unwanted device using ESPHome version 2022.3.1 and HA version 2022.3.7. What worked was to adopt the bad device and let it fail. Before deleting it though I restarted the ESPHome add-on and then Home Assistant. Then I was able to delete it and it stayed gone.

2 Likes

That’s a nice one. I will try it next time it happens.
Thanks for sharing :smiley: