Air Quality Binding - looking for testers

Great binding. Already configured, works properly. Good job!

Noticed a few errors this morning:

[WARN ] [airquality.handler.AirQualityHandler] - Error running aqicn.org (Air Quality) request: Server returned HTTP response code: 502 for URL: http://api.waqi.info/feed/geo:XX.XXXX;XX.XXXX/?token=XXXXXXXXXXXXXXXXXXXX

then

[WARN ] [airquality.handler.AirQualityHandler] - Error parsing aqicn.org (Air Quality) response: java.lang.NumberFormatException: Expected an int but was 2.4 at line 1 column 339 path $.data.iaqi.co.v

[WARN ] [airquality.handler.AirQualityHandler] - Error parsing aqicn.org (Air Quality) response: java.lang.NumberFormatException: Expected an int but was 2.6 at line 1 column 337 path $.data.iaqi.co.v

[WARN ] [airquality.handler.AirQualityHandler] - Error parsing aqicn.org (Air Quality) response: java.lang.NumberFormatException: Expected an int but was 2.7 at line 1 column 337 path $.data.iaqi.co.v

I suspect this is related to the format of data received for CO. From my raw json response:
"co":{"v":2.7}

Same here.

10:34:39.085 [DEBUG] [airquality.handler.AirQualityHandler] - aqiResponse = {"status":"ok","data":{"aqi":64,"attributions":[{"url":"http://www.luchtmeetnet.nl/","name":"RIVM - Rijksinstituut voor Volksgezondheid en Milieum, Landelijk Meetnet Luchtkwaliteit"}],"city":{"geo":[51.8xxxx,4.5xxxx],"name":"Hogeweg, Ridderkerk","url":"http://aqicn.org/city/netherland/ridderkerk/hogeweg/"},"dominentpol":"pm25","iaqi":{"h":{"v":61},"no2":{"v":28.1},"o3":{"v":4.4},"p":{"v":1014},"pm10":{"v":28},"pm25":{"v":64},"t":{"v":6.14}},"time":{"s":"2017-01-28 10:00:00","tz":"+01:00","v":1485597600}}}
10:34:39.087 [WARN ] [airquality.handler.AirQualityHandler] - Error parsing aqicn.org (Air Quality) response: java.lang.NumberFormatException: Expected an int but was 28.1 at line 1 column 366 path $.data.iaqi.no2.v

And here.

16:26:42.662 [WARN ] [airquality.handler.AirQualityHandler] - Error parsing aqicn.org (Air Quality) response: java.lang.NumberFormatException: Expected an int but was 0.1 at line 1 column 343 path $.data.iaqi.co.v

So I guess we need to wait for a fix.

Thank you for reporting the issues. Looks like the API changed today :open_mouth:
I’ll work on it in the next few days:

Quick update - as I thought, the API of WAQI changed. Sadly, without any notice or versioning.
So for now:

  • All measurements are kept as Float, not Integer values
  • Seems like there’s no longer Station ID in the payload :frowning:
  • There’s one additional value called dominentpol - I’m not sure what to do with this yet :wink:

I’m working on the bugfixes now. I’ll keep you updated!

Thanks again!
Kuba

B[quote=“kubawolanin, post:30, topic:20756”]
There’s one additional value called dominentpol - I’m not sure what to do with this yet :wink:
[/quote]

Probably ‘dominant pollutant’, the value that determines the index?

Looks lik there are some new values, too: h and p?

There is a new version 1.1.0 of the API in the docs

http://aqicn.org/json-api/doc/

h and p values were there all the time - it’s humidity and pressure.
And the version was 1.1.0 all the time IIRC :wink:

@PawelGrzembka @AndrewZ the issue is now resolved in the latest build.
Note that due to the API change, you need to remove Station ID item from your configs.
The safest approach would be to reinstall the Karaf bundle, but it should work without it as well.

Thank you!

1 Like

@kubawolanin all seems to be working properly, thank you!

The page now indicates 1.2.0: http://aqicn.org/json-api/doc
However I do not see the version number in any of the example requests/responses. If you were able to fetch this API version, would it make sense to verify it against the latest known version? This way you could at least generate a warning.

they are updating the API like crazy. This weekend the version was at 1.1.0 and they have now upgraded again. The 1.1.0 docs are not even available anymore.

@kubawolanin may I suggest an enhancement?
Currently the binding is using geo coordinates only, but the API itself allows to also query by station id (idx). Will be good to have this option in the binding configuration, this will allow to stick with the specific station if necessary. Thanks!

Hey Andrew,

I’ve just implemented that feature!

I’ve updated my first post on GitHub with the latest build.

What’s new:

Thank you! :slight_smile:

Just updated, all seems to be working properly. Thanks a lot, Kuba!

[WARN ] [airquality.handler.AirQualityHandler] - Error running aqicn.org (Air Quality) request: Configuration is incorrect

Another API change? Unfortunately I have no earlier raw json response to compare with.

@AndrewZ check your configuration in *.things file or in PaperUI. I checked my own configs just now and everything seems to run smoothly.

Air Quality Binding is now a part of openhab2-addons!

Thank you everyone for testing, improving and reviewing my code!
You no longer need to place a JAR file - just update your openHAB! :sunglasses:


Regarding the binding itself, a few breaking changes:

  1. Location configuration no longer understands semicolon - you need to use comma instead (which is now compliant with other bindings)
  2. I’ve removed stationUrl channel - I couldn’t find any reason to keep it. Let me know if you find any use case for it!
  3. Aqi_StationGeo item (and stationLocation channel) is now a Location element (instead of String) which allows you to display it on a map
2 Likes

@kubawolanin I’m using the same configuration for quite some time already and this error appears sporadically. I suppose this is how binding reacts to the invalid response from the server. I’ll probably need to keep debug on for a longer period.

I have updated to unstable Build #789 but the new binding is not available in Paper UI and it doesn’t install through my addons.cfg. What’s wrong?

I’m on build #798 - my binding is there :slight_smile: