Hi all,
I have a very basic question, but Copilot couldn’t help either
I have this test code:
{% set agenda = {"calendar.test":{"events":[{"start":"2024-12-13","end":"2024-12-16","summary":"Christmas Market"},{"start":"2024-12-14","end":"2024-12-16","summary":"Christmas Market New York"},{"start":"2024-12-14T08:00:00+01:00","end":"2024-12-14T18:30:00+01:00","summary":"Christmas Market London","location":"Market Square"},{"start":"2024-12-14T16:00:00+01:00","end":"2024-12-14T18:30:00+01:00","summary":"Christmas Market Berlin"}]}} %}
{% set result = false -%}
{% for event in agenda["calendar.test"]["events"] -%}
{% set EINTRAG = event['summary'] -%}
{% if 'Holidays' in EINTRAG -%}
{% set result = true -%}
{{ 'Holidays: '+EINTRAG -}}
{% elif 'Christmas Market' in EINTRAG -%}
{% set result = true -%}
{{ 'Christmas market: '+EINTRAG+'\n' -}}
{% endif -%}
{% endfor -%}
{{ result }}
Christmas market: Christmas Market
Christmas market: Christmas Market New York
Christmas market: Christmas Market London
Christmas market: Christmas Market Berlin
False
I don’t get it. Whatever I do, I end up with the template evaluating to ‘False’ (this is a string, but if I omit all the debugging messages, it will still evaluate to $false)
What am I missing here?
Update: Script Syntax - Home Assistant.
Huh, so this is expected. But how to dodge this and properly set the variable to $true?