I’m very new to HA but I’ve been playing around and now I’ve got stuck. I bought a Tradfri Bulb and Motion Sensor which I’ve connected via a Zigbee gateway (Phoscon). I ran through the automations tutorial and everything worked - when I wave my hand the light turns on wohooo!
Unfortunately it seems that not everything is simple, trying to do the reverse and turn the light off when the sensor goes “Clear” seems much more difficult. Here is my automations.yaml
- id: '1558122946947'
alias: LightOn
trigger:
- entity_id: binary_sensor.tradfri_motion_sensor
platform: state
to: 'on'
condition: []
action:
- data:
entity_id: light.lamp
service: light.turn_on
- id: '1558378378087'
alias: LightOff
trigger:
- entity_id: binary_sensor.tradfri_motion_sensor
to: 'off'
platform: state
condition: []
action:
- data:
entity_id: light.lamp
service: light.turn_off
To me the automations look exactly opposite. The first works and the light turns on, the second does not and so the light stays on
Looking at the LogBook I can see the ‘on’ event followed by the ‘LightOn’ automation then I can see the ‘off’ event but no ‘LightOff’ automation. I’m not sure what else to check… help?
I also tried using the trigger
from: ‘on’
rather than
to: ‘off’
but that was no more successful.