Automation not loading

My issue is that I have a single automation which does not load on startup.

Here is the automation:

alias: Turn on hall light on movement
  - platform: state
    entity_id: binary_sensor.pir_hall
    to: "on"
  - condition: state
    entity_id: sun.sun
    state: "below_horizon"
  - service: switch.turn_on
    entity_id: switch.hall_light

my automations.yaml file:

- !include automation/hall_light_on.yaml
- !include automation/welcome_home.yaml
- !include automation/defiant.yaml
- !include automation/lounge_lights.yaml
- !include automation/hall_light_off.yaml
- !include automation/radio_on.yaml

“configuration > general > reload automations” does not fix
removing the condition does not fix.
All the other automations load ok
Example working automation:

alias: Turn off hall light
  platform: state
  entity_id: binary_sensor.pir_hall
  to: "off"
    minutes: 1
  - service: switch.turn_off
    entity_id: switch.hall_light

Thanks in advance for any help!

Can it be the - in the trigger of the not loading automation?

Nope - that’s the correct way of doingit.

Couple of things.

First, did you run a configuration check?

Secondly, why not use:

automation: !include_dir_list automation/

That’ll save you from listing them individually

1 Like

Is the automation ‘on’? Go to the /dev-state and filter for ‘automation.’ . In the column ‘State’ there should be an ‘on’.

1 Like

@deisi, @Tinkerer,

Thanks guys for your replies.

I have sorted this out.

Firstly it does not seem to matter if the is there or not (I have this working now without the -; I guess the - is only needed if there is more than one block in the trigger)

The problem was this:
At some point in the development I had the line
initial_state: 'false'
This disables the automation on restart; unfortunately removing this line does not change this ‘disabled’ state.
To fix I went to the ‘states’ tab, clicked on ‘more info’ and in the dialog that appears there is a switch which allowed me to re-enable the automation

Without that line, the state of the automation is restored on startup. If you were to set it to 'true' then it would be forced on.

why not use:

automation: !include_dir_list automation/

Great tip; thanks!