AirGradient Forum

Got original Pro DIY kit connected to Home Assistant via REST api

Apologies if this is well-known, but I was struggling with using the normal HA integration as I have the Pro DIY and can’t update its firmware with anything modern (nor for some reason connect to it directly with http). Though I’d prefer the normal integration, I had good luck getting all of its relevant data out via adding a REST sensor and extracting out all of the data to entities. This went straight into configuration.yaml, replacing with my actual location and token in the resource field:

sensor:
  - platform: rest
    name: "AirGradient Cloud Bedroom Raw"
    resource: "https://api.airgradient.com/public/api/v1/locations/<######>/measures/current?token=<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>"
    method: GET
    scan_interval: 60
    timeout: 15
    value_template: "{{ value_json.timestamp }}"
    json_attributes:
      - locationId
      - locationName
      - locationType
      - pm02
      - pm02_corrected
      - atmp
      - atmp_corrected
      - rhum
      - rhum_corrected
      - rco2
      - rco2_corrected
      - tvoc
      - tvocIndex
      - wifi
      - serialno
      - model


template:
  - sensor:
      # ---- Identity ----
      - name: "AirGradient Bedroom Model"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','model') }}"

      - name: "AirGradient Bedroom Serial"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','serialno') }}"

      # ---- CO2 ----
      - name: "AirGradient Bedroom CO2"
        unit_of_measurement: "ppm"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','rco2') }}"

      - name: "AirGradient Bedroom CO2 Corrected"
        unit_of_measurement: "ppm"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','rco2_corrected') }}"

      # ---- Particulates ----
      - name: "AirGradient Bedroom PM2.5"
        unit_of_measurement: "µg/m³"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','pm02') }}"

      - name: "AirGradient Bedroom PM2.5 Corrected"
        unit_of_measurement: "µg/m³"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','pm02_corrected') }}"

      # ---- Temperature ----
      - name: "AirGradient Bedroom Temperature"
        unit_of_measurement: "°C"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','atmp') }}"

      - name: "AirGradient Bedroom Temperature Corrected"
        unit_of_measurement: "°C"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','atmp_corrected') }}"

      # ---- Humidity ----
      - name: "AirGradient Bedroom Humidity"
        unit_of_measurement: "%"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','rhum') }}"

      - name: "AirGradient Bedroom Humidity Corrected"
        unit_of_measurement: "%"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','rhum_corrected') }}"

      # ---- VOC ----
      - name: "AirGradient Bedroom TVOC"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','tvoc') }}"

      - name: "AirGradient Bedroom TVOC Index"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','tvocIndex') }}"

      # ---- Wi-Fi signal ----
      - name: "AirGradient Bedroom WiFi RSSI"
        unit_of_measurement: "dBm"
        state: "{{ state_attr('sensor.airgradient_cloud_bedroom_raw','wifi') }}"

I removed any fields (latitude, longitude, other data that might only exist in newer devices) that show up as null in the raw data for me.

Let me know if you’ve already discovered a better way. I’ll pull this out into an include so it’s not clogging up my base configuration.yaml, but this gives you the idea.

Very nice. I might try to use this same model to retrieve metrics for my outdoor Max that uses cellular so the native integration doesn’t work for it at the moment.

At one point there was a beta firmware for the earlier boards that worked with the HA integration, but I can’t find the link now and it doesn’t seem like it was under active development.

Since you are a proficient HA user, if you have ESPHome experience you could try out my configurations for this board using that and it would natively report to HA without needing this YAML config.