Automations doesnt work

Hello,

I’m pretty new to HA,
but adding sensors and switches is easy for me and I add a lot for someone who just started.
I can control and see a lot at this point and im just running for one week.

But the one thing that doesnt work is automations. I have no clue why. I made one as simple as possible and still it doesnt work.
Because im new i probbly do something simple wrong, but i cant figure it out.
I added some automations in the GUI and one in de config file for testing.

In this case i like to switch on a light when the door go’s open.
My configuration.yaml that should include this.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
automation: !include automations.yaml
group: !include groups.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

homeassistant:
  customize: !include customize.yaml

automation old:
  alias: simple automatisering
  initial_state: true
  description: ''
  trigger:
  - entity_id: binary_sensor.door_window_sensor_158d00044dde74
    from: closed
    platform: state
    to: open
  condition: []
  action:
  - brightness_pct: 10
    device_id: b231a79674544012ae92b94afabd71bc
    domain: light
    entity_id: light.60600011ecfabc3c8efc
    type: turn_on

things i tried:
change closed and open to on and off.
remove “old” from “automation old:”
hash out the rule “#automation: !include automations.yaml”
tried differend sensors.

ofcourse i restarted home assistant after every change.
The check also tels me that the config is oke.

I can also see that HA is picking up the sensor when it open’s or closes.
and i can manualy toggle the light(s).

anything would be helpful. if there is more info nessesary from my side i’m happy to share it.

Im running HA on a virtual applice in ESXI.

ps. sorry for my lame English

Martijn

As well as your config file you should have an automations.yaml file, as you have this:

automation: !include automations.yaml

Put your automation in that file, like this (note the other changes I made to the trigger)

- alias: simple automatisering
  initial_state: true
  description: ''
  trigger:
  - entity_id: binary_sensor.door_window_sensor_158d00044dde74
    from: 'off'   # binary sensors states are only ever 'on' or 'off' no matter how they are displayed n the frontend.
    platform: state
    to: 'on'
  condition: []
  action:
  - brightness_pct: 10
    device_id: b231a79674544012ae92b94afabd71bc
    domain: light
    entity_id: light.60600011ecfabc3c8efc
    type: turn_on

Do not put automation: in this file. Just start each seperate automation with - alias:

I don’t use device automations so can not comment on the validity of your action block.

After making changes and saving, do a configuration check. If that passes you can use “Reload Automations” instead or restarting.

Use this. Just check status of your light in developer

  - id: turn_light_on_if_door_opened
    alias: Turn light on if door opened
    initial_state: 'on'
    trigger:
      - entity_id: binary_sensor.door_window_sensor_158d00044dde74
        platform: state
        to: 'on'## or 'open'
##check if light is off
    condition:
      - condition: template
        value_template: >
          {{ is_state('light.60600011ecfabc3c8efc', 'off')}}
    action:
      - service: light.turn_on
        entity_id: light.60600011ecfabc3c8efc

@tom_l — I think @martijn-tinus is trying to protect the handcrafted automations from the UI as documented here.

I use this setup:

automation: !include automations.yaml
automation old: !include_dir_merge_list automations

so that the UI editor writes into automations.yaml (currently empty) and I keep all of my hand-written automations in automations/*.yaml, safe from the editor’s comment-deletion and re-ordering of declarations into a stupid order :smiley:.

I wish I spoke lame ‘anything’ as well as you do English
:+1:

1 Like

In that case it’s probably only the trigger that needs fixing:

  trigger:
  - entity_id: binary_sensor.door_window_sensor_158d00044dde74
    from: 'off'   # binary sensors states are only ever 'on' or 'off' no matter how they are displayed n the frontend.
    platform: state
    to: 'on'
1 Like

Thanks for the (fast) help!

I made some automations by now.
the part ‘on’ / ‘off’ was my problem i think.
i gues i need to figure out for every sensor and entity wat the possible states are.

im also gonna use the recomandation from Troon.
I think i will mess some automations in the future :smile:
And this will give me a easy option to give me some hobby space.

one’s i got this all figured out the realy automations are starting :slight_smile:
automatic start the vacuum when nobody’s @home. turn some lights off when everybody is gone.
but this will be things for a rainy sunday.

thanks for now!!

That one night where you forget to plug your phone in to charge and the battery goes flat at 2am, triggering the “nobody’s home” condition… :yawning_face: :tired_face:

haha yeah that would be a problem.
but i think there is a DND inside the vacuum.
or i make a condition where it only works between sunrise and sunset… or something.