Severe Weather Alerts from the US National Weather Service

I tried to use a RSS feed component for pulling out some info from the feed but it seems that it doesn’t create attributes in a json standard format so I couldn’t figure out a reasonable way of using the info I needed from it.

Maybe now that I have a working alert system i can spend some time working that out too.

Yes I saw another thread where somebody was trying to use the ha feed parser for NOAA and I think was struggling with it. Thanks. Either way I have my snow shovel and sled dogs… just kidding the only huskies I know do not work for a living

Yep, I think that was probably me.

Now installed and will be testing in The Great State of Texas… where severe weather… just is.
Thank you.

I have recently developed the geo_location component, and am now in the process of adding platforms. My focus at the moment are GeoJSON and GeoRSS feeds, and the platforms include external events based on the vicinity to your HA installation.
In parallel I’m trying to make this new platform more useful, for example by implementing a geo location based automation trigger.
I haven’t looked at CAP feeds, but I believe they often also come with some sort of geo location information embedded.
If anyone is interested in looking into this, I’d be happy to help.

1 Like

@dasbooter and @finity

NOAA also puts out Common Alerting Protocol notices, which is what you might be noticing. I authored a little python library to convert all the CAP versions to standard Python objects.

I’m currently scraping a number of these alerts (NOAA, RFS, CA, Taiwan, and a few other places) and storing them in a PostGIS database. If you see some value in integrating it with HASS, then please let me know and I’d be happy to flush out some details.

2 Likes

YEAH!
Bad news… we had a really big storm here in Central Texas today.
Good news… This little thingie you put together worked flawlessly!

1 Like

Awesome, good to know!

I think…:worried:

Hope everyone is OK.

1 Like

When I saw the notification (I’m out of town), I called partner and ask if Alexa gave her a verbal warning. She confirmed that every one of our echo, and dots, did indeed speak up. She was a bit taken back because this was a new one but she is now finally acknowledging that my little hobby actually has a use. :slight_smile:

1 Like

I tried the sensor as posted by @finity, and it broke my recorder. Seems having a hurricane go by makes the list of alerts too long to stick into the database, and having an excessively long SQL query actually borks the recorder until the hass service is restarted. Icky.

 2018-10-10 10:36:40 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (_mysql_exceptions.DataError) (1406, "Data too long for column 'event_data' at row 1") [SQL: 'INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s)'] [parameters: ('state_changed', '{"entity_id": "sensor.nws_alert_event", "new_state": {"last_changed": "2018-10-10T15:36:40.468924+00:00", "entity_id": "sensor.nws_alert_event", "con ... (68707 characters truncated) ... l; Santa Rosa Coastal; Okaloosa Coastal"}, "geometry": null, "type": "Feature"}], "friendly_name": "NWS Alert Event"}, "state": "Hurricane Warning"}}', 'LOCAL', datetime.datetime(2018, 10, 10, 15, 36, 40, 468997, tzinfo=<UTC>), datetime.datetime(2018, 10, 10, 15, 36, 40, 475520), 'aa244d704c424398a8fbf1959627dc03', None)] (Background on this error at: http://sqlalche.me/e/9h9h)

The family and the house are fine, we were just on the western edge of Michael’s path. Max winds around 35-40 knots. The worst damage was we had a trash can get blown over.

Anyways, how can we work around this? The recorder thing, not the trash can :grin:

You can select entities to ignore in the recorder. I haven’t set that sensor to be ignored but I also haven’t had more than 2 alerts at any time either so I haven’t had any crashes.

Try that and see what happens. I’ll do some more testing to see what I can get to fail.

Do you have any idea how many alerts were sent out simultaneously?

Glad to hear everyone in your circle is fine.

I’m sure it was a lot! Last year during hurricane Harvey my condo smoke/fire/carbon monoxide/weather warner went off so many times after we lost power that it wore out the fresh batteries I put in it.
Also… I recall the text of the alerts being WAY longer than 255 characters… if that impacts the code at all. :slight_smile:

I don’t think it affects anything because we are pulling the state out of the “event” title and it is less than 255 characters. I was told there are no limitations on the characters in the attributes tho. and “features” is an attribute of the sensor and that’s where all the text is in the alert.

The most alerts I saw active at one time was eight…it was ugly out there.

I think the recorder was trying to store the entire set of objects, and that ended up being a really long string.

I think the best solution is to just exclude that sensor from the recorder.

Would love to get a component or a appdaemon python file for your lib… someway of adding one or more feeds of CAP-streams. Maybe filtering them by distance from “home location” and using them in home-assistant

I’ve only got some really basic skills in python so I don’t even know where to start :smiley:

For this to work, the CAP feed will need to define an area for each entry that specifies geo location coordinates. Not all CAP feeds that I’ve seen do that; in some cases it’s just a textual description of the affected area.

For the glue code that joins the CAP feed via @kelvinn’s capparselib library to Home Assistant, you could take a look at how I’ve done something similar for GeoRSS feeds.

Ah crap, noticed now that the polygon field was optional… to bad since it would have been an easy way to do it! Still a CAP component would be great!

I’ll take a look at your georss code to! Thanks!

Indeed, a lot of CAP feeds either just reference a geocode, or include a Point geometry.

I’ve stitched to two together when receiving the alerts, e.g. an alert comes from NOAA with geocode of 48299, then I look that up in a geocode list and associate a geometry with it. For Points I just add a buffer of a bit.

Here’s an example:

https://alerted.us/api/v1/alerts/?lng=-98.71762&lat=30.73275

The cap_slug is also available as a website, e.g.:

https://alerted.us/alerts/9a99f75ac8c89ff67dd413ecbd4448/

I basically did the entire side project just before having a kid, and then had to drop everything until she is mostly self sufficient. I’m just now getting time to focus on some of these things a little bit.

I think this is achievable using the rest platform, e.g.

sensor:
  - platform: rest
    resource: https://alerted.us/api/v1/alerts/?lng=-98.71762&lat=30.73275
    value_template: '{{ value_json | length }}'

I think it is possible to do a filter by date, but I’d need to read up on HASS datetime functions.

[quote="finity, post:1, topic:71853"]
- alias: NWS Notification Weather Alert
....
action: 
  - service: notify.pushbullet_notify 
    data: 
      message: "NWS: {{ states.sensor.nws_alert_event.state }}"
[/quote]

I think there may be an error in your acton. Shouldn’t “data” instead be “data_template” since you’re using a template in the message?