Measuring Air Quality with

(Kuba Wolanin) #1

Hello there!
In the last couple of days in Poland we’ve seen a drastic increase of AQI.
This is why I thought I will share my openHAB2 setup of air quality measurement :slight_smile:

Just a quick update - you no longer need all of it - you can use the AirQuality binding :slight_smile:


We will utilize an API of so first thing you need to do is

Setting up your openHAB

  1. Create 3 items (see airquality.items file)
  • Number AirQualityIndex "AQI" - store AQI value
  • String AirQuality - This will display human-friendly SCALE transformation output
  • Switch AirQualityRerun - simple switch for fetching new data
  1. Create a airquality.rules file containing a simple rule for retrieving data from API and sending them accordingly to your items.
    Remember to change your geo coordinates and API token:
    var String coordinates = "37.14360;-115.482399"
    var String token = "YOURTOKEN"
  1. Add some nice SCALE Transformation (here’s Polish version as well)

And you’re done! :slight_smile:

The API has much more details inside, that you can measure as well (like CO, PM2.5 levels etc).

Here’s example response from the API:

  "status": "ok",
  "data": {
    "idx": 3402,
    "aqi": 190,
    "time": {
      "v": 1483988400,
      "s": "2017-01-09 19:00:00",
      "tz": "+01:00"
    "city": {
      "name": "Aleja Krasi\u0144skiego, Krak\u00f3w, Ma\u0142opolska",
      "url": "http:\/\/\/city\/poland\/malopolska\/krakow\/aleja-krasinskiego\/",
      "geo": ["50.057678", "19.926189"]
    "attributions": [{
      "name": "Regional Inspectorate for Environmental Protection in Krakow (WIO\u015a - Wojew\u00f3dzki Inspektorat Ochrony \u015arodowiska w Krakowie)",
      "url": "http:\/\/\/"
    }, {
      "name": "World Air Quality Index Project",
      "url": "http:\/\/\/"
    "iaqi": {
      "pm25": {
        "v": 190
      "pm10": {
        "v": 137
      "no2": {
        "v": 45
      "co": {
        "v": 19
      "t": {
        "v": -9
      "p": {
        "v": 1024
      "h": {
        "v": 72

Air Quality Binding - looking for testers
(Kuba Wolanin) #2

Quick question - would you be interested in having a dedicated openHAB2 binding for measuring Air Quality Index?

There would be one Thing containing mulitple channels, like aqi, pm25,, pm10 and so on.
I was thinking about it and am willing to do it if there’s enough interest :slight_smile:


(Bogumil J.) #3

Yes, Kuba :wink:

( ) #4

Hey @kubawolanin,
I didn’t know about “AQI” but I really like it. Will add it to my system later this week :thumbsup:

A binding would be great! Looking forward to it!

(Kuba Wolanin) #5

Just a quick update - you no longer need all of it - you can use the AirQuality binding :slight_smile: