petervidani / PurpleAir-AQI-Scriptable-Widget

Generate Scriptable app widget to query PurpleAir sensor and display local AQI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PurpleAir-AQI-Scriptable-Widget

By Jason Snell jsnell@sixcolors.com with enormous contributions by many others, including Matt Silverlock (whose code was where this project started), Rob Silverii (who added the gradients and themes per AQI level), Adam Lickel (who added some better JavaScript formatting and moved stuff into functions), and Alexander Ogilvie (who refactored the whole script and added a bunch of JavaScript niceties).

About this project

This script is meant to be used inside Scriptable to generate iOS home screen widgets.

It uses data from the PurpleAir network of low-cost, consumer air quality sensors to display your local air quality, including AQI rating and trend.

Why doesn't this widget match what I see on PurpleAir's map?

Standard AQI calculations were made with certain assumptions in place, including a goal of understanding industrial smog and and the use of expensive particle detectors. They were also meant to reflect long-term readings.

This widget using a draft adjustment from the EPA for more immediate readings from low-cost sensors like PurpleAir in areas where wood smoke is an issue, such as those affected by smoke from wildfires.

You can read about the backstory here.

This widget uses the draft EPA calculation detailed in this document.

As of this writing, the AQandU calculation on PurpleAir is going to give you a reading that's more accurate than the default. I hope the new EPA calc will appear on PurpleAir soon.

Do I need to sweat the numbers?

You don't. Earlier versions of this widget had a larger display for the numbers and a smaller display for the condition level, but the real point of AQI isn't a precise number, it's getting the level -- the words and color -- in the right zone.

But we all like numbers, so it displays a number too. Also, the widget does display a trend if one exists, so if you're in volatile conditions, you should be able to tell at a glance if your air quality is improving or worsening. I found this very useful during a recent set of wildfires in my area.

How to use this

To use it, make a new script inside the Scriptable and paste in the contents of purpleair-aqi.js.

You can run the script from within the app, or add a new Small widget on your home screen, set it to Scriptable, choose the script, and enter the sensor ID from a nearby PurpleAir sensor in the Parameter field.

Finding a sensor ID

To find a sensor ID, go to the PurpleAir map and tap or click on a station near you. The URL in your browser should change to the new selection. A four- or five-digit number will appear just after "select=" and that's the number to enter in to the Parameter field.

The backstory

You can read more about the origin of this project if you like.

About

Generate Scriptable app widget to query PurpleAir sensor and display local AQI.

License:The Unlicense


Languages

Language:JavaScript 100.0%