Added new weather alert sensors to use in lovelace based on nws_alerts

This commit is contained in:
Jeffrey Stone 2020-04-24 14:41:25 -04:00
parent fbd34a38a2
commit 96a0a938b5
2 changed files with 182 additions and 1 deletions

View File

@ -28,6 +28,9 @@ input_boolean:
weather_alert_texts:
name: Weather Alert Texts
icon: mdi:telegram
lightning_warning:
name: Lightning Warning
icon: mdi:flash-alert
### You first need to find either your NWS Zone ID or County ID. Im not sure which is better but I used my Zone ID here.
### You can find your Zone ID by going to https://alerts.weather.gov/ 7, scroll down to your state and click on the “zone list” then look for the entry for your county.
@ -40,6 +43,93 @@ sensor:
- platform: nws_alerts
zone_id: 'GAZ034,GAC135'
- platform: template
sensors:
flood_watch:
friendly_name: 'Flood Watch'
value_template: >-
{% if 'Flood Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[0] or
'Flood Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[1] or
'Flood Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[2] or
'Flood Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[3] or
'Flood Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[4] or
'Flood Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[5]
%}
{{ states.sensor.nws_alerts.attributes.spoken_desc }}
{% else %}
inactive
{% endif %}
flood_warning:
friendly_name: 'Flood Warning'
value_template: >-
{% if 'Flood Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[0] or
'Flood Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[1] or
'Flood Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[2] or
'Flood Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[3] or
'Flood Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[4] or
'Flood Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[5]
%}
{{ states.sensor.nws_alerts.attributes.spoken_desc }}
{% else %}
inactive
{% endif %}
tstorm_warning:
friendly_name: 'Thunderstorm Warning'
value_template: >-
{% if 'Thunderstorm Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[0] or
'Thunderstorm Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[1] or
'Thunderstorm Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[2] or
'Thunderstorm Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[3] or
'Thunderstorm Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[4] or
'Thunderstorm Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[5]
%}
{{ states.sensor.nws_alerts.attributes.spoken_desc }}
{% else %}
inactive
{% endif %}
tstorm_watch:
friendly_name: 'Thunderstorm Watch'
value_template: >-
{% if 'Thunderstorm Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[0] or
'Thunderstorm Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[1] or
'Thunderstorm Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[2] or
'Thunderstorm Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[3] or
'Thunderstorm Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[4] or
'Thunderstorm Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[5]
%}
{{ states.sensor.nws_alerts.attributes.spoken_desc }}
{% else %}
inactive
{% endif %}
tornado_watch:
friendly_name: 'Tornado Watch'
value_template: >-
{% if 'Tornado Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[0] or
'Tornado Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[1] or
'Tornado Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[2] or
'Tornado Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[3] or
'Tornado Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[4] or
'Tornado Watch' in states.sensor.nws_alerts.attributes.title.split(' - ')[5]
%}
{{ states.sensor.nws_alerts.attributes.spoken_desc }}
{% else %}
inactive
{% endif %}
tornado_warning:
friendly_name: 'Tornado Warning'
value_template: >-
{% if 'Tornado Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[0] or
'Tornado Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[1] or
'Tornado Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[2] or
'Tornado Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[3] or
'Tornado Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[4] or
'Tornado Warning' in states.sensor.nws_alerts.attributes.title.split(' - ')[5]
%}
{{ states.sensor.nws_alerts.attributes.spoken_desc }}
{% else %}
inactive
{% endif %}
automation:
- alias: 'NWS Weather Alert Pop Up Control'
initial_state: 'on'
@ -83,6 +173,14 @@ automation:
"{{ states.sensor.nws_alerts.attributes.display_desc.split('\n\n-\n\n')[0] }}"
{% endif %}
- alias: 'NWS Weather Sensor Refresh'
initial_state: 'on'
trigger:
platform: state
entity_id: sensor.nws_alerts
action:
- service: script.refresh_weather_alert_sensors
- alias: NWS Notification Weather Alert
initial_state: 'on'
trigger:
@ -207,6 +305,40 @@ automation:
title: "Tornado Warning!"
message: "The National Weather Service Has issued a Tornado Warning for our area."
- alias: Lightning Detected
initial_state: 'on'
trigger:
- platform: geo_location
source: wwlln
zone: zone.lightning_warning
event: enter
action:
# - service: input_boolean.turn_on
# entity_id: input_boolean.lightning_warning
- service: script.text_notify
data_template:
who: "jeff"
title: "Lightning Detected!"
message: "Lightning has been detected within 50 miles of Anchorage House"
# - service: script.lightning_warning_audible
# - alias: Lightning Warning Off
# initial_state: 'on'
# trigger:
# - platform: numeric_state
# entity_id: sensor.lightning_strike_count
# below: 1
# action:
# - service: input_boolean.turn_off
# entity_id: input_boolean.lightning_warning
# - service: script.text_notify
# data_template:
# who: "jeff"
# title: "Lightning Threat Over."
# message: "No more Lightning Strikes detected."
# - service: script.lightning_clear_audible
- alias: NWS Freeze Warning
initial_state: 'on'
trigger:
@ -318,3 +450,47 @@ script:
data:
media_content_id: http://192.168.7.40/audio/tornado_alarm.mp3
media_content_type: "music"
lighning_warning_audible:
sequence:
- condition: state
entity_id: binary_sensor.day
state: 'on'
- service: script.twitter_notify_image
data_template:
tweet: '{{ [ "Did you see that flash? I did. Letting everyone know there is lightning nearby.",
"When Lightning is near I notify the residents of Anchorage House to keep them safe.",
"If the residents of Anchorage House didnt hear the thunder I just gave them a heads up.",
"Everyone inside! If you are near Anchorage House that is. Lightning is near." ] | random }}'
image: >-
{{ [ "/config/www/tweet_images/lightning.jpg",
"/config/www/tweet_images/lightning-bolt.jpg"] | random }}
- service: script.ah_report
data:
call_interuption: 1
call_lightning_alert: 1
lighning_clear_audible:
sequence:
- condition: state
entity_id: binary_sensor.day
state: 'on'
- service: script.ah_report
data:
call_interuption: 1
call_lightning_clear: 1
refresh_weather_alert_sensors:
sequence:
- service: homeassistant.update_entity
entity_id: sensor.tornado_warning
- service: homeassistant.update_entity
entity_id: sensor.tornado_watch
- service: homeassistant.update_entity
entity_id: sensor.tstorm_warning
- service: homeassistant.update_entity
entity_id: sensor.tstorm_watch
- service: homeassistant.update_entity
entity_id: sensor.flood_warning
- service: homeassistant.update_entity
entity_id: sensor.flood_watch

View File

@ -191,3 +191,8 @@
friendly_name: "Current Inside Humidity"
unit_of_measurement: '%'
value_template: "{{ states.climate.home.attributes.current_humidity }}"
lightning_strike_count:
friendly_name: 'Lightning Strike Count'
entity_id: []
value_template: >-
{{ states.geo_location | list | count }}