Change lightning warning sensor to a binary sensor

This commit is contained in:
2023-03-28 01:08:56 -04:00
parent 8b6e9bc31c
commit 3ecdc59c70
9 changed files with 19 additions and 36 deletions

View File

@ -69,6 +69,12 @@ template:
attributes: attributes:
current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" current_temp: "{{ states('sensor.pirateweather_temperature') | int }}"
threshold: "{{ states('input_number.wind_chill_threshold') | 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: sensor:
- platform: weatheralerts - platform: weatheralerts
@ -840,15 +846,6 @@ sensor:
# previous_rainfall: # previous_rainfall:
# friendly_name: "Past 48h Rainfall" # friendly_name: "Past 48h Rainfall"
# value_template: "{{ states('sensor.daily_rainfall_in') | float + state_attr('sensor.daily_rainfall_in', 'last_period') | float }}" # 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: weather_alert_string:
friendly_name: Weather Alert String friendly_name: Weather Alert String
unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30 unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30
@ -928,9 +925,6 @@ input_boolean:
weather_alert_texts: weather_alert_texts:
name: Weather Alert Texts name: Weather Alert Texts
icon: mdi:message-processing icon: mdi:message-processing
lightning_warning:
name: Lightning Warning
icon: mdi:flash-alert
tornado_alarm: tornado_alarm:
name: Tornado Alarm name: Tornado Alarm
icon: mdi:speaker-wireless icon: mdi:speaker-wireless

View File

@ -1512,12 +1512,9 @@ automation:
alias: Lightning Detected alias: Lightning Detected
trigger: trigger:
- platform: state - platform: state
entity_id: sensor.lightning_warning entity_id: binary_sensor.lightning_warning
to: 'Unsafe' from: 'off'
condition: to: 'on'
- condition: state
entity_id: input_boolean.lightning_warning
state: 'off'
action: action:
- service: script.lightning_warning - service: script.lightning_warning
@ -1526,12 +1523,9 @@ automation:
alias: Lightning Warning Off alias: Lightning Warning Off
trigger: trigger:
- platform: state - platform: state
entity_id: sensor.lightning_warning entity_id: binary_sensor.lightning_warning
to: 'Safe' from: 'on'
condition: to: 'off'
- condition: state
entity_id: input_boolean.lightning_warning
state: 'on'
action: action:
- service: script.lightning_clear - service: script.lightning_clear
@ -1625,9 +1619,6 @@ script:
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %} {% 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." "Lightning has been detected within 20 miles of the house. Nearest storm is {{ ltgdist }} miles away."
tag: lightning-warning tag: lightning-warning
- service: input_boolean.turn_on
target:
entity_id: input_boolean.lightning_warning
- if: - if:
- condition: state - condition: state
entity_id: input_boolean.audible_notifications entity_id: input_boolean.audible_notifications
@ -1694,8 +1685,6 @@ script:
who: 'all' who: 'all'
title: "Lightning Clear" title: "Lightning Clear"
message: "The lightning threat has passed. It is safe to resume normal activities." 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 ## Script creates UI notification and is called via automation defined above
weatheralerts_popup_on_wx_alert: weatheralerts_popup_on_wx_alert:

View File

@ -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! ", "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }} ] | random }}
{% endif %} {% 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 %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [ {{ [
"There are reports of lightning in the area, please stay safe. ", "There are reports of lightning in the area, please stay safe. ",

View File

@ -26,7 +26,7 @@
{% endif %} {% endif %}
</p> </p>
<p> <p>
{% 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 %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [ {{ [
"There are reports of lightning in the area, please stay safe. ", "There are reports of lightning in the area, please stay safe. ",

View File

@ -101,7 +101,7 @@
</p> </p>
<p> <p>
{% 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 %} {% 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! ", "Please ignore that strobing effect in your window. That is mother nature trying to distract you from sleeping. Do not give in! ",

View File

@ -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! ", "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }} ] | random }}
{% endif %} {% 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 %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [ {{ [
"There are reports of lightning in the area, please stay safe. ", "There are reports of lightning in the area, please stay safe. ",

View File

@ -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. " "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') }}. {{ states('sensor.weather_alert_string') }}.
{% endif %} {% 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 %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [ {{ [
"There are reports of lightning in the area, please stay safe. ", "There are reports of lightning in the area, please stay safe. ",

View File

@ -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! ", "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }} ] | random }}
{% endif %} {% 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 %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [ {{ [
"There are reports of lightning in the area, please stay safe. ", "There are reports of lightning in the area, please stay safe. ",

View File

@ -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! ", "The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }} ] | random }}
{% endif %} {% 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 %} {% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [ {{ [
"There are reports of lightning in the area, please stay safe. ", "There are reports of lightning in the area, please stay safe. ",