Hi,
Yet another post on an error log, I have found several similar entries and tried their solutions, but I cannot find the root cause. I keep getting errors in the log every time the entity changes, apparently due to use of state(") in a template. I have not used state anywhere (only states). I don't know how long this has been going on, so cannot track by recent changes.
I have disabled the various helpers and automations that use the value, but still get the error. I have also disable the emoncms entity that populates the value - but STILL get the errors..
Is there any way to find the module - HA must know where it got the template from, but I cannot see a hint in the logs?
To rub salt into my confusion, the helpers and automations all seem to work happily even with the error message.
Any thoughts to help preserve my sanity gratefully received.
TIA
Kevin
Logger: homeassistant.helpers.event
Source: helpers/template/__init__.py:385
First occurred: 15:19:39 (62 occurrences)
Last logged: 16:45:11
Error while processing template: Template<template=(({{state('sensor.power_emonpi2_ashp_power_1m')}}) renders=220>
Error while processing template: Template<template=(({{state('sensor.power_emonpi2_ashp_power_1m')}}) renders=222>
Error while processing template: Template<template=(({{state('sensor.power_emonpi2_ashp_power_1m')}}) renders=224>
Error while processing template: Template<template=(({{state('sensor.power_emonpi2_ashp_power_1m')}}) renders=226>
Error while processing template: Template<template=(({{state('sensor.power_emonpi2_ashp_power_1m')}}) renders=238>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template/__init__.py", line 383, in async_render
render_result = render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template/context.py", line 43, in render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/jinja2/environment.py", line 942, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.14/site-packages/jinja2/sandbox.py", line 399, in call
if not __self.is_safe_callable(__obj):
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template/__init__.py", line 789, in is_safe_callable
) or super().is_safe_callable(obj)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/usr/local/lib/python3.14/site-packages/jinja2/sandbox.py", line 265, in is_safe_callable
getattr(obj, "unsafe_callable", False) or getattr(obj, "alters_data", False)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'state' 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/__init__.py", line 502, in async_render_to_info
render_info._result = self.async_render( # noqa: SLF001
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
variables, strict=strict, log_fn=log_fn, **kwargs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/template/__init__.py", line 385, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'state' is undefined