Purple Air sensor plugin

Posted on
Mon Sep 21, 2020 11:20 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Purple Air sensor plugin

Beta test release - https://github.com/FlyingDiver/Indigo-m ... /tag/0.0.1

To use, create a sensor device for each Purple sensor. Sensor must be a public shared sensor available on https://www.purpleair.com/map. Find your sensor on the map, then get the sensor ID from the URL:

Code: Select all
https://www.purpleair.com/map?opt=1/mAQI/a10/cC0&select=63643#4.77/32.86/-93.2


Look for the number after the "select=" in the URL. In this case, it's 63643. Which is a random sensor in Texas I picked as an example. ;)

Put that number in the Device Configuration dialog.

Currently, the plugin only uses data from the first detector channel for that sensor. Indoor sensors only have one channel. Outdoor sensors have two, but I'm ignoring the second. Suggestions on how to handle the second channel would be appreciated.

The sensor value is the AQI based on the EPA PM2.5 algorithm. All the other data (well, most of it) for the sensor channel is in the custom states, including temperature, humidity, and barometric pressure.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Sep 21, 2020 3:18 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Purple Air sensor plugin

Cool, I installed it and pointed it to the closest one. It is matching the current value - is there a way to pull down the 10 min. average value or is the purple air site just calculating that for their display?

For the plug in, when the device type is picked could you have two choices (1) purpleair sensor CH1 and (2) purpleair sensor CH2?

I will set up a trigger to alert me if air quality is above 100 and I have any windows open :-)

If no issues with the plug-in I will get an indoor one to test with - thanks!!!!

_______
Norm

Posted on
Mon Sep 21, 2020 3:32 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Purple Air sensor plugin

The 10 minute average (and others) are buried in the JSON data in a way that requires some extra work to extract. I'll see if I can add that to the next release.

I'll probably put in a choice of channels, but I really dislike the way they did the data structure. So much redundant information, and no explicit way to know if both channels have valid data. the single channel device still has a data array with two elements in it, but the second one doesn't have any useful data in it. So much fail there.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Sep 21, 2020 3:38 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Purple Air sensor plugin

No point (in my mind) adding sensor CH2 if no value - I don't see a way to look at them individually on the site -- maybe they use it to declare a problem if the two counters are more than some percentage off from one another?

_______
Norm

Posted on
Mon Sep 21, 2020 5:03 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Purple Air sensor plugin

norcoscia wrote:
No point (in my mind) adding season CH2 if no value - I don't see a way to look at them individually on the site -- maybe they use it to declare a problem if the two counters are more than some percentage off from one another?


I believe that's exactly what they do. What I don't know is if they use the average or the higher value for the AQI.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Sep 21, 2020 5:16 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Purple Air sensor plugin

So now that I have thought about it it might be of some value to know if there is a big difference - seems like it might be indicative of some dirt (or a spider web) interfering with one of the sensors - but just guessing. Maybe green status if they are close and red or yellow if an unusual difference - but I don’t have any way to see what a typical difference is. Just a thought.

I have looked around and I see many indoor sensors - does not look like you need to specify a location - so if I do get an indoor unit I could just make it public -place it far from my house and label it the Batcave :-)

_______
Norm

Posted on
Mon Sep 21, 2020 6:14 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Purple Air sensor plugin

If you wouldn't mind, when you get the new one, set it up as Private and send me the link to it. I want to see if I can get the plugin to read private ones as well as public.

As for the other, I'm not adding any logic or analysis to the plugin for the first release. Note the name is "miniPurple". ;)

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Sep 21, 2020 6:33 pm
norcoscia offline
User avatar
Posts: 1206
Joined: Sep 09, 2015

Re: Purple Air sensor plugin

Did some reading on the purple site - it said that if the sensors drift apart they may downgrade one of the channels -see below. Trying to decide on using the outside sensor indoors (they said many people do) or getting the easier to place (and cheaper) indoor unit - either way looks like a 6-8 week wait for a unit. I will try the link with you (assuming they don’t plan to charge my credit card until they ship) - checking with them now.....


