I’m having an issue with getting the automation to work and i can’t figure out why at all.
Here is my automation
- alias: If the window is open turn the light on
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00033aad5b2
from: 'off'
to: 'on'
action:
- service: homeassistant.turn_on
entity_id: switch.lounge
as you can see it’s a pretty basic automation so far as i just want to test it. I have used dev tools to change the state but no joy even physically moving the two sensors doesn’t turn it on.
Anyone any idea as i’m stumped even after looking online and following examples, etc.
Hi richatha,
i have just created an automation and it runs without problems. I attach a screenshot. I have not written the automation in the “automation.yaml” itself, but created on the HA UI … The exact formatting is very important here !!!
This refers to the status of the automation itself. It was a requirement in all automations at one point, so your code would look like:
- alias: If the window is open turn the light on
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00033aad5b2
from: 'off'
to: 'on'
action:
- service: switch.turn_on
entity_id: switch.lounge
Thanks for everyones suggestions but still not having any luck with the light coming on.
I can still see in the entities list that when i pull the contact away from each other the state changes from off to on but then the switch isn’t triggering. Have tried all your combinations so far with no avail.
Anything else wrong?
Here is my current code
- alias: If the door is open turn the light on
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00033aad5b2
to: 'on'
action:
- data:
- service: switch.turn_on
entity_id: switch.lounge
I have also tried a motion sensor too and that one didn’t work either!