Gathering Local-Only (intranet vs internet) data

I have an idea I would like to try out for our home automation dashboard. I would like to grab data from the PA-II locally vs needing to call out externally to API.

All we really care about is the readings from outside of our home so no need to put extra burden on the PurpleAir API.

Wondering if anyone has discovered a local end point that serve the data in say json format, or have done something similar.

Worse case scenario I could use the python requests library to scrape the live page for the two fields on an interval.

You can query /json or /json?live=true from the PA sensor itself and it will return either 2-minute average or immediate data, respectively.

Hi @dwhitemv - Thank you for that tip! I wanted to share the python script I threw together using what I learned form you.

anyone with Python3 installed should be able to copy this code into an file, update the aqi_live variable IP to your own, install python requests, and run python3

import requests
import json
from pprint import pprint
from requests.exceptions import HTTPError

# set the IP to the LOCAL ip of your PurpleAir device
aqi_live = "http://XXX.XXX.XXX.XXX/json?live=true"

# query the PurpleAir and catch any errors
    response = requests.get(aqi_live)
	# set json response to variable for future use
    data = response.json()

except HTTPError as http_err:
    print(f'HTTP error occurred: {http_err}')

except Exception as err:
    print(f'Other error occurred: {err}')

# setting values we care about to variables
sn_aqi_a = data['pm2.5_aqi']
sn_aqi_b = data['pm2.5_aqi_b']
sn_datetime = data['DateTime']

# print short message showing values creating newlines between
print(f"Current Time: {sn_datetime} \n AQI CHA: {sn_aqi_a} \n AQI_CHB: {sn_aqi_b}")

# uncomment next line to query and view all data from PurpleAir

Here is what the output looks like when I just ran before posting this up.

Current Time: 2022/10/21T01:38:05z 
 AQI CHA: 13 
 AQI_CHB: 19
1 Like