What does "downgraded" mean on the graph?
PurpleAir PA-II and PA-II-SD sensors contain two laser particle counters that measure the real time particulate matter and report as Channel A and Channel B. If the values being reported for the two laser particle counters drift apart, our system may "downgrade" one of the channels. The downgraded channel will no longer be used in the data average and will be grayed out in the graph's legend. You can still view the downgraded channel on the graph by clicking on the downgraded name in the graph's legend.

_______
Norm

Posted on
Thu Oct 08, 2020 7:35 pm
wikner offline
Posts: 181
Joined: Nov 02, 2003

Re: Purple Air sensor plugin

To use, create a sensor device for each Purple sensor. Sensor must be a public shared sensor available on https://www.purpleair.com/map. Find your sensor on the map, then get the sensor ID from the URL:

Code: Select all
https://www.purpleair.com/map?opt=1/mAQ ... 2.86/-93.2



Look for the number after the "select=" in the URL. In this case, it's 63643. Which is a random sensor in Texas I picked as an example. ;)

Put that number in the Device Configuration dialog.

This does not work, because nothing can be put in the Device Configuration Dialog.

Also my log has one of these every 1-2 minutes:
Code: Select all
   Purple Air Error                Error in plugin execution runConcurrentThread:

Traceback (most recent call last):
  File "plugin.py", line 123, in runConcurrentThread
  File "plugin.py", line 41, in _refreshStatesFromHardware
  File "/Library/Application Support/Perceptive Automation/Indigo 7/Plugins/PurpleAir.indigoPlugin/Contents/Server Plugin/PurpleAir.py", line 74, in GetData
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/api.py", line 71, in get
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/api.py", line 57, in request
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 477, in request
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 587, in send
  File "/Library/Application Support/Perceptive Automation/Indigo 7.4/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/adapters.py", line 481, in send
ConnectionError: HTTPConnectionPool(host='192.168.15.84', port=80): Max retries exceeded with url: /json (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x110e1ae90>: Failed to establish a new connection: [Errno 60] Operation timed out',))

   Purple Air Error                plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Attachments
Screen Shot 2020-10-08 at 7.29.41 PM.jpg
There is nothing to select in the menu. The other fields are all inactive; nothing can be put in them.
Screen Shot 2020-10-08 at 7.29.41 PM.jpg (55.56 KiB) Viewed 4529 times

Posted on
Thu Oct 08, 2020 7:37 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Purple Air sensor plugin

wikner wrote:
This does not work, because nothing can be put in the Device Configuration Dialog.


That's not my plugin. That's the original plugin from a different developer which no longer works.

If you want to try my plugin, the download link is in the first post of the thread.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Oct 08, 2020 7:42 pm
wikner offline
Posts: 181
Joined: Nov 02, 2003

Re: Purple Air sensor plugin

Thanks for your rapid response. My mistake :oops: I wonder why the original is still in the plugin store. I only installed it about 2 weeks ago, and it does sort of intermittently work for local sensors on the LAN. I'll try yours...

Posted on
Mon Nov 09, 2020 10:41 am
johnofcamas offline
Posts: 36
Joined: Jan 30, 2014

How to display / use other values

I'm using this (wonderful) plugin along with your Trane Nexia Thermostat (wonderful) plugin, and I'd like to set up the following trigger

Trigger:
- if the indoor AQ goes above a certain point (say 25)
Action
- set the Trane Nexia Thermostat's "Air Clean Mode" to "quick"

The thing am presented with for the trigger though is this:
aq_values.jpg
aq_values.jpg (67.99 KiB) Viewed 4361 times


I'm guessing here... but Which do I choose?

Also, follow up question. Is there a way to create "dummy" devices that can show those values?

Posted on
Mon Nov 09, 2020 10:48 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Purple Air sensor plugin

I would just use sensorValue, which is a normalized value using the EPA aqi algorithm. It's based on the PM2_5Value returned by the sensor.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Nov 09, 2020 10:51 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Purple Air sensor plugin

Also, you can probably use the Masquerade plugin to create pseudo devices that show a specific state.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Nov 09, 2020 10:59 am
johnofcamas offline
Posts: 36
Joined: Jan 30, 2014

Re: Purple Air sensor plugin

Thanks!

Who is online

Users browsing this forum: No registered users and 1 guest