locuester
(Dana Hanna)
November 24, 2018, 4:10am
1
Here’s my rrelevant config:
data_template:
entity_id: light.tori_mirror
hsb_color: [{%- if states.sensor.dark_sky_daytime_high_temperature.state | float * -3 + 300 < 0 -%}0{%- else -%} {{ states.sensor.dark_sky_daytime_high_temperature.state | float * -3 + 300}}{% endif -%},100]
- delay: 00:35:00
- service: light.turn_off
data:
entity_id: group.tori
I get the error:
Error loading /config/configuration.yaml: while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/automations.yaml”, line 86, column 20
Line 86 column 20 is the first ampersand here:
I’ve tried moving everything around, searchf ro tbas, etcc… It doesn’t like that hsb color script.
What am I missing?
First, all single line templates must be in quotes.
Second I can’t see any ampersands in the code block you posted.
Third, in the code block you posted the penultimate line needs moving right 2 spaces, and the last line needs moving right 4 spaces.
Fourth, it’s unlikely that you should have a data key inside a data_template key.
I could go on…
locuester
(Dana Hanna)
November 24, 2018, 2:45pm
3
Thanks so much for replying so quickly. The third issue you mention was a code formatting issue here.
Here’s the relevant code now:
- service: light.turn_on
data_template:
entity_id: light.tori_mirror
hsb_color: [{% if states.sensor.dark_sky_daytime_high_temperature.state | float * -3 + 300 < 0 -%}0
{%- else -%}
{{ states.sensor.dark_sky_daytime_high_temperature.state | float * -3 + 300}}
{%- endif %},100]
- delay: 00:35:00
- service: light.turn_off
Not sure where you’d expect an ampersand?
I get the same error:
Error loading /config/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
in "/config/automations.yaml", line 86, column 20
If I put this data_template in the template editor I get
[157.77,100]
Which is what I want hs_value set to.
Try:
- service: light.turn_on
data_template:
entity_id: light.tori_mirror
hsb_color: >
[ {% if states.sensor.dark_sky_daytime_high_temperature.state | float * -3 + 300 < 0 -%}0
{%- else -%} {{ (states.sensor.dark_sky_daytime_high_temperature.state | float * -3)|int + 300}}
{%- endif %},100 ]
- delay: 00:35:00
- service: light.turn_off
I wasn’t, but you sad “Line 86 column 20 is the first ampersand here” and there are no ampersands, which threw me.