# - volume_level\r
# - message\r
# - enable_greeting\r
+# - enable_status\r
#\r
# Operations:\r
# - script.notify_voice (greeting + message)\r
media_player: "{{ media_player }}"\r
volume_level: "{{ volume_level }}"\r
language: "{{ language }}"\r
- message: >-\r
- {# greeting message #}\r
- {% if enable_greeting | length != 0 %}\r
- {% if enable_greeting | int == 1 %}\r
- {% if now().strftime('%H')|int >= 7 and now().strftime('%H')|int < 12 %}\r
- Buongiorno.\r
- {% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}\r
- Buonpomeriggio.\r
- {% elif now().strftime('%H')|int >= 17 and now().strftime('%H')|int < 23 %}\r
- Buonasera.\r
+ message: >- \r
+ {# *********************************************** #}\r
+ {# ******************** Macro ******************** #}\r
+ {# *********************************************** #}\r
+ \r
+ {# Greeting Message #}\r
+ {%- macro greeting() -%}\r
+ {% if now().strftime('%H')|int >= 7 and now().strftime('%H')|int < 12 %}\r
+ Buongiorno.\r
+ {% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}\r
+ Buonpomeriggio.\r
+ {% elif now().strftime('%H')|int >= 17 and now().strftime('%H')|int < 23 %}\r
+ Buonasera.\r
+ {% else %}\r
+ Buonanotte.\r
+ {% endif %}\r
+ {%- endmacro -%}\r
+ \r
+ {# Cover Status #}\r
+ {%- macro status_cover() -%}\r
+ {% for entity_id in states.group.covers.attributes.entity_id %}\r
+ {% set name = entity_id.split('.')[1]|replace('_', ' ') %}\r
+ {% set perc = states(entity_id) %}\r
+ {% if perc | int < 25 %}\r
+ La {{ name }} è chiusa.\r
{% else %}\r
- Buonanotte.\r
+ La {{ name }} è aperta al {{ perc }} percento.\r
{% endif %}\r
+ {%- endfor %}\r
+ {%- endmacro -%}\r
+ \r
+ {# *********************************************** #}\r
+ {# ******************* Message ******************* #}\r
+ {# *********************************************** #}\r
+ \r
+ {# Greeting Message #}\r
+ {% if enable_greeting is defined %}\r
+ {% if enable_greeting | int == 1 %}\r
+ {{ greeting() }}\r
{% endif %}\r
{% endif %}\r
\r
+ {% if enable_status is defined %}\r
+ {% if enable_status | int == 1 %}\r
+ {{ status_cover() }}\r
+ {% endif %}\r
+ {% endif %}\r
+\r
{# generic message #}\r
{{ message }}\r