I would like to build an Alexa intent to give the number of windows opened. I can’t find the way yo increment a variable in a template. I am using “set counter = counter +1”. It seems to work for the first one but as soon as I add another one, I have an error.
The script is below:
CheckWindows:
speech:
text: >
{% set counter = 0 %}
{% set counter = counter + 1 if is_state("binary_sensor.dining_room_window", "on") %}
{% set counter = counter + 1 if is_state("binary_sensor.kitchen_window", "on") %}
{% if int(counter) > 0 %}
{{ counter }} windows opened
{% else %}
No windows opened
{% endif %}
card:
type: simple
title: Windows check
content: >
Windows opened