Openhab-addons: Air Quality Binding Error

Created on 16 Apr 2018  路  28Comments  路  Source: openhab/openhab-addons

It seems that this binding doesn't work / work unrealiably on the latest version.
Reported by multiple users on the community forum.

Issue:
[airquality.handler.AirQualityHandler] - Error in aqicn.org (Air Quality) response: missing data sub-object

I'm using this binding on a Raspberry Pi 3 in Docker, but as others reported nothing affects this binding, it doesn't work at all on any hardware.

Most helpful comment

@gigderoma

I'm sure something is wrong on server side :)

screenshot 1

Anyway, if I can, I'll contact the team with this issue...

All 28 comments

I have same error. Official OH2.2.

@kubawolanin since you are the original author do you have idea? And maybe time to resolve it?

Same issue here on two different installs (OH2.2.0)

Hmm I can confirm the issue occurrs on my setup as well. It's definitely related to the API change. And it's not the first time...
Personally I am not able to code at the moment.vwe should check what has been changed in the JSON response from the AQICN and adjust the binding acccordingly.

Same with me. Latest snapshot from 18th of April 2018

I've reproduced the bug.

http://api.waqi.info/feed/geo:44.984337;9.872792/?token=TOKEN

returned data: null, whereas

http://api.waqi.info/feed/geo:44.984;9.872/?token=TOKEN

returned the data as expected.
I'd suggest to remove a couple of digits from the latitude and longitude and see if you get anything...

I will contact the API provider so they address this issue.
Until then, let's stick to the workaround described above.

Cheers!

In my case, the station is configured by ID and not by geo coordinates and I am getting the error.

@kubawolanin I have clicked the second link, but I get the same response as the first one:

{"status":"error","data":"Invalid key"}

@rkrisi because you need to provide a valid API key in place of TOKEN.

@kubawolanin yes I saw it right after I sent the comment :) For me it seems that this solved the issue.

it just solved it for 1-2 hours, now I'm back where I was

it's working now without any workaround ... what happened?

@nesys It is working sometimes. For me, now it is not working....

When I open the URL that is reported in the things configuration in a browser, I get a valid response.

Status: OFFLINE - COMMUNICATION_ERROR
Server returned HTTP response code: 403 for URL: http://api.waqi.info/feed/geo:47.3667;8.5500/?token=xxxxx

Displaying the response content might help to debug the issue. The status label is wrong, too. The server is not offline.

My security suite (F-Secure) is blocking the API URL. I have to turn it off to test it. Why is it blacklisted?

