Well, yes it does but it doesnāt seem consistent:
This is my exact config (the style bit):
style: |
#states {
padding: 0px 16px;
}
:host {
--paper-item-icon-color:
{% if states('timer.irrigation_zone1_timer') == 'idle' %}
var(--paper-item-icon-color)
{% else %}
var(--paper-item-icon-active-color)
{% endif %};
}
This is the relevant bit from the log (the full log output is at the bottom of this post):
File "/config/lovelace/includes_garden/item_zone_duration_line.yaml", line 52, in top-level template code
{% if states('timer.irrigation_zone1_timer') == 'idle' %}
jinja2.exceptions.UndefinedError: 'states' is undefined
And this is the template page to prove the jinja works as expected:
As promised the full log output:
Error handling message: Unknown error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 20, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/lovelace/__init__.py", line 196, in send_with_error_handling
result = await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/lovelace/__init__.py", line 221, in websocket_lovelace_config
return await hass.data[DOMAIN].async_load(msg["force"])
File "/usr/src/homeassistant/homeassistant/components/lovelace/__init__.py", line 154, in async_load
self._load_config, force
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/lovelace/__init__.py", line 173, in _load_config
config = load_yaml(fname)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 62, in load_yaml
return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict()
File "/usr/local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 43, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 47, in construct_document
data = self.construct_object(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 227, in _construct_seq
(obj,) = loader.construct_yaml_seq(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 400, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in construct_sequence
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in <listcomp>
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 54, in _include_yaml
return loader._add_reference(load_yaml(fname, args), ldr, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 37, in load_yaml
return loader.yaml.load(config_file, Loader=loader.SafeLineLoader) or OrderedDict()
File "/usr/local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 43, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 47, in construct_document
data = self.construct_object(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 227, in _construct_seq
(obj,) = loader.construct_yaml_seq(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 400, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in construct_sequence
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in <listcomp>
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 54, in _include_yaml
return loader._add_reference(load_yaml(fname, args), ldr, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 37, in load_yaml
return loader.yaml.load(config_file, Loader=loader.SafeLineLoader) or OrderedDict()
File "/usr/local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 43, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 47, in construct_document
data = self.construct_object(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 227, in _construct_seq
(obj,) = loader.construct_yaml_seq(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 400, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in construct_sequence
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in <listcomp>
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 54, in _include_yaml
return loader._add_reference(load_yaml(fname, args), ldr, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 37, in load_yaml
return loader.yaml.load(config_file, Loader=loader.SafeLineLoader) or OrderedDict()
File "/usr/local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 43, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 47, in construct_document
data = self.construct_object(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 227, in _construct_seq
(obj,) = loader.construct_yaml_seq(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 400, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in construct_sequence
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in <listcomp>
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 227, in _construct_seq
(obj,) = loader.construct_yaml_seq(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 400, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in construct_sequence
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in <listcomp>
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 196, in _ordered_dict
nodes = loader.construct_pairs(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 147, in construct_pairs
value = self.construct_object(value_node, deep=deep)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 227, in _construct_seq
(obj,) = loader.construct_yaml_seq(node)
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 400, in construct_yaml_seq
data.extend(self.construct_sequence(node))
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in construct_sequence
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 122, in <listcomp>
for child in node.value]
File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object
data = constructor(self, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 54, in _include_yaml
return loader._add_reference(load_yaml(fname, args), ldr, node)
File "/config/custom_components/lovelace_gen/__init__.py", line 32, in load_yaml
stream = io.StringIO(jinja.get_template(fname).render({**args, "_global": llgen_config}))
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/config/lovelace/includes_garden/item_zone_duration_line.yaml", line 52, in top-level template code
{% if states('timer.irrigation_zone1_timer') == 'idle' %}
jinja2.exceptions.UndefinedError: 'states' is undefined