XML Parsing and Database Writing with Node-RED

Getting useful data into your home automation platform is always a challenge.  Weather, snow emergencies, school closings, etc are vital pieces of information as your automations mature.

Unfortunately there isn’t one nationwide, definitive source, for much of this information.  In this post I will outline ONE way to scrape and parse this data for use in automations or alerting.

In my case, I managed to find an XML document that contained the majority of what I was after.  It was not easy to find but I’ll post it here as a reference point: https://s3.amazonaws.com/tdpc-cdn/wbns/feeds/schoolclosings/WBNS-schoolclosingsC.xml

This feed contains (very current) data on school closings and snow emergencies.  And being XML was PERFECT for my parsing out of specific data.  I will give an example here in Node-RED.

Here is the flow in question:

Basically every 5 minutes I hit the URL, parse it out, look for a snow emergency or school closing, and if it’s different than previously format it and write it to the database.  From here I can act on the database values as needed!

You can get the Node-RED flow from here.  Feel free to import it and tweak as needed!

From there you can use your automation platform of choice to reference the database table and create and flows around this information.

Happy Automating!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.