From fd21e006509c249b539cb60fac736374b48a3e3e Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 6 Jul 2023 02:25:15 -0400 Subject: [PATCH] New speech engine message type for weather alerts #89 --- packages/custom_weather.yaml | 12 ++++++++++ packages/notify.yaml | 7 ++++-- packages/weatheralerts.yaml | 46 +++++++++++++++++------------------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 6e46651..e2172b2 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -131,6 +131,18 @@ template: device_class: safety attributes: current_strikes: "{{ states('sensor.blitzortung_lightning_counter') | int }}" + - name: "Audible Weather Alerts Allowed" + unique_id: 03851823-32d5-44c1-af42-256fcd922069 + state: > + {% if is_state('input_boolean.audible_notifications','on') %} + true + {% elif states('sensor.people_sleeping_total') | int == 3 %} + false + {% elif is_state('input_boolean.kallen_overnight','on') and (states('sensor.people_sleeping_total') | int == 2) %} + false + {% else %} + true + {% endif %} sensor: - platform: weatheralerts diff --git a/packages/notify.yaml b/packages/notify.yaml index b374296..13c45c9 100644 --- a/packages/notify.yaml +++ b/packages/notify.yaml @@ -951,14 +951,15 @@ script: - Salli type: name: 'Type' - description: 'What type of message is this? Can override some settings depending on the option selected. Alert bypasses time restrictions but respects volume settings and sleep mode. Critical bypasses all restrictions, and sets all volumes to max.' + description: 'What type of message is this? Can override some settings depending on the option selected. Alert bypasses time restrictions but respects volume settings and sleep mode. Weather is similar to alert, but will not play at all if everyone is asleep. Critical bypasses all restrictions, and sets all volumes to max.' required: false - example: 'normal, alert, critical' + example: 'normal, alert, weather, critical' selector: select: options: - normal - alert + - weather - critical variables: voice: "{{ states('input_select.jarvis_voice') }}" @@ -998,6 +999,8 @@ script: state: 'on' - condition: template value_template: "{{ type in ['critical','Critical','alert','Alert'] }}" + - condition: template + value_template: "{{ type in ['weather','Weather'] and is_state('binary_sensor.audible_weather_alerts_allowed','on') }}" - condition: state entity_id: group.adults state: 'home' diff --git a/packages/weatheralerts.yaml b/packages/weatheralerts.yaml index a2aad4b..e47e676 100644 --- a/packages/weatheralerts.yaml +++ b/packages/weatheralerts.yaml @@ -1523,6 +1523,7 @@ automation: - service: script.status_annc data: who: everywhere + type: weather call_interruption: 1 call_thunderstorm_warning: 1 - conditions: @@ -1532,6 +1533,7 @@ automation: - service: script.status_annc data: who: everywhere + type: weather call_interruption: 1 call_tornado_watch: 1 - conditions: @@ -1541,6 +1543,7 @@ automation: - service: script.status_annc data: who: everywhere + type: weather call_interruption: 1 call_thunderstorm_watch: 1 - conditions: @@ -1550,6 +1553,7 @@ automation: - service: script.status_annc data: who: everywhere + type: weather call_interruption: 1 call_freeze_warning: 1 - service: input_text.set_value @@ -1614,6 +1618,7 @@ automation: - service: script.speech_engine data: who: everywhere + type: weather message: "It is raining and there are windows open in the house. Please close them!" - wait_template: "{{ is_state('binary_sensor.windows','off') or is_state('sensor.pirateweather_precip','none') }}" timeout: "00:15:00" @@ -1632,6 +1637,7 @@ automation: - service: script.speech_engine data: who: common + type: weather message: "Windows are now closed. Thank you, and enjoy your dry house." - conditions: - condition: template @@ -1646,11 +1652,13 @@ automation: - service: script.speech_engine data: who: common + type: weather message: "Nevermind, it has stopped raining. Feel free to do whatever you'd like with the windows." default: - service: script.speech_engine data: who: common + type: weather message: "Well, I guess no one cares if the house floods. Suit yourself, but do not say I didn't warn you." @@ -1673,8 +1681,8 @@ script: tag: lightning-warning - if: - condition: state - entity_id: input_boolean.master_bedroom_sleeping - state: 'off' + entity_id: binary_sensor.audible_weather_alerts_allowed + state: 'on' then: - service: scene.create data: @@ -1706,17 +1714,12 @@ script: - light.tina_desk_strip data: color_name: red - - if: - - condition: state - entity_id: input_boolean.master_bedroom_sleeping - state: 'off' - then: - - service: script.status_annc - data: - who: 'common' - type: alert - call_interruption: 1 - call_lightning_alert: 1 + - service: script.status_annc + data: + who: common + type: weather + call_interruption: 1 + call_lightning_alert: 1 - delay: seconds: 10 - service: scene.turn_on @@ -1732,17 +1735,12 @@ script: who: all message: clear_notification tag: lightning-warning - - if: - - condition: state - entity_id: input_boolean.master_bedroom_sleeping - state: 'off' - then: - - service: script.status_annc - data: - who: 'common' - type: alert - call_interruption: 1 - call_lightning_clear: 1 + - service: script.status_annc + data: + who: common + type: weather + call_interruption: 1 + call_lightning_clear: 1 - service: script.text_notify data: type: alert