Home Assistant Entities unavailable while ESP in deep sleep

Testing that on one of my troubled devices.
Looks promising. Will watch it for a day or so and ‘feed back’.
Would be a much easier workaround than the one I and others are using.

I have the same issue.
Values show unavailable when esphome device is in deep sleep.
All my software is latest versions as of this post.
I do not compile on HA host (raspberry pi 3B), use my Mac desktop for that.
I enable deep sleep 10 sec on 1 min off after the integration is discovered.
If I enable deep sleep before discovery only one entity is ever found (firmware).
The other 6 never show up.
Connection is by api.
What is the normal behavior? Values staying or flipping back and forth???

So today i upgraded os to 11.3
remainder is at latest version
Core is 2024.1.0 (the dreaded dot 1)
Supervisor 2023.12.0
Frontend 20240103.3
AND
The values for my esp32 remain even when the device goes to sleep.
I like this behavior and am not sure what fixed it.
The only way I can tell that the Adafruit Feather with on board temp is sleeping is the ESOHome dashboard.
I wanted deep sleep because the temperature reading was off due to heating of the ESP32 module.

I am encountering this issue as well and I am trying fix this since days. I implemented all kind of workarounds and delays, which are pretty annoying.
So it looks like a) this problem is pretty common and b) it actually was fixed already, but still somehow persists.

I tested different esp 8266 devices using a Shutdown Switch and the reset button of my device / a switch connecting RST and GND.
I also tested using the Deep Sleep component instead of the Shutdown Switch.
The result is the same: Every time the devices go to deep sleep the sensors in HA become unavailable.

Does someone has found a working solution?
I am going to try a clean build without sensors and with deep sleep component as explained above and add the sensors afterwards and clean build again. If this does not help I am going to have a look at that modified API. But if it really is a problem with the API, why does the changes not get merged into the original API?

EDIT: Almost forgot to tell - I am on latest and greatest:
HA OS 11.3
HA Core 2024.1.2
ESP Home: 2023.12.5

My sensors do not become Unavailable anymore.

I changed the API key in the code (just to be sure, don’t know if necessary), deleted the device in the ESP integration of HA (but not in ESPHome Dashboard!) and flashed the ESP with the new API key.
After the ESP booted I got the notification that a new device was discovered. I added it to HA again.

Hello!
If an ESP is to work in deep sleep, the entities in HA must not yet exist. If the entities are already there because you want to test them, you have to delete the ESP and the entities after testing and then have them rediscovered, so to speak. Then the entities will remain permanently displayed.

The API key is not relevant.

Yes, you can leave the Yaml in ESPHome. I’ll do that too. That’s ok.

Greetings rabe

3 Likes

Just curious if anyone has found a fix for this?

I have one sensor that is battery powered and it recently (maybe in one of the Feb updates of HA? Unsure?) started going “unavailable” instead of holding its last known reading while the ESP is in deep sleep.

Did you try to delete the esphome integration for that esphome node and after that adding it again? If I remember that solved such unwanted behavior in the past :thinking:

I’ve not…mostly because its such a PITA with the timing of it being a solar powered battery device there is only like a 15 second window about half of which is it connecting to WiFi. I can give that a go, its just not fun.

If your deep sleep node has a “ota mode” like noted in the docs that can also be used to easily (re)-integrate the device in HA :tada:

The ESPHome FAQs state that the deep_sleep component must exists in the device’s configuration yaml file when it is added to HA. This is not to mean when the device is added to the ESPHome dashboard but after it’s in the dashboard you must set up the yaml file with deep_sleep before adding the device to the ESPHome HA Integration.

[FAQs](https://esphome.io/guides/faq.html)
Why do entities show as Unavailable during deep sleep?
The Deep Sleep component needs to be present within the config when the device is first added to Home Assistant. 
To prevent entities from appearing as Unavailable, you can remove and re-add the device in Home Assistant.
1 Like

I need a bit of guidance here. I’ve been playing with my esp and got it to the stage I want. As I had ‘unavailable’ sensors I removed device. However it still has code that puts it to sleep after 1 minute, and it fails adoption during that window. How do I work around this? The example shows wake for only 10s! Hope someone can advise. I have original yaml, but cannot add device using discovery/adoption