Am I attempting the impossible or do I have a simple mistake…?
I want to press one of several buttons on a dashboard which will set a variable ‘option’ to one of a number values and then call a script.
The values for the ‘option’ can be x and a number or y and a number, eg x10.
The script is to increase an input_number by the amount passed.
The error I get in the log is ‘mapping values are not allowed here’
script:
go_to:
alias: move by x or y
sequence:
- input_number.set_value
target:
entity_id: input_number.x_coord
data:
value: >
{%if option[0]=='x'%}
{{option[1:]|int(0)+states('input_number.x_coord')|int(0)}}
{%endif%}
Are you sure the error is from the right script? It sounds like something you would get when the “if” fails, since there’s no default. You might want to set it up to use a YAML condition instead of a Jinja guard clause:
I preferred your earlier variant, but it seemed to not add, just assign. This version errors
Failed to perform the action script/go_to. Template rendered invalid entity IDs: input_number.~option[0]~_coord