Send a notification after boot

Hi,

I would like to receive a noification as soon as the device has been booted.
For this I wanted to use the following code.
Unfortunately, I don’t get a notification. What can be the reason for this?

esphome:
  name: esp01-relay
  friendly_name: ESP01_Relay

  on_boot:
    - priority: 600
      then:
        - homeassistant.action:
            action: notify.mobile_app_a13x
            data:
              title: ESPHome 
              message: device booted

thx
a13x

Having booted doesn’t mean HA is connected to the device (nor event that wifi is connected).

You probably should use the on_client_connected trigger of the api component

Good point, thanks.

I’ve tried the following, but get this error when validating:

ERROR Error while reading config: Invalid YAML syntax:
mapping values are not allowed here

api:
  encryption:
    key: !secret api_encryption_key
  on_client_connected:
    then:
      - homeassistant.action:
        action: notify.mobile_app_a13x
          data:
            title: ESPHome
            message: device connected to API

Whilst fully agreeing with the above, I gave it a go but found the notifications to be inconsistent. Probably a timing issue. But inserting a delay caused even more weirdness - duplicate notifications sometimes in addition to no notifications or just one notification !

I don’t have enough time to troubleshoot today ( busy day ), so I tried the “on boot” option and it worked flawlessly each time I rebooted the ESP

  on_boot:
    priority: -100.0
    then:
      - delay: 2s
      - homeassistant.action:
          action: notify.persistent_notification
          data:
            title: ESPHome
            message: " Device Booted"

Don’t forget to allow the ESP to perform actions in Home Assistant

If you want to give the “on_client_connected” option a go ie. YMMV

api:
  encryption:
    key: !secret api_encryption_key

  on_client_connected:
    then:
#      - delay: 2s
      - homeassistant.action:
          action: notify.persistent_notification
          data:
            title: ESPHome
            message: " Device Booted"

Forget to mention earlier. For the the notification target ( action ), I’m aimed at bog standard persistent notifications in HA. I don’t use the mobile app. So please edit accordingly :slight_smile:

Thanks, that solved me issue :+1:

1 Like