I’ve been trying to build my first simple automation and I keep getting this one error which I have no idea about.
Yaml is:
alias: Turn Office Lights On
trigger:
platform: state
entity_id: binary_sensor.office_office_motion_178
to: on
action:
service: light.turn_on
entity_id: light.office_office_lights_160
- alias: Turn off Office Light
trigger:
platform: state
entity_id: binary_sensor.office_office_motion_178
to: off
for:
minutes: "3"
action:
service: light.turn_off
entity_id: light.office_office_lights_160
The error is :
Invalid config for [automation]: expected str for dictionary value @ data[‘to’]. Got None. (See /config/configuration.yaml, line 14).
Clearly I am doing something stupid. Can someone please point me in the right direction.
That is a copy and paste error the - is there and it is the same indentation as trigger, I must have accidentally deleted it when I was putting the ‘’’'s in to separate the code.
When quoted, it’s interpreted as a string containing the word on. Without quotes, the word on has special meaning and is handled as a variable (whose value is a boolean not a string).
To close out this topic, please consider marking my post (above) with the Solution tag. It will automatically add a check-mark next to the topic’s title which indicates to other users that this topic has an accepted solution. This helps users find answers to similar questions.
By selecting the Solution checkbox in the other post, it will automatically deselect your post because only one post in the entire thread can be the Solution post.
There appears to be one on your post. Try deselecting it and see if that permits you to select the Solution checkbox of any other post. Even if you still can’t select mark another post, at least users, searching for the Solution, won’t be led to the wrong post.