AQI Tile (Air Quality Index)

Hey everyone,

Unfortunately for some of us in the US, the air quality is terrible due to wildfires. I created a quick tile to show the current AQI near my house. The data is coming from one of the many purpleair.com sensors.

The code is here (don’t judge me on the code quality :grimacing:): Glitch :・゚✧

Feel free to clone it and make it your own as I am still fine-tuning mine. The only line that needs to be updated is the one where we fetch the data from purpleair.com (line 204), you want to select a sensor that is near your house. Let me know if you need instructions for finding the sensor id on purpleair.com

Cheers



7 Likes

@dbaq, thanks for sharing this very cool project. I liked how simple it looks visually. :+1:

I’ve moved your post to the Community Project category where other community members usually look for in regarding to the community developed projects. A couple feedback, you may want to take a look of the stio library and allow users to provide the sensor id via the Tile Editor in the dashboard, so they don’t have to look up in the code.

And you can also take advantage of the direct Custom Tile import URL as shown below to allow users to import the source code and create the custom tile in just one simple click. (I created the the import link with the image below and feel free to include it in your original post.) :grinning:

https://sharptools.io/developer/custom-tiles/import/?url=<Encoded-URL-to-Your-Raw-Source-Code>

image

1 Like

Thanks, James.

you may want to take a look of the stio library and allow users to provide the sensor id via the Tile Editor in the dashboard, so they don’t have to look up in the code.

Yep, that’s the plan if I see any interest from the community :wink:

1 Like

Awesome work on this! I really like the clean look and how easy it is to see things at a glance with the stoplight style colors.

Per discussion with @dbaq via PM, here’s a version that works like a native custom tile where it let’s you configure the PurpleAir sensor ID in the tile configuration.

:arrow_double_down: Import PurpleAir Custom Tile

Source Code

(The import link in James’ reply above has been updated too)

2 Likes

Just click on a sensor on the map and then grab the five digit select value?

The numbers roughly match but Purple is showing an AQI of 57 (yellow) and the tile is showing 47 (green). Maybe just a minor difference in the conversions to AQI?

A few things to know:

I am getting the data from that URL: https://www.purpleair.com/json?show=95579 (replace with your sensor ID)

The response could return multiple sensors (the main one + all the child sensors). I am using the first one in that list and I am using v1 which is the pm2.5 10 min average. We could also make that configurable.

As for the conversion mismatch, you are right. I also see some differences within the +/- 10. I reimplemented the code from Spare The Air: AQI Calculator: Concentration to AQI which could be slightly different from purpleair.com. In the end, from an AQI perspective, the difference is not meaningful but I will dig into it to understand the difference between purpleair and sparetheair when I get a chance.

ps: on purpleaire.com consider using outside sensors only because inside sensors are very random.

3 Likes

I totally agree! I figured it was close enough and probably just a minor calculation difference, so I appreciate your reply. Great job! :+1:

1 Like

@dbaq Really like the new tile and just added it to my dashboard. I have been noticing a rather big difference between what the website report and what my dashboard shows with this ID 17889. This morning, the difference is more than 25 between the two. I tried the calculation manually and have use the data returned by the json (13.74) and ran the calculation on the site AQI Calculator = 44. The tile was reporting 21. Was just wondering if this difference is somewhat normal? Great work!