Strange template error in logs

Hi there,

with the new 2025.04 beta (maybe even before. Don’t exactly know…) my log gets spammed with the following error.
The mentioned entity does not exist any more and I don’t know how to find the source for this issue and how to fix it.
Any ideas?

2025-03-29 10:45:08.306 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{ states('sensor.temperatur_bad_temperature')|float}}°C) renders=42>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2385, in forgiving_float_filter
    return float(value)
ValueError: could not convert string to float: 'unknown'

During handling of the above exception, another exception occurred:

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 2904, 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
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2388, in forgiving_float_filter
    raise_no_default("float", value)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1942, in raise_no_default
    raise ValueError(
    ...<2 lines>...
    )
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.temperatur_bad_temperature')|float}}°C' but no default was specified

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: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.temperatur_bad_temperature')|float}}°C' but no default was specified
2025-03-29 10:46:47.537 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'charging' when rendering '{{value_json.charging}}'

What if you click on the pencil in the top right corner of your dashboard, then the 3 dots where the pencil was, then go to Unused entities and see if it’s listed there? You can then see what “Domain” it’s listed under, ie Sensor or Automation.

There are 2 errors in your logs. The first is to do with the float filter in your template because it’s trying to convert the value ‘unknown’ into a float which is not possible. You need to specify a default value for the float. Like this:

{{ states('sensor.temperatur_bad_temperature')|float(default=0) }}°C

The other error is a warning about dict object' has no attribute 'charging suggesting the value_json object does not contain the charging attribute. So modify it to check for the attribute’s existence before rendering the template. Like this:

{{ value_json.charging if 'charging' in value_json else 'Attribute not found' }}

This has nothing to do with the beta release. You just need to correct your templates as mentioned above.

Use float(0) inside your template code and it will be gone.

But that’s the problem:
I am not aware of any templates that I created and I don’t find any.
Where do I have to look?

I did what you suggested, but the entity is neither mentioned under unused entities nor within the raw config of the dashboard.

The entity is gone, that is why the state is unknown. But the entity was used somewhere in a template, and maybe you forgot about that. The proposed change to it will help prevent the error, but since the entity does not exist anymore, the whole template entity is most likely useless anyway.

The easies way to find it is installing the spook integration and the watchman integration. Both complement each other. Spook is best for finding problems with UI created things, Watchman checks yaml files.

Do you have a templates.yaml file located in the same folder as your configuration.yaml? If so did you check that templates file?

Thank you for so suggestions so far.
Spook and Watchman find a few issues but unfortunately nothing related to this entity sensor.temperatur_bad_temperature.

I just did a full text search through all files located in the config directory and got nothing in regards to “sensor.temperatur_bad_temperature”.

Very strange… It has to be somewhere.

Have you tried searching your helpers?