Hi!
I’m trying to write a script for slow dimming a light from 50 to 200 brightness.
In a simple way it’s just a set of blocks in scripts.yaml like this:
'1589654337355':
alias: VR1.LD2 Smooth Maximum
sequence:
- data:
brightness: 50
entity_id: light.3431760284f3ebf92381
service: light.turn_on
- delay:
milliseconds: 500
- data:
brightness: 51
entity_id: light.3431760284f3ebf92381
service: light.turn_on
- delay:
milliseconds: 500
...
- data:
brightness: 200
entity_id: light.3431760284f3ebf92381
service: light.turn_on
But this needs too much text for this simple task. So I’ve decided to optimize it with templating:
'1589654337355':
alias: VR1.LD2 Smooth Maximum
sequence: {% for br in range(50,200,1) -%}{% raw %}
- data:
brightness: {% endraw %}{{br}}{% raw %}
entity_id: light.3431760284f3ebf92381
service: light.turn_on
- delay:
milliseconds: 500
{% endraw %}{%- endfor %}
This works as expected in template editor, but pasting this to scripts.yaml causes error
Error loading /config/configuration.yaml: while scanning for the next token found character '%' that cannot start any token in "/config/scripts.yaml", line 3, column 14
Next I’ve tried to make quotes around template items:
'1589654337355':
alias: VR1.LD2 Smooth Maximum
sequence: "{% for br in range(50,200,1) -%}{% raw %}"
- data:
brightness: "{% endraw %}{{br}}{% raw %}"
entity_id: light.3431760284f3ebf92381
service: light.turn_on
- delay:
milliseconds: 500
"{% endraw %}{%- endfor %}"
But this causes error:
Error loading /config/configuration.yaml: while parsing a block mapping in "/config/scripts.yaml", line 2, column 3 expected <block end>, but found '-' in "/config/scripts.yaml", line 4, column 3
Will be very pleased if you can recommend me correct format for template in scripts.yaml or give a sample code for similar task
Thank you!