I have been looking for ways to run a HomeKit action when the US National Weather Service (NWS) issues a severe weather alert for my area. The simple example would be to turn a light red when, say, a severe thunderstorm or tornado warning was issued. I’d like to be able to run more complex automations (via shortcuts) as well.
The tricky part seems to be triggering something when the alert gets issued. While several iOS apps will show a notification, I haven’t found an obvious way to use them as a trigger for a shortcut. It’s very possible I’m missing something obvious - this has got to be a common use case. As far as I can see, the Weather Conditions data doesn’t contain alert data.
I’m looking into alternatives to on-device triggers. The good news is that the NWS provides location-specific (usually counties) RSS feeds with text for each alert, which opens up a number of possibilities for server-side scripting:
- A Node-RED script that parses the RSS feed and calls out to a PushCut server via the PushCut web API (Requires a dedicated PushCut automation server device, but not too hard, and decouples the notification from the action)
- A Node-RED script that parses the RSS feed and directly manipulates HomeKit (easiest but hardwires the automation)
- A Node-RED script that parses the RSS feed and calls the excellent Button Platform for Homebridge (Requires both HomeBridge and Node-RED, but also pretty simple and again decouples the notification from the action)
Deeper dives include getting the JSON object from e.g. OpenWeatherMap or the XML from the NWS location feed and parsing that to get the alerts. (Substitute your favorite scripting language above…)
So, before I dove down the programming rabbit hole, can anyone suggest a better / simpler way to do this? Any worked examples?
Personally, I’d take a look at Home Assistant for this, the number one reason being that it has native support for NWS. You can create a sensor or switch, or whatever you like and expose that to HomeKit to have it react to it, you’ll also be able to differentiate between thunderstorms and tornados (as I presume you need to prepare slightly differently!).
In the land of HomeKit/HomeBridge, I’d probably skip Node-RED (it’s definitely overkill for parsing an RSS feed!), and look at the Weather plugin for HomeBridge. It supports OpenWeatherMap which already has all the data from NWS and would save you a good few steps!
Integromat (now “Make”) has good RSS parsing tools. You could use that to trigger something.
Thanks, Rosemary, and good timing. I installed the homebridge-weather plugin today, and unless I’m missing something, it’s looking like a dead end for alerts. It appears the OpenWeatherMap API doesn’t have support for fast-breaking alerts. Given their global perspective, fast alerts would be hard.
I’ve started down the Node-RED path, but will take a look at HA. The US NWS has a very nice (and very localized) feed with XML alerts that get updated with a 2-3 minute latency. NR makes this easy to parse. Plus, NR comes as part of Homebridge, so it’s a trade off of wrestling with setting up yet another box vs. doing a bit of programming on one I already have deployed
More experiments tomorrow, and I’ll post results here.
Well, my quest for weather alerts has been an interesting rabbit hole. The good news is that programmatically messing with RSS feeds isn’t needed, since the US Weather Service provides an REST API Web Service which allows access to pretty much all the information the NWS provides. This includes alerts at all levels.
The only complexity comes from the specifications for the endpoints and schemas, which are complex to parse because the schema accommodates pretty much any kind of alert the US Government could conceive of sending out. So, picking out the actual weather alerts requires decoding a couple of levels of data structures.
I am nearly done with the parsing and getting the alerts hooked into Homebridge. If anyone else is interested in seeing the results, reply to me here and I’ll post the links.