Error while processing template:

Hi, recently I started getting these errors in the log and they happen pretty frequently. what could be causing them?

Logger: homeassistant.helpers.event
Source: helpers/template.py:646
First occurred: June 3, 2025 at 12:28:44 (96 occurrences)
Last logged: 09:05:20

Error while processing template: Template<template=({{ value_template }}) renders=372>
Error while processing template: Template<template=({{ value_template }}) renders=378>
Error while processing template: Template<template=({{ value_template }}) renders=380>
Error while processing template: Template<template=({{ value_template }}) renders=386>
Error while processing template: Template<template=({{ value_template }}) renders=388>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 644, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2934, in _render_with_context
    return template.render(**kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
    self.environment.handle_exception()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/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
jinja2.exceptions.UndefinedError: 'value_template' 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 761, 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.py", line 646, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'value_template' is undefined

Someone suggested looking into Lovelace raw log but I could not find anything there that is out of ordinary.

Where do I start looking?

Thank you

Thank you

Hello Joe68,

One of your templates has bad syntax. What were the last template(s) you added? Comment them out one by one until the error goes away.
Not much we can do to help without seeing all your templates here ourselves.

look for that in your configuration file.

I did and I don’t have it in my configuration.yaml

thx

Thanks for your reply… being new in HA… what do you mean by “template”?

Thanks for the info… I’ve searched all the templates/yaml for {{ value_template }} and I have zero results.

ahh… I think I found the culprit… still double checking

Got it

type: custom:gauge-card-pro
entity: sensor.living_room_thermometer_humidity
entity2: sensor.living_room_thermometer_temperature
min: 10
max: 35
needle: true
needle_color: "#bb"
segments:
  - from: 15
    color: blue
  - from: 21
    color: green
  - from: 24
    color: yellow
  - from: 27
    color: orange
  - from: 30
    color: red
gradient: true
gradient_resolution: high
value: "{{ value_template }}"
inner:
  min: 0
  max: 100
  needle_color: blue
  segments:
    - from: 0
      color: green
    - from: 50
      color: yellow
    - from: 65
      color: orange
    - from: 75
      color: red
  gradient: true
  gradient_resolution: high
  value: "{{ value_template }}"
mode: needle
setpoint:
  value: 23
  color: red
titles:
  primary: Living Room Temp
  secondary: Livingroom Humidity
  primary_color: "#aaa"
  secondary_color: "#aaa"
  primary_font_size: 15px
  secondary_font_size: 15px
value_texts:
  primary: "{{ states(entity) }}"
  secondary: "{{ states(entity2) }}"
  primary_color: "#aaa"
  secondary_color: "#aaa"
  primary_unit: C
  secondary_unit: C
  primary_font_size_reduction: 30

That was a curve ball; good catch.

It was in a custom card that supports Jinja2 templates.

Thanks @Sir_Goodenough,

"What were the last template(s) you added? " - I should’ve check this first but somehow slipped my mind :frowning:

@123

Yea… and I was having hard time getting it to work… I guess I didn’t quite make it to work properly … more reading… :slight_smile:

Thank you!

1 Like