From 3ecdc59c7053e213300f0bad53b19fe2c1488bd5 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 28 Mar 2023 01:08:56 -0400 Subject: [PATCH] Change lightning warning sensor to a binary sensor --- packages/custom_weather.yaml | 18 +++++---------- packages/weatheralerts.yaml | 23 +++++-------------- templates/speech/daily_briefing.yaml | 2 +- templates/speech/kallen_morning_briefing.yaml | 2 +- templates/speech/kallen_nightly_briefing.yaml | 2 +- templates/speech/morning_briefing.yaml | 2 +- templates/speech/nightly_briefing.yaml | 2 +- templates/speech/weather_briefing_full.yaml | 2 +- templates/speech/welcome_home.yaml | 2 +- 9 files changed, 19 insertions(+), 36 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 23d570b..6b3f23d 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -69,6 +69,12 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" threshold: "{{ states('input_number.wind_chill_threshold') | int }}" + - name: "Lightning Warning" + unique_id: edaddfc4-f7f0-4d75-aada-a2c588afe029 + state: "{{ states('sensor.blitzortung_lightning_counter') | int > 0 }}" + device_class: safety + attributes: + current_strikes: "{{ states('sensor.blitzortung_lightning_counter') | int }}" sensor: - platform: weatheralerts @@ -840,15 +846,6 @@ 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" - unique_id: 72bd76a2-ec5b-49fd-982f-ed1ec225514e - value_template: >- - {%- if states('sensor.blitzortung_lightning_counter') | int > 0 %} - Unsafe - {% else %} - Safe - {%- endif %} weather_alert_string: friendly_name: Weather Alert String unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30 @@ -928,9 +925,6 @@ input_boolean: weather_alert_texts: name: Weather Alert Texts icon: mdi:message-processing - lightning_warning: - name: Lightning Warning - icon: mdi:flash-alert tornado_alarm: name: Tornado Alarm icon: mdi:speaker-wireless diff --git a/packages/weatheralerts.yaml b/packages/weatheralerts.yaml index 7e84bfb..76e2cd6 100644 --- a/packages/weatheralerts.yaml +++ b/packages/weatheralerts.yaml @@ -1512,12 +1512,9 @@ automation: alias: Lightning Detected trigger: - platform: state - entity_id: sensor.lightning_warning - to: 'Unsafe' - condition: - - condition: state - entity_id: input_boolean.lightning_warning - state: 'off' + entity_id: binary_sensor.lightning_warning + from: 'off' + to: 'on' action: - service: script.lightning_warning @@ -1526,12 +1523,9 @@ automation: alias: Lightning Warning Off trigger: - platform: state - entity_id: sensor.lightning_warning - to: 'Safe' - condition: - - condition: state - entity_id: input_boolean.lightning_warning - state: 'on' + entity_id: binary_sensor.lightning_warning + from: 'on' + to: 'off' action: - service: script.lightning_clear @@ -1625,9 +1619,6 @@ script: {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} "Lightning has been detected within 20 miles of the house. Nearest storm is {{ ltgdist }} miles away." tag: lightning-warning - - service: input_boolean.turn_on - target: - entity_id: input_boolean.lightning_warning - if: - condition: state entity_id: input_boolean.audible_notifications @@ -1694,8 +1685,6 @@ script: who: 'all' title: "Lightning Clear" message: "The lightning threat has passed. It is safe to resume normal activities." - - service: input_boolean.turn_off - entity_id: input_boolean.lightning_warning ## Script creates UI notification and is called via automation defined above weatheralerts_popup_on_wx_alert: diff --git a/templates/speech/daily_briefing.yaml b/templates/speech/daily_briefing.yaml index 6e04feb..b832b51 100644 --- a/templates/speech/daily_briefing.yaml +++ b/templates/speech/daily_briefing.yaml @@ -41,7 +41,7 @@ "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ", ] | random }} {% endif %} - {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "There are reports of lightning in the area, please stay safe. ", diff --git a/templates/speech/kallen_morning_briefing.yaml b/templates/speech/kallen_morning_briefing.yaml index 71a0a36..7d941d4 100644 --- a/templates/speech/kallen_morning_briefing.yaml +++ b/templates/speech/kallen_morning_briefing.yaml @@ -26,7 +26,7 @@ {% endif %}

- {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "There are reports of lightning in the area, please stay safe. ", diff --git a/templates/speech/kallen_nightly_briefing.yaml b/templates/speech/kallen_nightly_briefing.yaml index 9267343..5e189bc 100644 --- a/templates/speech/kallen_nightly_briefing.yaml +++ b/templates/speech/kallen_nightly_briefing.yaml @@ -101,7 +101,7 @@

- {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "Please ignore that strobing effect in your window. That is mother nature trying to distract you from sleeping. Do not give in! ", diff --git a/templates/speech/morning_briefing.yaml b/templates/speech/morning_briefing.yaml index e11a669..4cadd94 100644 --- a/templates/speech/morning_briefing.yaml +++ b/templates/speech/morning_briefing.yaml @@ -54,7 +54,7 @@ "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ", ] | random }} {% endif %} - {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "There are reports of lightning in the area, please stay safe. ", diff --git a/templates/speech/nightly_briefing.yaml b/templates/speech/nightly_briefing.yaml index f52fd39..b96f38c 100644 --- a/templates/speech/nightly_briefing.yaml +++ b/templates/speech/nightly_briefing.yaml @@ -24,7 +24,7 @@ "Currently there are weather alerts active. The total number of alerts is {{ states('sensor.weather_alerts_active_corrected') }}. They are as follows. " {{ states('sensor.weather_alert_string') }}. {% endif %} - {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "There are reports of lightning in the area, please stay safe. ", diff --git a/templates/speech/weather_briefing_full.yaml b/templates/speech/weather_briefing_full.yaml index da8db4a..04ff65b 100644 --- a/templates/speech/weather_briefing_full.yaml +++ b/templates/speech/weather_briefing_full.yaml @@ -12,7 +12,7 @@ "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ", ] | random }} {% endif %} - {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "There are reports of lightning in the area, please stay safe. ", diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 075ecdc..e6c8083 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -71,7 +71,7 @@ "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ", ] | random }} {% endif %} - {% if is_state('input_boolean.lightning_warning','on') %} + {% if is_state('binary_sensor.lightning_warning','on') %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {{ [ "There are reports of lightning in the area, please stay safe. ",