Restoring AirGradient devices to stock firmware

Sunday, November 3rd, 2024 at 08:57am

For a while now I have had a couple of AirGradient Air Quality Monitors as part of my home automation. One has been mounted to the wall near my desk and has been quite interesting seeing how the CO2 levels change throughout the day, especially when I have the study door closed. The other is the outdoor model which I got to have a more reliable outdoor device and also so I can compare the levels of particulates between my study and the wider world.

The first thing I did when I got them was to reflash them with ESPHome as I wanted them to report to Home Assistant, not to the cloud service. This always felt a bit clunky and I was using different config, one using ajfriesen/ESPHome-AirGradient and the other MallocArray/airgradient_esphome.

A few months ago they announced that the latest firmware would have direct integration with Home Assistant. This weekend I finally got around to checking that out, but it had a few rough edges.

Reverting to the latest stock firmware was easy, it was possible to do over USB directly from the browser. The only tricky part is that I didn’t want to take down the outdoor unit, so a long cable and my laptop was the answer there.

Once they were reflashed I could see in their log that they were working, but I was a bit stuck as there was no obvious next step. They were connected to my network, but there was no automatic discovery in Home Assistant.

I am running Home Assistant in a non standard way (via docker so I only have core features) so having to add devices manually is not unexpected, but if I tried to go to the web interface the devices exposed all I got was:

Not found: /

Was this correct? Did it not reflash correctly?

The first thing I came across was that there is MQTT support. Ah, maybe that is how they communicate with Home Assistant?

However the information on enabling MQTT said it was via the dashboard, but my devices are not connected to the cloud dashboard, I don’t even have an account there…

More stumbling around led me to a forum post and the Local Server API documentation. Now I knew to hit the /config endpoint I could see and change the settings and now they were reporting to MQTT.

Still no auto discovery in Home Assistant… so I did something I should have tried earlier, adding the integration manually with the ip addresses of the devices. This worked.

It turns out that I didn’t need to enabled MQTT, but I have left that enabled as I log all the MQTT messages, so it might be useful for debugging.

I also need to raise a ticket, that Not found: / was not helpful. If a device exposes a webserver then hitting to root endpoint should give something useful about the device, it doesn’t need to be a fancy status page, it could simply be a static link to relevant documentation…

Tagged with: