ESPHome with dynamic sleep_time in Deepsleep

I'm building a remote temperature sensor on ESP8266 to be put in a sauna, running on batteries. Since the sauna is only used for a couple of hours each time and sometimes weeks between usage, I'd like a variable sleep_time to reserve battery.

I.e. if the sauna temperature is below 30 degrees, it should sleep 15 minutes between readings.
If temperature is above 30 degrees I would like sleep_time to be 5 minutes.

Is is possible to have a template setting the sleep_time in ESPHome or do I need to build my own code to do this?

did you ever find out if anything like this is possible? I’m using an ESP32 and would like to do something similar

It’s not yet possible with just yaml there is a feature request though, go there and upvote

you can do it with a lambda and an undocumented call to the deep_sleep component but may be you just upvote meanwhile :slight_smile:

Upvoted, thanks

Hi there
I am responding to a bunch of old threads that are not resolved since I myself could not find this information here in the forums.

There are several ways (at least with version 1.19) to set the deep sleep duration from sensors or from Home Assistant by sending a retained MQTT message, se the code below.

In the sauna case I would maybe lean on having some sort of manual switch that turns the ESP on during the start up phase of the sauna but that might be overkill if you are not interested in logging the temps during the startup phase.

  - platform: dallas
    address: 0x5500000970DEB928
    name: "Test temp1"
    id: some_sensor_id
      - if:
            lambda: 'return id(some_sensor_id).state > 30.0 ;'
          - lambda: |-
          - lambda: |-

More code and text in this thread: DeepSleep with time window - #2 by runevad