Closed 3ative closed 3 years ago
So I narrowed it down to being the
value: | {{ [((variable.state | int) - 1), 0] | max }}
part. Didnt have any more time yet. Tbh that part was just copy pasted from the rogro repo.
Try it like this:
value: >
{{ [((states.variable.testing_one.state | int) - 1), 0] | max }}```
value: > {{ [((states.variable.testing_one.state | int) - 1), 0] | max }}```
I tried that, it worked-ish. 👍 I edited your code to:
value: |
{{ [((states.variable.testing_one.state | int) - 1), 0] | max }}
I removed the trailing 'tick' marks ( I guessed it was a typo😉) and now it works - Thank you for your time.
@Wibias Should I make a PR to update the code examples ? Or, now that you know about it, will you make the necessary edits.
I will do it in some minutes. Thanks for the response!
@Wibias Addition: I just looked at the yaml again, after a reload and HA changed it to this:
action:
- service: variable.set_variable
data:
variable: testing_one
value: "{{ [((states.variable.testing_one.state | int) - 1), 0] | max }}"
Notice the quotes on the 'value:' line.
For me it doesnt add the quotes but I am also using '>'
@Wibias
For me it doesnt add the quotes but I am also using '>'
If I save using the '>' that gets changed to a pipe '|' !
Well that's weird, I just checked again and for some reason it's changed it to single quotes now!!!
action:
- service: variable.set_variable
data:
variable: testing_one
value: '{{ [((states.variable.testing_one.state | int) - 1), 0] | max }}'
I've setup the Variable (_variable.testingone) and can change the state, so that bit is working.
and getting this: "Error: Error rendering data template: UndefinedError: 'variable' is undefined"
Any ideas?