On Boot Automation Troubles

Hi, I have a few smart plugs which have an LED on the button. I want the brightness to change based on sun above/ below horizon. I have this working fine on the sun above/ below horizon trigger but the On Boot automation only ever actions the ELSE condition.

Anyone have any ideas?

substitutions:
  devicename: driveway_lights
  upper_devicename: Driveway Lights

esphome:
  name: $devicename
  platform: ESP8266
  board: esp01_1m
  on_boot:
    then:
      - if:
          condition:
            - sun.is_above_horizon:
          then:
            - light.turn_on:
                id: led
                brightness: 0.75
          else:
            - light.turn_on:
                id: led
                brightness: 0.14
               
sun:
  latitude: #####
  longitude: #####
  on_sunrise:
    - then:
        - light.turn_on:
            id: led
            brightness: 0.75
  on_sunset:
    - then:
        - light.turn_on:
            id: led
            brightness: 0.14
              
wifi:
  ssid: #####
  password: #####
  output_power: 17.5db
  ap:
    ssid: "$upper_devicename Fallback Hotspot"
    password: #####

captive_portal:

logger:

api:

ota:

time:
  - platform: homeassistant

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: False
    id: sonoff_button
    internal: true
    on_press:
      - light.toggle: light_1
  - platform: status
    name: "$upper_devicename Status"
    id: connected_status

output:
  - platform: gpio
    id: sonoff_relay
    pin:
      number: GPIO5
      
  - platform: esp8266_pwm
    id: basic_blue_led
    pin:
      number: GPIO4
      inverted: true

light:
  - platform: binary
    name: "$upper_devicename"
    id: light_1
    output: sonoff_relay
    
  - platform: monochromatic
    name: "$upper_devicename Blue LED"
    output: basic_blue_led
    id: led
    
switch:
  - platform: restart
    name: "$upper_devicename Restart"

Probably because the sun component isn’t initialised when the if statement runs. Try making the priority lower (default is -10):

esphome:
  name: $devicename
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -100
    then:
....etc

Just tried your suggestion but still only actions the else command

Try to use the delay action before your condition

  • delay: 60s