From: Giorgio Ravera Date: Sun, 29 Mar 2020 10:54:23 +0000 (+0200) Subject: Moved Alarms to a dedicated package X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=283e82de3440620ab44dd347332a6b2a88a4fe82;p=homeassistant.git Moved Alarms to a dedicated package --- diff --git a/automation/alarms.yaml b/automation/alarms.yaml deleted file mode 100644 index a682b90e..00000000 --- a/automation/alarms.yaml +++ /dev/null @@ -1,17 +0,0 @@ -###################################################################### -# Alarm: Aknowledge Alarms -# -# Actions: -# - persistent_notification.dismiss -# - script.stop_alarm -###################################################################### -- alias: "Alarms: Riconoscimento Allarmi" - initial_state: 'on' - - trigger: - platform: state - entity_id: input_boolean.alarms - to: 'off' - - action: - - service: script.stop_alarm diff --git a/binary_sensor/alarms.yaml b/binary_sensor/alarms.yaml deleted file mode 100644 index 09980275..00000000 --- a/binary_sensor/alarms.yaml +++ /dev/null @@ -1,17 +0,0 @@ -###################################################################### -# Binary Sensor: Alarms -###################################################################### - -- platform: template - sensors: - alarms: - friendly_name: Allarmi - entity_id: input_boolean.alarms - value_template: >- - {{ is_state('input_boolean.alarms', 'on') }} - icon_template: >- - {% if is_state('input_boolean.alarms', 'on') %} - mdi:alarm-light - {% else %} - mdi:alarm-light-outline - {% endif %} diff --git a/configuration.yaml b/configuration.yaml index fb7ba1fa..de857c20 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -12,6 +12,8 @@ homeassistant: time_zone: Europe/Rome # Customization folder customize: !include_dir_merge_named customizations/ + # Packages: + packages: !include_dir_named packages/ # Show links to resources in log and frontend # introduction: diff --git a/input_boolean/alarms.yaml b/input_boolean/alarms.yaml deleted file mode 100644 index a6716291..00000000 --- a/input_boolean/alarms.yaml +++ /dev/null @@ -1,8 +0,0 @@ -###################################################################### -# Alarms: Generic -###################################################################### - -alarms: - name: Allarme - icon: mdi:alarm-light-outline - diff --git a/packages/alarms.yaml b/packages/alarms.yaml new file mode 100644 index 00000000..e17fdaaf --- /dev/null +++ b/packages/alarms.yaml @@ -0,0 +1,67 @@ +###################################################################### +# Alarm Package +###################################################################### + +###################################################################### +# Input Booleans +###################################################################### +input_boolean: + +###################################################################### +# Alarms: Generic +###################################################################### + alarms: + name: Allarme + icon: mdi:alarm-light-outline + +###################################################################### +# Alarms: Door +###################################################################### +# door_alarm: +# name: Allarme Porta +# icon: mdi:door-open + +###################################################################### +# Binary Sensors +###################################################################### +binary_sensor: + +###################################################################### +# Alarm Binary Sensor +###################################################################### + - platform: template + sensors: + alarms: + friendly_name: Allarmi + entity_id: input_boolean.alarms + value_template: >- + {{ is_state('input_boolean.alarms', 'on') }} + icon_template: >- + {% if is_state('input_boolean.alarms', 'on') %} + mdi:alarm-light + {% else %} + mdi:alarm-light-outline + {% endif %} + +###################################################################### +# Automations +###################################################################### +automation: + +###################################################################### +# Alarm Automation: Aknowledge Alarms +# +# Actions: +# - persistent_notification.dismiss +# - script.stop_alarm +###################################################################### + - alias: "Alarms: Riconoscimento Allarmi" + initial_state: 'on' + + trigger: + platform: state + entity_id: input_boolean.alarms + to: 'off' + + action: + - service: script.stop_alarm \ No newline at end of file diff --git a/packages/alarms_scripts.yaml b/packages/alarms_scripts.yaml new file mode 100644 index 00000000..d06babf4 --- /dev/null +++ b/packages/alarms_scripts.yaml @@ -0,0 +1,172 @@ +###################################################################### +# Alarm Script Package +###################################################################### + +###################################################################### +# Scripts +###################################################################### +script: + +###################################################################### +# Alarm: Start Alarm Sound +# +# Operations: +# - media_player.volume_set +# - media_player.play_media +###################################################################### + + start_alarm_sound: + alias: "Allarmi: Avvia Suono" + sequence: + - service: media_player.volume_set + data_template: + entity_id: 'media_player.google_home' + volume_level: 0.4 + + - service: media_player.play_media + data_template: + entity_id: 'media_player.google_home' + media_content_type: 'audio/mp4' + media_content_id: 'https://home.giorgioravera.it/local/audio/alarm.mp3' + +###################################################################### +# Alarm: Stop Alarm Sound +# +# Operations: +# - media_player.media_stop +# - script.volume_manager +###################################################################### + + stop_alarm_sound: + alias: "Allarmi: Interrompi Suono" + sequence: + - service: media_player.media_stop + data_template: + entity_id: 'media_player.google_home' + + - service: script.volume_manager + data_template: + media_player: 'media_player.google_home' + +###################################################################### +# Alarm: Start Alarm Level 1 +# Inputs: +# - title +# - message +# +# Operations: +# - script.notify_text +###################################################################### + + start_alarm_level_1: + alias: "Allarmi: Attiva Allarme 1" + sequence: + + - condition: template + value_template: >- + {# Check Null Input #} + {% if level | length == 0 %} + {% set level = 1 %} + {% endif %} + {% if level | int >= 1 %} + true + {% else %} + false + {% endif %} + + - service: script.notify_all + data_template: + volume_level: 0.4 + language: 'it' + title: >- + {# Check Null Input #} + {% if title | length == 0 %} + {% set title = 'Allarme Generico' %} + {% endif %} + Home Assistant - {{ title }} + message: >- + {# Check Null Input #} + {% if message | length == 0 %} + {% set message = 'Allarme Generico' %} + {% endif %} + {{ message }} + enable_persistent: 1 + notification_id: "alarm" + +###################################################################### +# Alarm: Start Alarm Level 2 +# Inputs: +# - level +# +# Operations: +# - start_alarm_sound +###################################################################### + + start_alarm_level_2: + alias: "Allarmi: Attiva Allarme 2" + sequence: + + - condition: template + value_template: >- + {# Check Null Input #} + {% if level | length == 0 %} + {% set level = 1 %} + {% endif %} + {% if level | int >= 2 %} + true + {% else %} + false + {% endif %} + + - service: script.start_alarm_sound + +###################################################################### +# Alarm: Start Alarm +# Inputs: +# - title +# - message +# - level +# +# Operations: +# - input_boolean.turn_on +# - script.start_alarm_level_1 +# - script.start_alarm_level_2 +###################################################################### + + start_alarm: + alias: "Allarmi: Attiva Allarme" + sequence: + - service: input_boolean.turn_on + entity_id: input_boolean.alarms + + - service: script.start_alarm_level_1 + data_template: + title: "{{ title }}" + message: "{{ message }}" + level: "{{ level }}" + + - service: script.start_alarm_level_2 + data_template: + title: "{{ title }}" + message: "{{ message }}" + level: "{{ level }}" + +###################################################################### +# Alarm: Stop Alarm +# +# Operations: +# - stop_alarm_sound +# - persistent_notification.dismiss +###################################################################### + + stop_alarm: + alias: "Allarmi: Disattiva Allarme" + sequence: + - service: input_boolean.turn_off + entity_id: input_boolean.alarms + + - service: script.stop_alarm_sound + + - service: persistent_notification.dismiss + data_template: + notification_id: "alarm" diff --git a/script/alarms.yaml b/script/alarms.yaml deleted file mode 100644 index e59a6508..00000000 --- a/script/alarms.yaml +++ /dev/null @@ -1,163 +0,0 @@ -###################################################################### -# Alarm: Start Alarm Sound -# -# Operations: -# - media_player.volume_set -# - media_player.play_media -###################################################################### - -start_alarm_sound: - alias: "Allarmi: Avvia Suono" - sequence: - - service: media_player.volume_set - data_template: - entity_id: 'media_player.google_home' - volume_level: 0.4 - - - service: media_player.play_media - data_template: - entity_id: 'media_player.google_home' - media_content_type: 'audio/mp4' - media_content_id: 'https://home.giorgioravera.it/local/audio/alarm.mp3' - -###################################################################### -# Alarm: Stop Alarm Sound -# -# Operations: -# - media_player.media_stop -# - script.volume_manager -###################################################################### - -stop_alarm_sound: - alias: "Allarmi: Interrompi Suono" - sequence: - - service: media_player.media_stop - data_template: - entity_id: 'media_player.google_home' - - - service: script.volume_manager - data_template: - media_player: 'media_player.google_home' - -###################################################################### -# Alarm: Start Alarm Level 1 -# Inputs: -# - title -# - message -# -# Operations: -# - script.notify_text -###################################################################### - -start_alarm_level_1: - alias: "Allarmi: Attiva Allarme 1" - sequence: - - - condition: template - value_template: >- - {# Check Null Input #} - {% if level | length == 0 %} - {% set level = 1 %} - {% endif %} - {% if level | int >= 1 %} - true - {% else %} - false - {% endif %} - - - service: script.notify_all - data_template: - volume_level: 0.4 - language: 'it' - title: >- - {# Check Null Input #} - {% if title | length == 0 %} - {% set title = 'Allarme Generico' %} - {% endif %} - Home Assistant - {{ title }} - message: >- - {# Check Null Input #} - {% if message | length == 0 %} - {% set message = 'Allarme Generico' %} - {% endif %} - {{ message }} - enable_persistent: 1 - notification_id: "alarm" - -###################################################################### -# Alarm: Start Alarm Level 2 -# Inputs: -# - level -# -# Operations: -# - start_alarm_sound -###################################################################### - -start_alarm_level_2: - alias: "Allarmi: Attiva Allarme 2" - sequence: - - - condition: template - value_template: >- - {# Check Null Input #} - {% if level | length == 0 %} - {% set level = 1 %} - {% endif %} - {% if level | int >= 2 %} - true - {% else %} - false - {% endif %} - - - service: script.start_alarm_sound - -###################################################################### -# Alarm: Start Alarm -# Inputs: -# - title -# - message -# - level -# -# Operations: -# - input_boolean.turn_on -# - script.start_alarm_level_1 -# - script.start_alarm_level_2 -###################################################################### - -start_alarm: - alias: "Allarmi: Attiva Allarme" - sequence: - - service: input_boolean.turn_on - entity_id: input_boolean.alarms - - - service: script.start_alarm_level_1 - data_template: - title: "{{ title }}" - message: "{{ message }}" - level: "{{ level }}" - - - service: script.start_alarm_level_2 - data_template: - title: "{{ title }}" - message: "{{ message }}" - level: "{{ level }}" - -###################################################################### -# Alarm: Stop Alarm -# -# Operations: -# - stop_alarm_sound -# - persistent_notification.dismiss -###################################################################### - -stop_alarm: - alias: "Allarmi: Disattiva Allarme" - sequence: - - service: input_boolean.turn_off - entity_id: input_boolean.alarms - - - service: script.stop_alarm_sound - - - service: persistent_notification.dismiss - data_template: - notification_id: "alarm" \ No newline at end of file