Send notification and go offline

Hello. What is the best way to send an notification when a device gets online from deep sleep? I tried an automation, but it never fires:

alias: Send Pushover
description: ""
triggers:
  - entity_id:
      - sensor.floor_esp32.wifi
    from:
      - unavailable
      - unknown
    trigger: state
conditions: []
actions:
  - action: notify.pushover
  ...

When i start it manually, the notification comes as expected. As far as I understand this may not work due to undefined states of the sensor? So how does one resolve this? An on_boot action to let the device do the thing? The ESP device is quite simple: just wakes up from deep sleep by an external trigger signal, connects to wifi and goes to deep sleep again after 10 seconds. No sensors, no actions.

Wifi component offers on_connect automation.

Thanks. Tried this, but it never fires. Even if the device is on for 60s. The device is also allowed to use actions/scripts. Is there something else to consider? API timings? Can't figure out.

  on_connect:
    then:
      - homeassistant.action:
          action: notify.html5
          data:
            message: "test"
triggers:
  - trigger: state
    entity_id:
      - sensor.floor_esp32.wifi

I use just the trigger of state without a from or to so when my esp comes online it triggers. I use MQTT so that may result in a different response than API.


When esp connects to mqtt server and HA gets a sensor reading it then sends esp back to deepsleep which is tipically within 60ms.

See your logs, best way to debug. On_connect is for wifi, api is likely not yet available at that moment.