Consider this macro:
{% macro test_macro(input_value) %}
{% set new_value = (input_value | int) * 2 -%}
{{ new_value }}
{% endmacro %}
The macro is stored inside “custom_templates” folder:
And this sensor:
template:
- sensor:
- name: test_using_macro
state: >-
{% from 'test_macro.jinjia' import test_macro -%}
{{ test_macro('123') }}
which gives an error:
2023-04-06 23:46:36.540 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError(‘TemplateNotFound: test_macro.jinja’) while processing template ‘Template<template=({% from ‘test_macro.jinja’ import test_macro -%} {{ test_macro(‘123’) }}) renders=4>’ for attribute ‘_attr_native_value’ in entity ‘sensor.test_using_macro’
Update: found an error - “jinjia” instead of “jinja”, will re-check.
Update: sorry!!! false alarm, works fine.