ESPHome Entities disappeared?

Can someone help me find my missing entity?

I have an ESPHome device (A Sonoff Basic switch) that has been working for weeks. Today, I can edit and update it in the ESPHome panel. I can open the device web page and turn the switch on or off. But an automation that turns this switch on or off stopped working. While investigating to see if the device developed a new entity_2 ID, I can’t find it in Developer Tools → states:

sconces device id

When turning the switch on/off from the device web page, I see this in the logs:

[12:50:10][D][switch:012]: 'basement_sconces relay' Turning ON.
[12:50:10][D][switch:055]: 'basement_sconces relay': Sending state ON
[12:50:17][D][switch:016]: 'basement_sconces relay' Turning OFF.
[12:50:17][D][switch:055]: 'basement_sconces relay': Sending state OFF

Yes, I’ve restarted Home Assistant. Any ideas would be appreciated.

Here is the YAML file of the device:

#basement-sconces.yaml
#Sonoff Basic RfR2 Module

substitutions:
  device_name: basement-sconces
  friendly_name: basement_sconces  #Dashes are not allowed


packages:
  device_base: !include common/esp8266.yaml
  wifi: !include common/wifi.yaml


# Web server uses a lot of RAM.  If you have a lot of components and your
# device is acting strange, remove the Web Server by uncommenting this line.
# web_server: !remove 

  
###############################
# Sonoff Basic peripherals

# Relay on GPIO12  
switch:
  - platform: gpio
    name: ${friendly_name} relay
    pin:
      number: 12
      mode: output
    id: relay
    
    
    
# Physical Button on GPIO0
binary_sensor:
  - platform: gpio
    pin: 
      number: 0
      inverted: False
      mode: INPUT_PULLUP
    name: ${friendly_name} button_0
    on_press:
      - switch.toggle: relay
      
  # Physical Button on GPIO3 (Rx)
  - platform: gpio
    pin: 
      number: 3
      inverted: False
      mode: INPUT_PULLUP
    filters:
      - delayed_on: 250ms   # DEBOUNCE
    name: ${friendly_name} button_3
    #If the switch on GPIO3 is a toggle, use both on_press and on_release
    #If the switch on GPIO3 is a momentary toggle, then just use on_press.
    on_press:
      then:
      - switch.toggle: relay
    on_release:
      then:
      - switch.toggle: relay


light:
  - platform: status_led
    name: ${device_name} status LED
    id: ready
    pin: GPIO13
    internal: true

===========================================================

Update: I renamed the device and the new entity became available:

#basement-sconces.yaml
#Sonoff Basic RfR2 Module

substitutions:
  device_name: basement-sconce-lights
  friendly_name: basement_sconce_lights  #Dashes are not allowed

I updated the automations with the new entity and they work fine.

But, still, why did the device entity disappear in the first place?

Sometimes it happens when name is changed.
When _1 _2 etc. appears - I prefer to delete HA device and add it again to have clean situtation.

Adding _2, _3, etc is normal when you change almost anything on the device, but the entity always shows up in Dev Tools > States. That is my question- why does a working device no longer show in “states”?

On the _2, etc, I wish there were an easy way to clean those up. And, in my case hundreds of “unknown” entities. As I do experiments and remove old devices, the entity remains in the database forever. Deleting the integration and letting Home Assistant rediscover everything still online is a tedious job because of the ESP devices that sleep most of the time. And the broken automations… We’re talking about an all-day job of cleaning up.

1 Like

Is it maybe this issue: Sensor not available - #26 by reox ?
I had this now several times, sometimes I could resolve it but now it is in a state where nothing makes the sensor available again. The data is correctly transmitted, just the state is wrong.