Kuba Wolanin

Air Quality binding for openHAB2

By Kuba Wolanin
Published in Home automation
April 23, 2017
1 min read
Air Quality binding for openHAB2

Being a Krakow citizen, I know the struggle of breathing during the winter time. People burning trashes in their tiled stoves in the city is one of main reasons why we have to deal with air pollution. The first time I heard of Air quality index was when I moved to Krakow.

I was thinking about extending my home automation system with a feature that would warn me each time the air quality is bad.


After some online research I found AQIcn.org service that seemed perfect to my needs. It has an open API, is fairly well documented and needs just my e-mail address to get me started.

Shortly after I played around with the API, I’ve submitted a tutorial on openHAB community forum showing how to utilize the AQI data in the home automation setup.

But that wasn’t enough. The API was so powerful that I planned it to serve as a separate binding for openHAB!

With some trials and errors, reading through the openHAB Coding Guidelines and an amazing support from other openHAB developers, I’ve managed to submit my first pull request to the openhab2-addons repository. Here’s the latest AirQuality binding source coude available in the openHAB repository.

Use case

So now my home automation system contains a set of rules that utilizes the AQI value in my area. I’m tracking the AirQuality every hour. Here you can see the Grafana chart showing the AQI from last two months in Krakow/Skawina: aqi

For the automation I wrote a simple rule that would change my Xiaomi Gateway light color whenever AQI value changes:

rule "Air Quality to Xiaomi Gateway"
    Item Aqi_Description changed
    var String hsb

    switch Aqi_Description.state {
        case "HAZARDOUS":
            hsb = "343,100,49"
        case "VERY_UNHEALTHY":
            hsb = "280,100,60"
        case "UNHEALTHY":
            hsb = "345,100,80"
            hsb = "30,80,100"
        case "MODERATE":
            hsb = "50,80,100"
        case "GOOD":
            hsb = "160,100,60"

    sendCommand(Gateway_Color, hsb)

Check out the documentation of AirQuality binding that’ll hopefully get you started.


Next Article
Integrating Fanvil i30 with openHAB


Home automation
Misc Projects

Related Posts

Integrating Fanvil i30 with openHAB
April 14, 2020
2 min
© 2021, All Rights Reserved.

Quick Links


Social Media