i want to light up a LED depending on sensor data
I use this code, in conf.yaml
automation :
alias: turn on light if distance is less than 5cm.
trigger:
platform: state
entity_id: sensor.distance
below: 5
for:
seconds: 3
action:
service: switch.turn_on
entity_id: switch.control
It could just be due to the indenting. You’ve only indented by one space when it should be two like this:
automation:
- alias: 'turn on light if distance is less than 5cm.'
trigger:
platform: state
entity_id: sensor.distance
below: 5
for:
seconds: 3
action:
service: switch.turn_on
entity_id: switch.control
Oh and you had a space between automation and : on the first line.