Variables integration

I am attempting to use variables within HA to compute dates. The attached screenshots show one of the variables in question in HA/Developer Tools/States and shows that var.adjyear has a value 2022 which is correct.
The second screenshot shows a template using the variable var.adjyear and the resulting error, UndefinedError: ‘var’ is undefined.
While the variable definitions work and a script use to set the variable value works, the template does not.


Try this:

start: "{{ now().replace( year = states('var.adjyear')|int(1900), month = states('var.adjmonth')|int(12), etc...

Yes, that works. Thank you. Just an old school head trying new approaches. I have to remember that values have to be extracted and that entities including variables cannot be used directly as in other HLL techniques.

1 Like