@rkrisi yes you are right .. now not working again also for me :(

Hello @kubawolanin , when I change the setting of the thing (e.g. I removed the geo data and used only the station ID), it works once, but after 2 hours it again comes back with this error message. Maybe this can help you. Regards, Siggi
Ahh, sorry, it updated once correct one hour later and 2 hours later I got the error.

Found this report after I wrote about it on the OH community forum:

I think I found a problem with the Airquality binding not storing the correct value in the API key field.

Every hour, when the binding refresh the AQI it will stop with the following error in the openhab log:

[WARN ] [airquality.handler.AirQualityHandler] - Error in aqicn.org (Air Quality) response: missing data sub-object
Looking at the Paper UI item properties I can see that the value stored in the API token key is wrong (too short) and the item will still fail and go offline when trying to edit and enter the correct key. I counted the number of characters and found that it match the one for the API key of the weatherunderground binding.

As a quick and temporary fix, deleting and re-creating the item in Paper UI will return the item to online status for a while, so does reloading the model if you created it with a THING file.

@Catskinner , I believe this has nothing to do with the API key, because I didn't change this field, but when I update any other field (e.g. refresh intervall) then it is working once. Also by random over the day it is suddently again getting data from AQI site and one request period later (2 hours at me) it is going back to error message about missing sub type ...
Regards, Siggi

Neither did I change the API key field at first. What happened is that the AQI binding stopped with the error and I went to look at the properties in the paper UI. What I immediately saw was that the number of characters hidden by the * in the API key token field was much shorter than the actual length of the API token.

Obviously it made me curious and I tried to edit the field and restore the correct token - which didn't work in my case. I still have to reload the THINGS file in order to return the AQI to online.

It made me curious about it and I opened every item to indetify from where the AQI would get the wrong value. In the end I managed to find that the API key in the weatherunderground binding had exactly the same number of characters. So IMHO I think that something worth investigating.

guys, any update on this? FYI I never changed my API key, and sometimes it works for few minutes, but most of the time it is not working.

The status label is wrong, too. The server is not offline.

@sbaechler It's not the status of the server, but the Thing itself. Read more in the docs.

it just solved it for 1-2 hours, now I'm back where I was

It is working sometimes. For me, now it is not working....

I never changed my API key, and sometimes it works for few minutes, but most of the time it is not working.

@nesys and that is IMO clearly indicating that it's not an issue with the binding.

All this binding does is a periodic request to the following URL:
http://api.waqi.info/feed/geo:LAT;LON/?token=API_KEY
or @stationId instead of geo:, depending on your configuration.

If the data is not there, or we receive a malformed/inaccurate or just empty response from the server, there's not much we can do about this...

I would suggest you contacting the AQICn team who's providing this API for us.

It would also be useful if you set your logging level to DEBUG and report the results here - it would help tremendously anyone investigating this issue.

Best regards

OK, I'll try to help. I set the log level to DEBUG for the binding and this is what I got back.

Today at 12:08 I registered a failure in the openhab.log:

2018-05-03 12:08:06.507 [WARN ] [airquality.handler.AirQualityHandler] - Error in aqicn.org (Air Quality) response: missing data sub-object

Which was immediately reflected in the events.log:

2018-05-03 12:08:06.518 [hingStatusInfoChangedEvent] - 'airquality:aqi:home' changed from ONLINE: Attributions: Israel Ministry of Environmental Protection to OFFLINE (COMMUNICATION_ERROR): missing data sub-object 2018-05-03 12:08:06.526 [vent.ItemStateChangedEvent] - AQI changed from 130 to UNDEF

At 12:24 I forced a reload of the airquality.things by simply opening the file, deleting the "a" from the first word typing it again and saving the file. and this is what was logged in the openhab.log file:

05-03 12:24:26.148 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'airquality.things' 2018-05-03 12:24:26.236 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'airquality.things' 2018-05-03 12:24:26.867 [WARN ] [airquality.handler.AirQualityHandler] - Error in aqicn.org (Air Quality) response: missing data sub-object

Followed by the events logged in the events.log which show how the binding was restored:

2018-05-03 12:24:26.203 [hingStatusInfoChangedEvent] - 'airquality:aqi:home' changed from OFFLINE (COMMUNICATION_ERROR): missing data sub-object to ONLINE 2018-05-03 12:24:26.213 [me.event.ThingUpdatedEvent] - Thing 'airquality:aqi:home' has been updated. 2018-05-03 12:24:26.265 [me.event.ThingUpdatedEvent] - Thing 'airquality:aqi:home' has been updated. 2018-05-03 12:24:26.877 [hingStatusInfoChangedEvent] - 'airquality:aqi:home' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): missing data sub-object 2018-05-03 12:24:26.894 [hingStatusInfoChangedEvent] - 'airquality:aqi:home' changed from OFFLINE (COMMUNICATION_ERROR): missing data sub-object to ONLINE: Attributions: Israel Ministry of Environmental Protection 2018-05-03 12:24:26.901 [vent.ItemStateChangedEvent] - AQI changed from UNDEF to 103

Nothing else beside forcing a reload of the things and yet the binding managed to interpret correctly the reply once it was reloaded.

I'd be interested in your ideas and suggestions because this is really baffling me.

I've been running http://api.waqi.info/feed/@stationID/?token=API_KEY with the http binding and getting the values with JSONPATH for a day. The only problem I face is that the info is refreshed (server side) about an hour later than what you can find by navigating to the website, but I'm getting no errors.

I've the same problem with binding-airquality - 2.3.0.SNAPSHOT version. The way to temporarily obtain a correct response is to slightly change the coordinates in the request. I presume the problem is on the server side then since after a while also the new coordinates gives the same problem. From tcpdump you can see that the request from OH is exactly the same ( except for the little change on the coordinates ) so the server for some strange reason is unwilling to provide the correct JSON data

image

@gigderoma

I'm sure something is wrong on server side :)

screenshot 1

Anyway, if I can, I'll contact the team with this issue...

I believe you are right. Another trick is to restart the binding from the Karaf console. I tried it yesterday and saw that it would sometime fail with the "missing data sub-object"error and sometime retrieve the correct value.

It looks like the responses from the server side are either malformed sometime or incorrect.

I have contacted them through their site, but I haven't got any responses yet...

Did someone try this from the Openhab machine?
curl http://api.waqi.info/feed/geo:48.7754%3B9.1818/?token=TOKEN
instead of
curl http://api.waqi.info/feed/geo:48.7754;9.1818/?token=TOKEN

Semicolon used for geo returns error, where urlencoded semicolon returns expected result.

Cheers
Christian

Was this page helpful?
0 / 5 - 0 ratings