Hello the world of automation enthusiasts,
I’m doing more and more complex automations, especially since the editor is more clear.
But I’d like to put comments in some of my templates, as they are becoming really complex.
Is there a way in the Jinja2 to do comments, like in this template:
{% if (now().isoweekday() in [6, 7])
or (as_timestamp(now()) + (24*3600)) | timestamp_custom('%Y-%m-%d 00:00:00', True) == state_attr('calendar.conges_scolaires','start_time')
or ( (states('calendar.conges_scolaires') == 'on')
and (as_timestamp(now())) | timestamp_custom('%Y-%m-%d 00:00:00', True) != state_attr('calendar.conges_scolaires','end_time')
)
or (as_timestamp(now()) + (24*3600)) | timestamp_custom('%Y-%m-%d 00:00:00', True) == state_attr('calendar.jours_feries_en_belgique','start_time')
or ( (states('calendar.jours_feries_en_belgique') == 'on')
and (as_timestamp(now())) | timestamp_custom('%Y-%m-%d 00:00:00', True) != state_attr('calendar.jours_feries_en_belgique','end_time')
)
%}
set offset=1
{% endif %}
I know that I can put
{# Some comment in Jinja2 #}
But in the massive condition, I’d like to add comment on each line like
{% if (now().isoweekday() in [5, 6]) {# Sat, Sun #}
or (as_timestamp(now()) + (24*3600)) | timestamp_custom('%Y-%m-%d 00:00:00', True) == state_attr('calendar.conges_scolaires','start_time') {# Tomorrow is a school holiday #}
or ( (states('calendar.conges_scolaires') == 'on') {# Today is a school holiday... #}
and (as_timestamp(now())) | timestamp_custom('%Y-%m-%d 00:00:00', True) != state_attr('calendar.conges_scolaires','end_time') {# ... and there is no school tomorrow #}
)
or (as_timestamp(now()) + (24*3600)) | timestamp_custom('%Y-%m-%d 00:00:00', True) == state_attr('calendar.jours_feries_en_belgique','start_time') {# Tomorrow is a public holiday #}
or ( (states('calendar.jours_feries_en_belgique') == 'on') {# Today is a public holiday... #}
and (as_timestamp(now())) | timestamp_custom('%Y-%m-%d 00:00:00', True) != state_attr('calendar.jours_feries_en_belgique','end_time') {# ... and it's not over yet tomorrow #}
)
%}
Which is not working
Is there a way?