PurpleAir local API

The purpleair device on my local network will return a JSON dump of current state over http at the /json endpoint. Having a local polling integration would be a great addition to the cloud-based purpleair integration already provided.

I was able to simulate this using the REST integration. It works pretty well, though it would be nice to have real support. As a bonus, you can read the AQI values from the sensor, not available via the API.

rest:
  - resource: http://purpleair.lan/json?live=true
    sensor:
      - name: "PM1.0 Ch A"
        value_template: "{{ value_json['pm1_0_atm'] }}"
        device_class: pm1
        unit_of_measurement: "µg/m³"
      - name: "PM1.0 Ch B"
        value_template: "{{ value_json['pm1_0_atm_b'] }}"
        device_class: pm1
        unit_of_measurement: "µg/m³"
      - name: "PM2.5 Ch A"
        value_template: "{{ value_json['pm2_5_atm'] }}"
        device_class: pm25
        unit_of_measurement: "µg/m³"
      - name: "PM2.5 Ch B"
        value_template: "{{ value_json['pm2_5_atm_b'] }}"
        device_class: pm25
        unit_of_measurement: "µg/m³"
      - name: "PM10 Ch A"
        value_template: "{{ value_json['pm10_0_atm'] }}"
        device_class: pm10
        unit_of_measurement: "µg/m³"
      - name: "PM10 Ch B"
        value_template: "{{ value_json['pm10_0_atm_b'] }}"
        device_class: pm10
        unit_of_measurement: "µg/m³"
      - name: "PM2.5 AQI Ch A"
        value_template: "{{ value_json['pm2.5_aqi'] }}"
        device_class: aqi
        state_class: measurement
      - name: "PM2.5 AQI Ch B"
        value_template: "{{ value_json['pm2.5_aqi_b'] }}"
        device_class: aqi
        state_class: measurement
1 Like

This is awesome. Exactly what I needed. Thanks! Works great with latest PurpleAir as of 2023-06.

Have you seen this set of instructions:
https://www.reddit.com/r/homeassistant/comments/tbhdvb/tutorial_complete_detailed_purpleair_integration/
I’ve been using it for over a year now with a PA-II-Flex outdoor locally and it’s been great.