I’m having real difficulty using namespaces in templates. I’m running the latest HomeAssistant (61.0) and Jinja2 2.10 so I think it should work. Whilst I can set the values, I can’t work out how to retrieve them. I’ve checked the Jinja2 documentation and can’t see what I’m doing wrong.
{%- set ns = namespace(mystate=1) -%}
{{ ns }}
gives
<Namespace {'mystate': 1}>
However trying to use or get the value of mystate doesn’t work, e.g.
{%- set ns = namespace(mystate=1) -%}
{{ ns.mystate }}
doesn’t give anything. Nor does any other attempt I’ve made to get the value of mystate. Anybody know how to get this working? Or does it work elsewhere and it’s just my setup is broken?
Eh, I just found namespace in the jinja documentation and it doesn’t appear to work in hass. The method I posted will not work. I copied the example from the api documentation into the templates page and that did not return any value when accessing namespace.
I’ve changed my code to avoid the problem. Always good when that’s an option. I’m going to have a look at appdaemon too. Looks pretty nice, including the dashboard. Thanks for the pointer.