Closed kaechele closed 4 months ago
I'm having the same issue running version 1.4 with Home Assistant 2024.2.1.
Have uninstalled the add on and reinstalled, multiple restarts and the problem remains.
can confirm most templates to no longer work (if the config.entity is called?), all report None or undefined.in the logger
downgrading works 100% perfect, so templates are ok.
Logger: homeassistant.helpers.event
Source: helpers/template.py:574
First occurred: 08:43:02 (20 occurrences)
Last logged: 09:00:17
Error while processing template: Template<template=({% if states[config.entity] is not none %} {% set id = state_attr(config.entity,'friename').split('hygro')[0] %} {{id}} {% else %} Initialiseren {% endif %}) renders=6>
Error while processing template: Template<template=({% if states[config.entity] is not none %} {% set id = state_attr(config.entity,'friname').split('hygro')[0] %} {{id}} {% else %} Initialiseren {% endif %}) renders=6>
Error while processing template: Template<template=({% if states[config.entity] is not none %} {% set id = state_attr(config.entity,'frname').split('hygro')[0] %} {{id}} {% else %} Initialiseren {% endif %}) renders=6>
Error while processing template: Template<template=({% if states[config.entity] is not none %} {% set id = state_attr(config.entity,'fname').split('hygro')[0] %} {{id}} {% else %} Initialiseren {% endif %}) renders=6>
Error while processing template: Template<template=({% if states[config.entity] is not none %} {% set id = state_attr(config.entity,'name').split('hygro')[0] %} {{id}} {% else %} Initialiseren {% endif %}) renders=6>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 572, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2332, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 7, in top-level template code
jinja2.exceptions.UndefinedError: 'id' is undefined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 698, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 574, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'id' is undefined
and yet this secondary:
- type: custom:template-entity-row
entity: binary_sensor.donker_buiten
name: >
Donker buiten (< -4°)
secondary: >
{% if states[config.entity] is not none %}
{{relative_time(states[config.entity].last_changed)}} ago, Elevation:
{{state_attr('sun.sun','elevation')}}
{% else %} Not yet set, Elevation: {{state_attr('sun.sun','elevation')}}
{% endif %}
still works fine. so, it is not that straightforward just yet. Need to find out what was changed specifically, and why this breaks templates, but not all
I also can confirm the jinja templates to still work in dev tools template, and dont show any error at all.
I was not able to reproduce this, but I've tried to fix the only related thing that was changed in 1.4.0.
can confirm the template to show correctly again, thx
Also fixed it for me. Thank you!
1.4.1 works. Thanks!
Somehow templates stopped rendering in my card after updating to 1.4.0 today. Everything works fine after a downgrade to 1.3.2.
Here's what it should look like:![image](https://github.com/thomasloven/lovelace-template-entity-row/assets/454490/34b0e429-b7e9-469b-9b7d-f7e664aa0fde)
This is what it looks like with 1.4.0:![image](https://github.com/thomasloven/lovelace-template-entity-row/assets/454490/ed4ecb90-04d1-435c-b2d7-8cc1526124a0)
Card YAML