Deepsleep and input_boolean from Home Assistant

Hi,

I would like to have an input_boolean helper in Home Assistant.
Upon start of my ESPHome node, it’s value shall determine if my node goes to deepsleep or not.
In the logs, I do see that the ESPhome node gets the value from HA, however my actions do not trigger. They get triggered once I flip the button in the HA dashboard.
So bascially upon restart of my node, getting the boolean out of HA does not do anything (tested with a copy of the input_boolean, as indicated below). What am I missing?

  - platform: homeassistant
    name: Deepsleep ${uppernodename}
    id: deepsleep_request
    entity_id: input_boolean.esp8266_deepsleep

  - platform: copy
    name: Deepsleep ${uppernodename} requested
    id: deepsleep_request_copy
    source_id: deepsleep_request
    on_press:
      then:
        - logger.log: "Enabling deepsleep"
        - deep_sleep.allow: deep_sleep_1
    on_release:
      then:
        - logger.log: "Disabling deepsleep"     
        - deep_sleep.prevent: deep_sleep_1

I’ve experienced this issue too. Can’t recall the exact fix.

You can try adding publish_initial_state: true and see if that helps.

  • publish_initial_state (Optional, boolean): If true, then the sensor will publish its initial state at boot or when HA first connects, depending on the platform. This means that any applicable triggers will be run. Defaults to false.

Thank you! This fixes it.
Seems I read over or misinterpreted that option…

1 Like