Hooking Purple-Air Sensor up to Inovelli Switch LED via Home-Assistant

Hey friends! I live in California and, like everyone else, have been plagued with terrible air quality due to the awful fires happening all around. My 4yo son was asking everyday, “Daddy, is it safe to play outside yet?”

Instead of pulling my phone out every time, I wanted to make it so the whole family could know (at a glance) what the air quality was like.

So I wrote a python script that can be tied into Home Assistant to report on a specific PurpleAir sensor as well as giving a color value to be sent to our Inovelli Red Series Dimmer Switch near the front door.

image

Now my son tells me “Dad, can we go play outside, it’s now green out!”

1 Like

This is an awful situation for you guys. I hear that the West Coast fires have even affected New York and have been detected in Europe.

Horrendous.

My family has been lucky that we’ve been in the middle between the various fires. Many friends had to evacuate for a period of time because of their proximity to one or another fire.

This is AWESOME - I’m in Sonoma County and it sucks right now! I should get my sensor in a week or so, but it looks like you can grab the data from any sensor. I think I’ll do this for the same 4-5 sensors that I look at each day. PurpleAir was inundated w/ orders recently. But, I’ll be adding it to HOME ASSISTANT for sure when I get it!

It’s too bad you have to restart HOME ASSISTANT every time you want to change a sensor. I see your command to pull the data. Is this the realtime data or one of the averages?

urllib.request.urlopen('https://www.purpleair.com/json?show={}'.format(SensorID)) as url:
    data = json.loads(url.read().decode())

I’m also getting pretty wide variations in the query vs from the data coming from PurpleAir.com. For example, your query gives me 95 degrees on the sensor near me #18781.

But it hasn’t been over 88 on any sensor anywhere in the area all day…

The AQI, humidity, pm2.5, etc are all quite different from the real time map readings, which caused me to check other readings. Are you seeing the same discrepencies? Perhaps their map is lagging, but the temp differential caused me pause…

Jeff

Can I ask how people are getting the sensor id for a specific sensor? It used to be that there was a link at the bottom of the sensor display that showed the JSON URL along with the sensor id. That seems to have disappeared.

I wonder if the temp reading at PerpleAir.com has some kind of compensation factor for the laser heat while the JSON data doesn’t? I have a DS18B20 about 8 ft from the PA sensor is it reads 5 degs lower than the PA sensor temp.

Click on a sensor you want. Then look at the URL

Jeff

Dang. I didn’t notice that.

Thanks!

BTW, I’m in San Jose (South Bay)

Those are all the real-time values. Based on https://www2.purpleair.com/community/faq#hc-json-object-fields

So there must be a bug somewhere. The temp values are way off…

It’s mentioned that the temperature reading is ~8F higher than ambient temp in the FAQ: Tempertautre_F: Temperature inside of the sensor housing in Fahrenheit. On average, this is 8F higher than ambient conditions. (From BME280) So you would want to subtract 8F from that value to get an accurate reading. https://www2.purpleair.com/community/faq#!hc-primary-and-secondary-data-header

Yup. I’ve adjusted my temp sensors accordingly, -8 degrees.