From 8fa1a081cbf16edd027e77704ac14ce5d483e96d Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Tue, 14 Sep 2021 21:56:04 +0200 Subject: [PATCH] Converted enable_persistent and disable_telegram into boolean --- automations/energy.yaml | 2 +- automations/update_notifications.yaml | 6 +-- packages/alarm/alarm_notifications.yaml | 6 +-- scripts/notify.yaml | 58 ++++++++----------------- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/automations/energy.yaml b/automations/energy.yaml index 77ba6118..118c927e 100644 --- a/automations/energy.yaml +++ b/automations/energy.yaml @@ -14,5 +14,5 @@ data_template: title: "Home Assistant - Allarme Consumo Energetico" message: "Consumo energetico elevato ({{ states.sensor.shelly_em_channel_1_power.state }})." - enable_persistent: 0 + enable_persistent: false volume_level: 0.4 diff --git a/automations/update_notifications.yaml b/automations/update_notifications.yaml index f261cb4e..6b491a3d 100644 --- a/automations/update_notifications.yaml +++ b/automations/update_notifications.yaml @@ -24,7 +24,7 @@ title: "Home Assistant - Aggiornamento" message: "E' disponibile un aggiornamento per Home Assistant {{ state_attr('binary_sensor.updater', 'newest_version') }}. {{now().strftime('%Y-%m-%d %I:%M %p')}}" notification_id: "update" - enable_persistent: 1 + enable_persistent: true - service: input_boolean.turn_on entity_id: input_boolean.update_homeassistant @@ -61,7 +61,7 @@ {% endif %} {%- endfor %} notification_id: "update" - enable_persistent: 1 + enable_persistent: true - service: input_boolean.turn_on entity_id: input_boolean.update_shelly @@ -101,7 +101,7 @@ - {{ update['display_name'] }}: {{ update['available_version'] }} {%- endfor %} notification_id: "update" - enable_persistent: 1 + enable_persistent: true - service: input_boolean.turn_on entity_id: input_boolean.update_hacs diff --git a/packages/alarm/alarm_notifications.yaml b/packages/alarm/alarm_notifications.yaml index 9c1394ed..e409d672 100644 --- a/packages/alarm/alarm_notifications.yaml +++ b/packages/alarm/alarm_notifications.yaml @@ -2,7 +2,7 @@ # Alarm Package - Notifications Scripts ###################################################################### -script: +script: ###################################################################### # Alarm: Start Alarm Sound # @@ -59,7 +59,7 @@ script: alias: "Allarmi: Attiva Allarme" sequence: - service: input_boolean.turn_on - data_template: + data_template: entity_id: > {# Check Null Input #} {% if entity_id | length == 0 %} @@ -92,7 +92,7 @@ script: {% set message = state_attr(entity_id, 'friendly_name') %} {% endif %} {{ message }} - enable_persistent: 1 + enable_persistent: true notification_id: "alarm" # LEVEL 2 diff --git a/scripts/notify.yaml b/scripts/notify.yaml index 17007d19..de099c6e 100644 --- a/scripts/notify.yaml +++ b/scripts/notify.yaml @@ -35,13 +35,13 @@ notify_text: enable_persistent: >- {# Check Null Input #} {% if enable_persistent | length == 0 %} - {% set enable_persistent = 0 %} + {% set enable_persistent = false %} {% endif %} {{ enable_persistent }} disable_telegram: >- {# Check Null Input #} {% if disable_telegram | length == 0 %} - {% set disable_telegram = 0 %} + {% set disable_telegram = false %} {% endif %} {{ disable_telegram }} @@ -64,22 +64,16 @@ notify_text: text: enable_persistent: description: "Abilitare o meno la persistenza" - example: "0" - default: "0" + example: "false" + default: false selector: - select: - options: - - "0" - - "1" + boolean: disable_telegram: description: "Disabilitare la notifica su telegram" - example: "0" - default: "0" + example: "false" + default: false selector: - select: - options: - - "0" - - "1" + boolean: sequence: - condition: state @@ -94,12 +88,7 @@ notify_text: - choose: - conditions: - condition: template - value_template: > - {% if disable_telegram | int == 1 %} - false - {% else %} - true - {% endif %} + value_template: "{{ disable_telegram }}" sequence: - service: notify.telegram @@ -113,12 +102,7 @@ notify_text: message: "{{ message }}" - condition: template - value_template: > - {% if enable_persistent | int == 1 %} - true - {% else %} - false - {% endif %} + value_template: "{{ enable_persistent }}" - service: persistent_notification.create data_template: @@ -348,13 +332,13 @@ notify_all: enable_persistent: >- {# Check Null Input #} {% if enable_persistent | length == 0 %} - {% set enable_persistent = 0 %} + {% set enable_persistent = false %} {% endif %} {{ enable_persistent }} disable_telegram: >- {# Check Null Input #} {% if disable_telegram | length == 0 %} - {% set disable_telegram = 0 %} + {% set disable_telegram = false %} {% endif %} {{ disable_telegram }} @@ -402,22 +386,16 @@ notify_all: text: enable_persistent: description: "Abilitare o meno la persistenza" - example: "0" - default: "0" + example: "false" + default: false selector: - select: - options: - - "0" - - "1" + boolean: disable_telegram: description: "Disabilitare la notifica su telegram" - example: "0" - default: "0" + example: "false" + default: false selector: - select: - options: - - "0" - - "1" + boolean: sequence: - service: script.notify_text -- 2.47.3