Disclaimer: I’m new to this. But I have gotten two automations working fine. Now I am attempting a third, cleverly named as “three”. (Code snippet below)
When I upload this configuration and restart home-assistant, I get the following error:
2017-08-19 09:10:01 ERROR (MainThread) [homeassistant.config]
Invalid config for [automation]: required key not
provided @ data['condition'][0]['condition']. Got None.
I assume from this that my “condition:” is invalid, but I have not been able to successfully alter it to pass muster. Any suggestions?
Here is the code snippet from the configuration.yaml:
- id: three
alias: Turn on bright hall light when kat comes home
trigger:
platform: state
entity_id: device_tracker.watch_kat
from: 'not_home'
to: 'home'
condition:
entity_id: sun.sun
value_template: '{{ state.attributes.elevation | int }}'
below: 10
action:
service: light.turn_on
data:
entity_id: light.linear_unknown_type4754_id4252_level
brightness: 155
Your condition needs to look like this:
condition:
condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.sun.sun.attributes.elevation | int }}'
below: 10
Have a look at this page for more examples.
Thanks, fanaticDavid. It still errored out on that, but let me see if I can noodle my way through it. If I can’t, I’ll be back!
Tried a bunch of different things based on what I could google, etc. No dice.
My error is now:
2017-08-19 18:19:00 ERROR (MainThread) [homeassistant.config]
Invalid config for [automation]: expected a dictionary
@ data[‘condition’][0]. Got None
extra keys not allowed @ data[‘below’]. Got None
extra keys not allowed @ data[‘entity_id’]. Got None
extra keys not allowed @ data[‘value_template’]. Got None.
My automation is now:
-
id: three
alias: Turn on bright hall light when kathy comes home
trigger:
platform: state
entity_id: device_tracker.watch_kathy
from: ‘not_home’
to: ‘home’
condition: numeric_state
entity_id: sun.sun
value_template: ‘{{ state.attributes.elevation }}’
below: 10
action:
service: light.turn_on
data:
entity_id: light.linear_unknown_type4754_id4252_level
brightness: 155
The biggest change I tried was using
value_template: ‘{{ state.attributes.elevation }}’
Which more than a few google results said was the right way to do what I was doing.
Saw numerous examples of code that was reported as working using that, but no dice. For example this snippet:
condition: numeric_state
entity_id: sun.sun
value_template: ‘{{ state.attributes.elevation }}’
below: 3
I got the same error when I tried the config file in fanaticDavid’s example.
You did not copy my code exactly. Previously, you were only using this line for conditions:
condition:
Now, you are using:
condition: numeric_state
My code states the following:
condition:
condition: numeric_state
The first condition:
is the start of the condition section of your automation. The second condition:
defines the type of condition.
Could you let me know if your version of the template works, though? I’m curious
Automation was accepted with this condition code:
condition:
condition: numeric_state
entity_id: sun.sun
value_template: ‘{{ state.attributes.elevation }}’
below: 10
Have to test if it actually works yet, but it was accepted when restarting and appears as a valid automation in the dashboard.
THANKS!
1 Like
I wasn’t careful with my spacing when cutting and pasting, of course my last 4 lines were indented.