I have a simple automation which turns on a light when it is dark. Whether it is dark or not is determined by a binary sensor which I can assure you is off now.
Why then does the light go on at every HA restart?
- alias: Hall light on when dark
initial_state: on
trigger:
- platform: state
entity_id: binary_sensor.dark_hall
to: 'on'
- platform: homeassistant
event: start
condition:
# Check it is dark (for when triggered by HA restart)
- condition: state
entity_id: binary_sensor.dark_hall
state: 'on'
# Check it is after 8am
- condition: time
after: '08:00:00'
action:
- service: homeassistant.turn_on
entity_id: switch.hall_light