PurpleAir Intergation not working for me: Unexpected error

Hello, I’m very new to home assistant. I’m trying to integrate one of PurpleAir sensors into Home Assistant. Adding the integration, when I enter the required API key and select my location I get a red error message: Unexpected error.

The sensor shown on the PurpleAir map and I have cut and pasted the API key directly off the PurpleAir developer site. The key that I created is a read key.

Can anyone suggest a way forward?

I had the same experience with PurpleAir and went on to try the AirNow integration - it’s working fine for me.

If I understand you correctly, I would have to give up on using my PurpleAir sensor. The thing is I’m using the sensor inside so I don’t think AirNow will help me.

If you have your own PurpleAir, use the REST api; search PurpleAir on this forum and you get all the info you need.

OK, check out this gem in Home Assistant Logs:

2023-05-24 09:09:30.326 ERROR (MainThread) [homeassistant.components.purpleair] PurpleAir error while getting nearby sensors: Error while querying https://api.purpleair.com/v1/sensors?fields=name,latitude,longitude&nwlat=45.44641602476684&nwlng=xxxxxxxxxxxxxxx&selat=xxxxxxxxxxxxxx&selng=-xxxxxxxxxxxxxx: Payment is required to make this api call.

I have sent an email to PurpleAir asking if I need to pay to access my readings. I will report back as soon as I hear from them.

If you don’t have your own PurpleAir, then yes, they made that change awhile ago. If you own a PurpleAir, you can access your own data via the API.

Thank you Glen for following up. The thing is I’m not really a programmer, I don’t know Python nor have I ever heard of the REST API. It sounds like you have it working. Would you be willing to write down a step by step tutorial? Perhaps you could start with what pecies need to be in place for this to work.

Review this: https://community.home-assistant.io/t/purpleair-air-quality-sensor/146588/13

Did you move credits into the project you are using from PurpleAir’s API setup page? The key doesn’t work unless you move credits in. I was confused by the error in HA as well.

You start off with 1 million credits when you set up a key. You pay after those are exhausted.

Now to the reason I came here – I can’t seem to get any data from the integration after I successfully got it up and running. All I get is state ‘unavailable’ for the PM2.5 data.

Update … a reboot with credits in my key seems to have fixed everything. However if the default auto-refresh is on, it will quickly gobble up credits. Since I was putting a small number of creds in the key to experiment, they ran out. When the integration parses the API for data and there’s no creds, the HA data goes to ‘unavailable’ instead of showing the last valid data point.

I just encountered this problem in switching from the 3rd party integration to the built-in one.

PurpleAir support saids they don’t want the API access to cost the sensor owners anything. Just call/email them and give them your API account name, and they’ll move your account off of billing, so your API requests won’t require any points. They said in the future, they’ll have a system in place that automatically adds points to sensor owner’s accounts, and then they’ll put those accounts back on billing, but as long as you’re only using it for HA, you shouldn’t run into a points issue.

Is there a reason you don’t pull it from the local API directly?