[RELEASE] Free Device Driver for the PurpleAir Air Quality Station - Now with Hubitat support!

@spritelysprite thank you very much for the update!

Unfortunately, I do not seem to be retrieving any attributes. Please see the screenshot below.

Any help would be greatly appreciated!

Marc

@marcaronson408 It looks like you're still using the original version. If you use the fork I mentioned above, you'll be on version 1.1.10.

Also, you'll need to get an API key as mentioned before it will work. PurpleAir support responded next day with a key for me.

@ storageanarchy would you be able to merge in the changes from @spritelysprite?

When I requested the API key for my sensors they sent me a read and a write key, I imagine I need the read key rather than the write? I'm getting the following when I tried updating the driver with the read key, thanks.

dev:47432022-06-13 06:51:16.569 pm errorHTTP error from PurpleAir: 404
{
  "api_version" : "V1.0.10-0.0.17",
  "time_stamp" : 1655164278,
  "error" : "NotFoundError",
  "description" : "Cannot find a sensor with the provided parameters."
}
dev:47432022-06-13 06:51:16.073 pm traceRequest to be made: [uri:https://api.purpleair.com/v1/sensors/xxxxxx, headers:[X-API-Key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx], timeout:30, ignoreSSLIssues:true]

Update: It works when I use a public Purple air device but not when I use a private (indoor) device.

@spritelysprite, Oy Vey -- I see the mistake I made!

I treated it as a new driver rather than an updated version of the existing version. All is working now -- thank you!

Marc

1 Like

Is the purplekey variable being used, it looks like after it is asked for it only looks at it if a certain error is displayed but doesn't seem to add it to the request? I would think that is what is needed for private PurpleAir devices? Thanks.

Can someone tell me how I can pull the attrbutes from this driver to turn air filters on and off?

I was looking at trying my hand at my first WebPiston, but the one example I could find looks to be based on the old API

I used the custom attribute option in RM with the old driver I haven't been able to get the info from my indoor sensor yet. Update: after getting the inside sensor working with the API updates to the driver I've verified this rule worked again without modification.

1 Like

This is awesome! Thanks so much!

I don't know the programming language well but where the following line is

String url="https://api.purpleair.com/v1/sensors/$purpleID"

Should be something like the following but this code didn't return a url value for some reason

if (purplekey != null) {
        String url="https://api.purpleair.com/v1/sensors/$purpleID?read_key=$purpleKey"
    } else {
        String url="https://api.purpleair.com/v1/sensors/$purpleID"
}

Once I added the ?read_key=$purpleKey to the end of the line it was able to read from my private sensor as long as I had my PurpleAir Private Key defined.

Ok this code seems to work for public or private sensors depending on whether or not you supply the Private key.

    if (settings.purpleKey) {
	        url="https://api.purpleair.com/v1/sensors/$purpleID?read_key=$purpleKey"
        } else {
            url="https://api.purpleair.com/v1/sensors/$purpleID"
    }

Here is a fork with the logic for private PurpleAir stations.

Hey Barry, @storageanarchy, did you notice this announcement from PurpleAir (pasted below)? Wonder if this device driver will be affected and, if so, whether there is anything we can do about it. Appreciate any perspective.

PurpleAir Announcement Email

ear PurpleAir API Users,

We are excited to let you know that we will be releasing a new version of the PurpleAir API on July 18, 2022. This new API provides access to historic data that is now hosted on Google’s BigQuery. It is important to note this update provides no functional changes to our current API at https://api.purpleair.com, but rather adds new history endpoints.

What updates will the new version have?
We added features that provide access to historical data. You’ll find documentation within the API site explaining how to use these new endpoints.

Before the 18th, you may test them here: https://june2022.api.purpleair.com. This preview URL will go away, so please be sure only to use it until the main URL is updated.

What do you need to do?
If you use ThingSpeak for historic data, you will need to migrate your code to use the PurpleAir API instead. The ThingSpeak service will stop working in or around August 2022. We encourage you to get familiar with and switch to the new API’s history endpoints as soon as possible before ThingSpeak is no longer available.

Rollback capability.
If you experience any issues with the new version, for a limited time, the previous version of the API will be available at https://rollback.api.purpleair.com.

Look out for future announcements.
We are currently updating our API Terms of Service and Attribution guidelines. Please look out for an announcement in the coming weeks.

Thank you,
The PurpleAir Team

Disclaimer You are receiving this email because you have signed up for a PurpleAir API key.

As of July 19th, this integration no longer works for me, as per the PurpleAir announcement posted above. Anybody have a solve?

It's still working here.

Are you using your own private device or the cloud integration? Did you not get the API announcement from PurpleAir a few days ago (it’s in this thread a couple messages up)

I have both an internal and external PurpleAir device using the cloud API fork I modified to make work with private devices, posted above. I got the announcement but according to the announcement:

It is important to note this update provides no functional changes to our current API...

So I'm hoping it will stay working and it's not just that my devices haven't gotten the firmware update yet, which is possible.

When I get home this evening I will try using:

    if (settings.purpleKey) {
	        url="https://api.purpleair.com/v1/sensors/$purpleID?api_key=$purpleKey"
        } else {
            url="https://api.purpleair.com/v1/sensors/$purpleID"
    }

Note the change from read_key -> api_key.

To my surprise the fork worked as is. I was pretty sure it'd need to be api_key but I guess not.

I contacted PurpleAir support to get the right key.

Can anybody share how to update version 1.1.08 installed using Package Manager to 1.1.10?

I located the updated driver code dated June 4 ( Update to use Purple API · SANdood/PurpleAirStation@275e600 · GitHub) and I can see the changes that were made in comparison to version 1.1.08. But I don't know how to update my version from 1.1.08 to 1.1.10.

Thanks in advance for any assistance.

Edit: I was able to get it updated to 1.1.11 simply by creating a new driver and copying and pasting the code into the window and saving it. However, I was surprised to see that it is asking me for both an API Key and the Station ID. Is that correct for it to be asking for both even with PurpleAir's new API? Anybody know how to find the station ID now that the old JSON webpage is gone?

1 Like