AirNow.gov integration?


(Brian Spranger) #1

Has anyone been able to get ST to pull the air quality index from www.airnow.gov? It would be sweet to enter your zip code and get the outside air quality report. Then we can decide if we want to exchange our indoor air with the outdoor air.


#2

Since they have an RSS feed, you can just subscribe to that and then set up an IFTTT applet based on certain words in the feed.

http://feeds.enviroflash.info

That’s how people pick up NOAA alerts, for example. :sunglasses:

I don’t know if it’ll be granular enough for you, though.


(Glen King) #3

Are you seeking an automated solution? Where ST gets the report and opens/closes a vent automatically depending on air composition in that moment?? Sounds cool.


(Brian Spranger) #4

This is exactly what my plans are.

I am building a Heat Recovery Ventilator for my house and will be able to control many aspects of it. However, I live in a large city were there are air quality concerns on certain days, so I can be smart about if I want to exchange the air with poor outside air.


(Brian Spranger) #5

So I am new to ST…
I was able to get the IFTTT to receive the RSS feeds for my city, but I wasn’t sure how to get the data out and sent into a variable(?) in ST so that my other devices could react to the air quality.

I also wasn’t sure how to get the data out, there are multiple things reported like ozone, particles, etc.

I did get it to send me the info via email. It appears to update every 30 min on the 15 & 45 minutes.

I think the time resolution would be adequate.


#6

There are a couple of different ways to do this, but at this point I think the most straightforward will be to use Core.

If you ask in the core peer assistance thread (linked to in the FAQ), you may be able to find someone who would be interested in helping you set this up as a project.

Even with core, though, it’s going to be a pretty tedious set up.

If it was me and the information was important to me I might just buy an air quality measuring device with an IFTTT service because the integration would probably be much less work to set up. But obviously that’s your choice.


#7

Did you every figure out a good option for this? I’m in Oregon and we’re getting hammered with Forest Fire smoke, and would love to add a tile to ActionTiles that shows current AQI.

Thanks!


(Brian Spranger) #8

No, I haven’t. I just got my air exchanger running yesterday. So now I will start to look.


#9

I just signed up for API access (though, that probably isn’t necessary). Now I just need to figure out how to write a DH to parse the data.


#10

I’ve actually been working on parsing this data myself for a SmartApp I’ve been working on. I got it working yesterday, so if you want to take a look at some basic working code, the function at end of this file may be of interest. It pulls the PM2.5 and Ozone levels, along with the associated category data, based on either the forecast for the next day or the current conditions.


(Brian Spranger) #11

I will take a look. I just got my heat recovery ventilator working this week so I need this to intelligently exchange air in the house.

Here is an image of my HRV.


#12

Looks good! Was the transparent front panel a functional choice or just because it looks cool (pun intended)? :grin:


(Brian Spranger) #13

I used to make fish tanks with acrylic so I had a bunch laying around. Figured I wouldn’t need to worry about it rotting from moisture.

The clear is nice to see how it’s operating.


(Brian Spranger) #14

I installed the smartapp, got an api key which seems very “generic” and got the smart app installed. It would be cool if there was a device handler that you could look at a device to see what the current air quality is at. Right now I have no way of knowing if it is actually getting the air quality or not.


#15

Yeah, the code I linked to is only for alerting if the air quality hits a certain category, it doesn’t expose the raw AQI numbers to the user. If you look at live logging in the console, the numbers will be shown when it makes a check, but a device handler is beyond my skill set at the moment. I may look into it more when I have some time off later this month.

Your API key should be a long string of hex characters in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. If you’re seeing the key as “GUEST”, that’s not it. For some reason that is shown on the https://docs.airnowapi.org/webservices page, but if you go to any of the other pages (e.g. https://docs.airnowapi.org/forecastsbyzip/docs) you’ll see the real key.


#16

Also, I discovered a a really stupid bug in the version I put up at the weekend, try the new code I committed today…


(Brian Spranger) #17

I updated my device driver.
Also got the real API key.

Here is a log I just received.

74db275a-5d44-4564-9621-ac5c1468109b 10:00:05 PM: error java.lang.NullPointerException: Cannot get property ‘number’ on null object @ line 134
74db275a-5d44-4564-9621-ac5c1468109b 10:00:05 PM: error error: groovyx.net.http.ResponseParseException: OK
74db275a-5d44-4564-9621-ac5c1468109b 10:00:05 PM: debug Forecast conditions: mainly clear. lows overnight in the mid 60s.
74db275a-5d44-4564-9621-ac5c1468109b 10:00:04 PM: info Something’s open, let’s check the weather.


(Brian Spranger) #18

So, I was having problems as seen above in my last post so I added some debug to your smart app. Well after adding debug it started working. Makes no sense. but I guess I will keep it for now.


#19

The error message you got was the exact one I saw before fixing the bug. I’m wondering if maybe the IDE didn’t publish the new code properly and was still running the broken version, but then published it successfully after you added the debug code.

In related news, it turns out that writing a device handler isn’t as hard as I thought. I should be able to publish my initial attempt at a DTH after work today.


(Brian Spranger) #20

Sweet! I will try it out