Oh great @sheminasalam ! I was trying to use (with a little success, yeah) some variables into the template, but yours is more clean. BTW A question. In your example, the output goes on a single line. If I try to put all in a list, it has empty spaces where the contact is closed. How avoid? The script is working btw.
Here what I mean:
Template example:
Following doors are open:
{% if is_state('binary_sensor.0x00158d00047e76e4_contact', 'on') %}- Studio Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d000477376f_contact', 'on') %}- Studio Porta Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047d6600_contact', 'on') %}- Porta ingresso{% endif %}
{% if is_state('binary_sensor.0x00158d00047d65df_contact', 'on') %}- Soggiorno Porta Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d0004a0257c_contact', 'on') %}- Cucina Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047d65fc_contact', 'on') %}- Bagno Doccia Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d0004521ef0_contact', 'on') %}- Bagno Vasca Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00049fd978_contact', 'on') %}- Camera Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047e9d51_contact', 'on') %}- Camera Porta Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047ebb8e_contact', 'on') %}- Stanza di Giulia Porta Finestra{% endif %}
Output, considering two sensors open
Following doors are open:
- Bagno Doccia Finestra
- Bagno Vasca Finestra
Expected:
Following doors are open:
- Bagno Doccia Finestra
- Bagno Vasca Finestra
how to format?
In addition, trying the whole script, it is not editable in the GUI and the output of the open sensors gets empty. Something is not executed
allarme_verifica_portefinestre:
alias: Allarme Verifica stato sensori Porte e Finestre
sequence:
- choose:
- conditions:
- condition: state
entity_id: group.all_door_entities
state: 'on'
sequence:
- service: notify.xefilbot
data:
title: '*Avviso Porte/Finestre Aperte*'
message: >-
Le seguenti porta/finestre sono aperte:
{% if is_state('binary_sensor.0x00158d00047e76e4_contact', 'on') %}- Studio Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d000477376f_contact', 'on') %}- Studio Porta Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047d6600_contact', 'on') %}- Porta ingresso{% endif %}
{% if is_state('binary_sensor.0x00158d00047d65df_contact', 'on') %}- Soggiorno Porta Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d0004a0257c_contact', 'on') %}- Cucina Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047d65fc_contact', 'on') %}- Bagno Doccia Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d0004521ef0_contact', 'on') %}- Bagno Vasca Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00049fd978_contact', 'on') %}- Camera Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047e9d51_contact', 'on') %}- Camera Porta Finestra{% endif %}
{% if is_state('binary_sensor.0x00158d00047ebb8e_contact', 'on') %}- Stanza Porta Finestra{% endif %}
- conditions:
- condition: state
entity_id: group.all_door_entities
state: 'off'
sequence:
- service: notify.xefilbot
data:
title: '*Avviso Porte/Finestre Aperte*'
message: Tutte le Porte/Finestre sono chiuse
default: []
mode: single
And last but not least, where to buy you a beer/the/coffee??
Simon