This guide uses https://github.com/geerlingguy/airgradient-prometheus/ to set things up
-
Run ESPHome locally
# docker-compose.yml version: "3" services: esphome: container_name: esphome image: esphome/esphome volumes: - ./hass/esphome/config:/config - /etc/localtime:/etc/localtime:ro restart: always ports: - 6052:6052
Run
docker-compose up --build
.Visit http://localhost:6052 in a browser that supports WebSerial such as Chrome.
Do any initial setup.
-
Configure ESPHome secrets
Following instructions on geerlingguy/airgradient-prometheus, configure and add the following (copied from geerlingguy's readme) to the "Secrets" popup in ESPHome
--- # Provide a unique name for this AirGradient. name: airgradient-office # Encryption key for HA API access. # Generate a random 32-bit key with `openssl rand -base64 32` api_encryption_key: PASTE_BASE64_KEY_HERE # Set password for OTA updates. ota_password: otapassword # Configure a WiFi network connection. wifi_ssid: my-wifi-network wifi_password: my-wifi-password
Make sure to click "Save".
-
Connect your AirGradient device to your machine via USB.
-
Add device in ESPHome.
First open your browser console for useful information.
Click "Add device" in ESPHome. If it errors, click "Skip this step".
When prompted to select a device type, pick the device model listed in the console
The AirGradient ONE v9 is an ESP32-C3.
-
Add configuration for device and fix minor bugs.
Click "Edit" on the new device, and paste in the appropriate YAML from https://github.com/geerlingguy/airgradient-prometheus/blob/master/AirGradient-ESPHome/airgradient-one.yaml.
As of Feb 2024, the
airgradient-one.yaml
configuration is missing the requiredprometheus:
key in the YAML configuration.Append
prometheus:
at the end of the configuration.If not connecting to Home Assistant, add
reboot_timeout: 0s
to the API block. -
Go ahead and click on validate and then install.
-
Obtain the IP of your AirGradient, and open up
- http://DEVICE_ADDRESS:9926
- http://DEVICE_ADDRESS:9926/metrics
-
Now add to your Prometheus config
scrape_configs: - job_name: 'airgradient-bedroom' metrics_path: /metrics scrape_interval: 30s static_configs: - targets: ['airgradient-ip-address:9926']