How to get rid of entities when ESPHOME config changed and an entity is no longer there?

Hi, Topic says it all.

Just delete them.

If they aren’t on that page, just go to the entities page and delete them.

I don’t want to delete the complete device. I want to delete one entity in the device which is no longer existent due to changes in the config.

Ah, I should have tried it again.

NOW the entities show as unused and can be deleted. Seems there need some time to pass until this is possible.

For one entity is shows used last time 8h ago although the config does not include it for more than a week. => I cannot delete that.

Just need to restart typically or reload the integration.

Reload integration or restarting HA does not help.

One sensor which is not in the yaml config anymore cannot be deleted.

Does it help if I disable the entity and wait for a while or restart?

if reloading or restarting doesn’t work, that means ESPHome is still outputting something. Disabling it will remove it from entities, but it’ll still show up as disabled in your entity list. It will not show up in the dev tools → states page, or any entity searching dropdown.

Ok, so I did a clean build in ESPHOME.

  name: bad-warmwasser
  friendly_name: "Bad Warmwasser"
  includes:
    - TibberLocal.hpp

esp8266:
  board: huzzah
#  restore_from_flash: true

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: .fritz.box
#  use_address: 192.168.222.46
  manual_ip:
    static_ip: 192.168.222.19
    gateway: 192.168.222.1
    subnet: 255.255.255.0
    dns1: 192.168.222.11
  ap:
    ssid: "Bad Warmwasser Fallback"
    password: !secret wifi_ap_password

captive_portal:

logger:
  baud_rate: 0
  #level: INFO

ota:

api:
  encryption:
    key: "xxxx+cvWCh12nM4QCxLCCY="

status_led:
  pin:
    number: GPIO00
    inverted: True

#text_sensor:
#  - platform: version
#    name: "ESP Bad Warmwasser Version"
#    id: esp_bad_warmwasser_version

time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
      - seconds: 0
        minutes: 0
        hours: 5
        then:
          - switch.toggle: esp_bad_warmwasser_restart

switch:
  - platform: restart
    id: esp_bad_warmwasser_restart
    name: "ESP Bad Warmwasser Restart"

  - platform: template
    name: "Bad Warmwasser"
    id: bad_warmwasser
    turn_on_action:
      servo.write:
        id: esp_bad_warmwasser_servo_ctrl
        level: -0.55
    turn_off_action:
      servo.write:
        id: esp_bad_warmwasser_servo_ctrl
        level: 0.8
#    restore_mode: RESTORE_DEFAULT_OFF
    optimistic: true
#    assumed_state:

servo:
  - id: esp_bad_warmwasser_servo_ctrl
    output: esp_bad_warmwasser_pwm_output
    auto_detach_time: 1s
    transition_length: 1s
    restore: true

output:
  - platform: esp8266_pwm
    id: esp_bad_warmwasser_pwm_output
    pin: GPIO014
    frequency: 50Hz

http_request:

custom_component:
- lambda: |-
    return {new TibberLocal(1000, id(uart_bus), "http://tibber_bridge.fritz.box/data.json?node_id=1", "admin", "AV7B-BC74")};

uart:
  id: uart_bus
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1

sml:
  id: sml_id
  uart_id: uart_bus

sensor:
  - platform: sml
    name: "Energie Zählerstand"
    id: bad_energie_zaehlerstand
    sml_id: sml_id
    server_id: "xxxx"
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 4
    device_class: energy
    state_class: total_increasing
    filters:
      - multiply: 0.0001

  - platform: sml
    name: "Leistung"
    id: bad_leistung
    sml_id: sml_id
    server_id: "xxxx"
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    accuracy_decimals: 0
    device_class: power
    state_class: measurement

Still, I got:

Which is clearly NOT in the ESP config.

Reload the ESPHome integration.

If that doesn’t work, you restart. Either way, it involves the integration restarting without the integration providing the entity. Then it will be deletable. As a sidebar, the _2 is an indication that it doesn’t seem like it’s coming from esphome integration as the autogenerated id would not have the _2. That only occurs when the entity_id already exists and an integration is forced to increment the entity_id. Alluding to it being created by another integration.

You can believe me. I did restart the integration and Ha multiple times. I know the _2 because the time I generated the entities in ESPHome I once generated it as float and then changed the type to string. At that time HA generated the extra _2 entities and the one without became stale.
The entity is a string right now and I can see the history up until the time I deleted in ESPHome.

Ok, multiple updates later, lot’s of reboots/reloading later still no way to get rid of entities in ESP home where the config changed and the entities are not delivered by ESP home anymore (deleted in ESP home config).

image

How to deal with it?

Not sure how this is happening to you, but this is only affecting you. I think you’re missing a configuration somewhere, or doing something wrong during the process. I ran into this recently (removing entities from esp device) and it worked as expected after a restart of the esp device and HA. I was able to delete the entities with no issues.

With whom can I go thru this and check if there is a bug deeper down there?

In the end I would be able to remove the ESP Home device completely in the hope to get the entities removed then, but that would be last resort.

You’re welcome to write up an issue against HA core. Otherwise you’re on your own.

:crazy_face:

(Posting to short)

Something that worked.

Deactivate the complete ESP home device.

image

Then deleting the entities worked.

Reactivating device. Done.

1 Like

ive got the same issue

Also for me: Coming back all the time.

The only painful way to get rid of it is to remove the complete ESPhome device and add it again.

They will only come back if your esp device has them configured. The 2 systems are separate. Once you delete an entity from a device, the entity is gone unless the device is still telling HA it exists. So this is most likely an issue with your esp configuration.

When I do these changes, I simply remove the configuration from the ESP yaml, I then update the firmware on the esp device (So that it no longer creates the entities). Then I restart HA. After some time, the delete option will appear on the entities and you’ll be able to remove them forever.