Can't get custom template files to work?

I am trying to use a custom template file but the Developer Tools is telling me it can’t find it
(TemplateNotFound: tools.jinja)

• I am running 20240306.0
• I run HA in a docker and don’t use HACS.
• I created the folder myself - the permissions look the same as other folders under config
• I’ve tried multiple filenames from different examples - all with the same result
• I have restarted HA and restarted the docker container - still no change

It must be something obvious I am doing wrong. Can anyone enlighten me?

It’s not an edge case on the file name nor the macro name. I created /config/custom_templates/tools.jinja as:

% macro answer_question(entity_id) %}
{{ states(entity_id }}
{% endmacro %}

Note the missing bracket in the states() call. I then called the homeassistant.reload_custom_templates service, and used it in a template. It returned TemplateSyntaxError, so it read the file and found the “error”.

I then fixed the error, and:

Do your other macro files work or is it just tools.jinja?

I’m also on docker: the files in the folder (when viewed from an attached shell) are all owned by 1026.users (1026 is my UID on the host machine) and are chmod 777 (rwxrwxrwx) — the same as configuration.yaml.

Thanks @Troon

I was glad to hear you use Docker as well to eliminate that as being the problem.

Your comment on the chmod permissions got me investigating and I managed to fix my issue this morning. My os was showing the filename as “tools.jinja” but it was actually “tools.jinja.txt” and hiding the real extension. Doh! Fixed now and working. Thank you!

1 Like