Automation doesn't work

Hello,

I’m new to all of this and having troubles with a simple automation to switch the light on in the hallway when opening the door. It does nothing… I use aqara door sensors with deconz zigbee integration and SonoffLAN integration with Sonoff smart switches.

- id: '1606825601890'
  alias: Licht aan bij deur openen
  trigger:
  - platform: state
    entity_id: binary_sensor.deur_naar_gang
    from: 'closed'
    to: 'open'
  action:
  - service: switch.turn_on
    entity_id: switch.sonoff_voordeur

I guess your state is wrong. binary sensors normally have the state on/off
you can check it in the developer tool section

I didn’t know that :sweat_smile: Just checked in developer tools and the state is indeed on or off. I’ll test it and let you know!

I adjusted the state to on or off but still nothing happens. What am i not seeing/forgetting?

- id: '1606825601890'
  alias: Licht aan bij deur openen
  trigger:
  - platform: state
    entity_id: binary_sensor.deur_naar_gang
    from: 'off'
    to: 'on'
  action:
  - service: switch.turn_on
    entity_id: switch.sonoff_voordeur

Anything in your logs ? I assume you reloaded the automations ?

Automations are reloaded. In my logs i do not see anything about the automation, it’s like it’s not even there.

Is the automation enabled? Do you see it in Developer Tools -> States?

How do you enable an automation :thinking: ? I can’t find it under states…

You should see all your automation in the states page if you filter by typing automations, if you click on the i next to the entity name, the pop up as shown appears, the switch on there enables/disables it

Nope no automation in there…
I have this set in my configuration file, is that correct?

automation: !include_dir_merge_list automations.yaml

If you only have one automations.yaml, try

automation: !include automations.yaml

Assume you automations.yaml is saved in same directory as configuration.yaml

I think what you have is if you have an automations directory and multi automation yaml files in there:

automation: !include_dir_merge_list automations/

Yep that was it! I now understand when you have to put !include_dir_merge_list and when not. After i changed it, the automation appears under Developer > States.

I’ll test the automation when i get home and let you know if it works.

The automation works now! Thanks everyone for the advice :+1: