From 7acf827562ce712c128f250d8792e7ca62682dee Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 31 May 2022 04:23:34 -0400 Subject: [PATCH] Implementing lightning alerts --- packages/custom_weather.yaml | 16 +++++++------- packages/weatheralerts.yaml | 43 ++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 34eb75a..317348d 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -805,14 +805,14 @@ sensor: previous_rainfall: friendly_name: "Past 48h Rainfall" value_template: "{{ states('sensor.daily_rainfall_in') | float + state_attr('sensor.daily_rainfall_in', 'last_period') | float }}" - # lightning_warning: - # friendly_name: "Lightning Warning" - # value_template: >- - # {%- if states('sensor.recent_lightning_strikes') | int > 0 %} - # Unsafe - # {% else %} - # Safe - # {%- endif %} + lightning_warning: + friendly_name: "Lightning Warning" + value_template: >- + {%- if states('sensor.blitzortung_lightning_counter') | int > 0 %} + Unsafe + {% else %} + Safe + {%- endif %} input_boolean: freeze_warning: diff --git a/packages/weatheralerts.yaml b/packages/weatheralerts.yaml index 865f6e4..0c5c8af 100644 --- a/packages/weatheralerts.yaml +++ b/packages/weatheralerts.yaml @@ -1500,6 +1500,9 @@ automation: entity_id: input_boolean.lightning_warning state: 'off' action: + - service: script.text_notify_all + title: "Lightning Detected!" + message: "Lightning has been detected within 20 miles of the house. Nearest storm is {{ states('sensor.blitzortung_lightning_distance') }} miles away." - service: input_boolean.turn_on entity_id: input_boolean.lightning_warning - service: script.lightning_warning_audible @@ -1510,8 +1513,6 @@ automation: - platform: state entity_id: sensor.lightning_warning to: 'Safe' - for: - minutes: 20 condition: - condition: state entity_id: input_boolean.lightning_warning @@ -1538,6 +1539,44 @@ automation: ## script ## script: + lightning_warning_audible: + sequence: + - condition: state + entity_id: binary_sensor.day + state: 'on' + - service: script.status_annc + data_template: + who: 'living_room' + call_interuption: 1 + speech_message: >- +

+ {{ [ + 'I have detected lightning withing 20 miles of the house.', + 'Did you see that flash? I did. Lightning is near.', + 'If you didnt hear the thunder you will soon. ' + ]|random }} + If anyone is outside they should seek shelter inside. +

+ + lightning_clear_audible: + sequence: + - condition: state + entity_id: binary_sensor.day + state: 'on' + - service: script.status_annc + data_template: + who: 'living_room' + call_interuption: 1 + speech_message: >- +

+ {{ [ + 'Lightning threat appears to be over.', + 'No more lightning appears to be occuring.', + 'Lightning is gone.' + ]|random }} + It is safe to resume normal activities. +

+ ## Script creates UI notification and is called via automation defined above weatheralerts_popup_on_wx_alert: alias: Weather Alert Pop Up - 1