Hi,
I need to change a variable based on IF statement inside a Script or Automation and at the end do something.
I know that variable is used only inside IF, bu I need to setup variable based on if. It is possible? Here is an example that does not work:
HI @petro ,
thanks for suggestion, I am new on HA.
I can use template, but I need to do a sequence of IF to check all sensor I need to check and send notification containing all open window, example:
- service: notify.pushover
data:
title: Test
message: >
{% if is_state('binary_sensor.xiaomi_contact_abbaino_contact', 'on') %}
Devo Suonare, Abbaino Mansarda
{% else %}
Devo Suonare, Nulla
{% endif %}
{% if is_state('binary_sensor.xiaomi_contact_cucina_contact', 'on') %}
Devo Suonare, Abbaino Mansarda, Cucina
{% else %}
Devo Suonare, Nulla
{% endif %}
So in this case I have even to concatenate variable to add only open contact to notification. Even better will be to iterate in a group and add sensor name to notification list based on its status.
In addition the code: