On_boot issue

Hi,

very simple code:

substitutions:

  device_name: lampka-nocna-mikolaj
  friendly_name: Lampka nocna Mikołaj
  comment: Sonoff Basic R3
  icon: "mdi:gesture-tap-button"

esphome:
  name: ${device_name}
  friendly_name: ${friendly_name}

  on_boot:
    
    - logger.log: "Device booting up..."
    - wait_until:  
        condition:      #  any condition here
          api.connected: 
        timeout: 60s
    - if:
        condition:
          api.connected:
        then:
        - logger.log: "api connected"
        - homeassistant.action:
            action: counter.reset
            data:
              entity_id: counter.licznik_klawisza_testowego

After device reboot there is no entry in log and homeassistant action is not performed.

BUT If i link this action to switch like below:

switch:
  - platform: gpio
    name: Relay
    id: przekaznik
    pin: GPIO12
    restore_mode: RESTORE_DEFAULT_OFF
    icon: "mdi:toggle-switch-variant-off"
    on_turn_on:

      - homeassistant.action:
          action: counter.increment
          data:
            entity_id: counter.licznik_klawisza_testowego

the counter in HA is reset. Tried also with priority setting - no luck.

Any hint ?

ESPHome Version 2024.12.4

 on_boot:
    - priority: -100
      then:

then ad your code.

Thank You !

You are welcome!

The api component has an on_client_connected trigger which would be a better place to put your actions.

1 Like