WTH is home-assistant.log sometimes so cryptic? Especially with errors in templates, you have to search the corresponding entity_id!

Who is not familiar with it - sometimes you have to clean up. And sometimes you even clean up the errors in the HA log. I have the problem here that the error messages do not contain any information about the corresponding entity_id of the (binary_)sensor, the corresponding automation or wherever the template is. Is this information not available when the error occurs? Couldn’t the information about the entity_id/automation/… be output at a prominent place in the error message (at the beginning)? That would be very pleasant!

2022-10-07 00:18:30.796 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.WHATEVER')|float < states('input_number.WHATEVER')|float}}' but no default was specified') while processing template 'Template("{{ states('sensor.WHATEVER')|float < states('input_number.WHATSOEVER')|float}}")' for attribute '_state' in entity 'binary_sensor.WHATEVER'
2022-10-07 00:18:31.404 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'start_time' when rendering 

Another example I would like to add are jinja logical errors like this but I’m not sure which template is failing.

A file and line number would be useful.

It’s the first if statements template in a script. Yaml if statement.

@j3mu5 It tells you the template and the entity_id, but the entity_id is at the end. So the information you want is there, you just gotta read the whole thing.

Hi @petro

I use packages so would the first if statement apply to any one of those files?

Yes but you can narrow it down to templates that compare 2 things using a > sign

Thank you for your help.

FYI I gathered that all from the error. While it doesn’t say the script it’s in (‘might not be possible). It does give context about the script. If[0] tells you it’s an if statement condition. It also tells you it’s the first condition in that if statement because of the word condition and the zero inside the brackets. If it was the second condition, it would have a 1 in the brackets, and 2 if it was the 3rd.

I would like to see a clickable link back to the yaml file containing the error that the checker found. Often in my logs there is not enough information for me to know which file is causing the error.
Below are two examples of the configuration checker finding errors but no indication of the file location where the wig dominates from…

Logger: homeassistant.config
Source: config.py:455
First occurred: 08:22:32 (6 occurrences)
Last logged: 08:30:10

Invalid config for [automation]: [sensor] is an invalid option for [automation]. Check: automation->sensor. (See ?, line ?).

I wish these errors would be auto-reported…