stepsolar
(Stepsolar)
December 16, 2025, 5:16pm
1
Hi everyone, I’m creating a blueprint. I’m contacting you because I can’t write this code properly. I always get the following error:
Errore: Error rendering data template: TemplateError: Invalid domain name ‘{{ !input trigger_state_entity }}’
{{ (as_timestamp(now()) - as_timestamp(states["{{ !input trigger_state_entity }}"].last_changed | default(0)) | int ) | timestamp_custom("%H:%M:%S", false) }}
variables:
trigger_state_entity: !input trigger_state_entity
How could I do that?
Thanks
When you gather data in a blueprint using !inputs, you will need to use that data in the lower parts of the blueprint. All the native Home Assistant places accept the
!input my_data
format for this.
If you are using the value in a template, however, this does not work.
The code inside of the template brackets is all rendered by a jinja2 template engine, not Home Assistant. That engine does not know what the !input tag is. That is looking for a variable.
Therefore in order for template engin…
There are multiple issues…
Don’t nest templates, just use the variable directly.
Don’t use !input inside templates. Define a variable and use that variable.
{{ (as_timestamp(now()) - as_timestamp(states[trigger_state_entity].last_changed | default(0)) | int ) | timestamp_custom("%H:%M:%S", false) }}
2 Likes
stepsolar
(Stepsolar)
December 16, 2025, 5:41pm
3
Thank you so much, it works.
1 Like
stepsolar
(Stepsolar)
December 19, 2025, 1:15pm
4
Hi,
I’m having the same problem again. I’ve tried several things, but I can’t find a solution. How can I fix it?
variables:
holiday_calendar_entity: !input holiday_calendar_entity
{% if is_state('[holiday_calendar_entity]'), 'off') %}
{% else %}
{{ state_attr('[holiday_calendar_entity]'), 'message') }}
{% endif %}
stepsolar
(Stepsolar)
December 19, 2025, 3:43pm
5
I wrote it this way too, but no result comes out
{% if is_state[holiday_calendar_entity], 'off' %}
{% else %}
{{ state_attr[holiday_calendar_entity], 'message' }}
{% endif %}
it only works this way
{% if is_state('calendar.example', 'off') %}
{% else %}
{{ state_attr('calendar.example','message') }}
{% endif %}
123
(Taras)
December 19, 2025, 4:08pm
6
It’s is_state() and state_attr() so you use parentheses like this:
{% if is_state(holiday_calendar_entity, 'off') %}
{% else %}
{{ state_attr(holiday_calendar_entity, 'message') }}
{% endif %}
holiday_calendar_entity is a variable’s name, representing an entity_id, so it is entered as-is (without wrapping it in square brackets and/or quotes, like you did in your examples).
1 Like
stepsolar
(Stepsolar)
December 19, 2025, 4:50pm
7
Thank you so much, it works.