Entity values "Unavailable" during sleep

I have a basic 8266 connected to a BME280 for temperature, pressure and humidity. Running “live”, it’s perfect. I put in the code for the deep sleep, plus the jumper wire from RST to D0, and it’s waking, running for 30s, then sleeping for 5min, which is what it is supposed to do.

The problem is that when it’s in sleep mode, the cards for the sensor in HA all show as unavailable. As soon as it wakes & connects, the data is back. I was under the impression that it would display the last known values.

I’m running HA 2023.10.3, ESPHome 2023.9.3.

Note: I added the sleep after the device and entities had already been configured in HA.

You can try a reload in the Integration as HA might mot know it has a deep_sleep setting.
Otherwise delete the entity and re-add it in HA.

Tho it looks like its still an issue: ESPHome - Sensor value is shown as Unavailable after several minutes of deep sleep · Issue #98221 · home-assistant/core · GitHub

You haven’t shown your YAML code. Are you using MQTT? Going unavailable is the expected response. The device usually sends a will message when it goes to sleep. Search the forum for the hundreds of other people who had same problem and then found the solution.

Ok, here’s what I had to do to fix it:

in the device code, comment out all sensors, save and upload the new firmware

in HA, do a restart. Once it’s fully running, go to the device entities and delete all of the sensors.

in the device code, remove the comments from the sensors, save and upload the new firmare.

It now retains the device readings during sleep.

No MQTT, and, no, it’s not ‘expected’ to show unavailable. It should show the last known reading. Following my solution, it now works 100% correctly.

That’s basically what I had to do. I described the steps in the solution.

I’ve struggled with the same issue. I finally had all my sensors behaving but I was trying so many things to make them stop displaying “unavailable” during sleep I was never sure what actually solved it, until…
I added a new esp8266 device and it also started showing the unavailable issue and then I realized when I add a device it initially isn’t configured for deep-sleep. I’ll add a few sensors to get it where I want it and then add the deep-sleep component. I believe that to be the problem. Deep-sleep should be configured and installed before adding any sensors.

  • So with this new device, I commented out the sensors, but left in the deep-sleep, in the config file and re-installed it.
  • Copied the config file for the device from the esphome folder in homeassistant/config. I have samba installed so I have access to these folders.
  • Deleted the device from esphome.
  • Restarted Home Assistant.
  • Copied the devices config file back to the esphome folder. This will add it back to esphome.
  • It then will show up in HA as a newly discovered device. Add it to HA.
  • Uncomment the sensors in the device’s config file and reinstall it.
  • problem should be solved.