### You first need to find either your NWS Zone ID or County ID. I’m 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.
### I recommond useing both
#I’ve taken much of the underlying work here and created a custom component for nws alerts sensor.
#The sensor can be created by adding the nws_alerts.py file to <config_directory>/custom_components/sensor/ and adding the following to your sensor definitions:
sensor:
- platform:nws_alerts
zone_id:'GAZ034,GAC135'
- platform:template
sensors:
flood_watch:
friendly_name:'Flood Watch'
entity_id:sensor.time
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
value_template:"{{ (('Severe' in states.sensor.nws_alerts.attributes.title) or ('Thunderstorm' in states.sensor.nws_alerts.attributes.title)) and 'Warning' in states.sensor.nws_alerts.attributes.title }}"
action:
- service:script.ah_report
data_template:
speech_message:>
{% if states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[5] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[5] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[4] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[4] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[3] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[3] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[2] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[2] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[1] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[1] }}
{% else %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[0] }}
{% endif %}
- service:script.twitter_notify_image
data_template:
tweet:'{{ [ "Anchorage House is battening down the hatches. Servere Weather is imminent. ",
"The weather outside is getting intense, so I just made a weather announcement.",
"Anchorage House monitors the NWS for severe weather using #HomeAssistant just for these occasions. Thanks for the heads up @NWSAtlanta "]| random }}'
image:>-
{{["/config/www/tweet_images/lightning.jpg",
"/config/www/tweet_images/lightning-bolt.jpg"]| random }}
- delay:'00:00:15'
- service:script.ah_report
data_template:
speech_message:>
{% if states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[5] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[5] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[4] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[4] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[3] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[3] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[2] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[2] }}
{% elif states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[1] is defined %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[1] }}
{% else %}
The National Weather Service Has issued a {{ states.sensor.nws_alerts.attributes.spoken_desc.split('\n\n-\n\n')[0] }}
{% endif %}
- alias:NWS Announce Weather Alert for Tornado
trigger:
- platform:state
entity_id:sensor.nws_alerts
condition:
condition:and
conditions:
- condition:template
value_template:"{{states.sensor.nws_alerts.state | int > 0}}"
- condition:template
value_template:"{{ 'Tornado Warning' in states.sensor.nws_alerts.attributes.title}}"
action:
- service:script.jarvis_alert
data_template:
message:"Attention!,,,Attention!,,,The National Weather Service Has issued a Tornado Warning for our area."
- service:script.twitter_notify_image
data_template:
tweet:'{{ [ "NWS is sounding the Tornado alarm, so I am too. Anchorage House is taking cover. ",
"Anchorage House is heading to the closet because the NWS just issued a tornado warning for our area.",
"I just activated the internal Tornado Alarm. Thanks for the heads up @NWSAtlanta "]| random }}'
image:>-
"/config/www/tweet_images/tornado.jpg"
- delay:'00:00:15'
- service:script.jarvis_alert
data_template:
message:"Attention!,,,Attention!,,,The National Weather Service Has issued a Tornado Warning for our area."
- delay:'00:00:15'
- service:input_boolean.turn_on
entity_id:input_boolean.tornado_alarm
- service:script.text_alert
data_template:
title:"Tornado Warning!"
message:"The National Weather Service Has issued a Tornado Warning for our area."