Closed metbril closed 7 years ago
Hey Robert, thanks for continuing tests! I need to look at it more closely. After the fix I applied, the measurements in the binding are equal with what's stated on the website (yeah, the air is that bad where I live 😕 )
Do you have a timezone properly set on your device? Just asking because I didn't (that's why I didn't find this bug before you did 😉 )
$ date
ma 23 jan 2017 21:28:14 CET
I've added NYC to the mix:
21:40:32.994 [DEBUG] [airquality.handler.AirQualityHandler] - aqiResponse = {"status":"ok","data":{"idx":3309,"aqi":18,"time":{"v":1485180000,"s":"2017-01-23 14:00:00","tz":"-05:00"},"city":{"name":"New York","url":"http:\/\/aqicn.org\/city\/newyork\/","geo":["40.7127837","-74.0059413"]},"attributions":[{"name":"New York State Department of Environmental Conservation (NYSDEC)","url":"http:\/\/www.dec.ny.gov\/"},{"name":"Air Now - US EPA","url":"http:\/\/www.airnow.gov\/"},{"name":"World Air Quality Index Project","url":"http:\/\/waqi.info\/"}],"iaqi":{"pm25":{"v":18},"o3":{"v":22},"no2":{"v":10},"co":{"v":1},"t":{"v":4},"d":{"v":-1},"p":{"v":1005},"h":{"v":70},"w":{"v":10}}}}
NYC: "time":{"v":1485180000,"s":"2017-01-23 14:00:00","tz":"-05:00"}
I can only conclude that the time in the message is local time and that the time zone difference is stated:
EST (local time): 14:00 (GMT-5) GMT: 19:00 (EST+5) CET: 20:00 (GMT+1)
Help wanted from @ThomDietrich or @splatch?
@rtvb I saw your comment but didn't have time to verify it yet. If I understand correctly "s" is showing local time of place for which index is published. This means that we might need to do a little bit more dance than just using passed TZ. After gluing it we will just get GMT time which still may not be a local time.
As long as DateTime items get populated with a local time, it's just fine. I guess that computing GMT and returning it in the channel including the proper timezone ("Z") would suffice, don't you think?
I decided to follow @rtvb advice and just display the "S" value as it is. I'll update JAR shortly in the main PR
That was not my advice. I meant MY local time, not that of the station. As far as I'm concerned I still consider this a bug since a DateTime item in OH is always considered to be in the time zone of the OH installation and NOT in any other time zone.
I did some additional testing. Below you find logging data for 2 stations.
RTD: "time":{"v":1485201600,"s":"2017-01-23 20:00:00","tz":"+01:00"} MOW: "time":{"v":1485205200,"s":"2017-01-23 21:00:00","tz":"+03:00"}
The time for RTD is shown as
21:00
in the sitemap The time for MOW is shown as22:00
in the sitemapThe latter can't be true, since this is logged at
21:02:55.850
So now the question is whether or not the times in the JSON are in GMT or local time. The API docs should make this clear.
http://aqicn.org/api/ / http://aqicn.org/json-api/doc/
So, perhaps the time does not need to be converted after all.
The timezone should be added to the date, to be able to present it local openHAB time.
My guess is, that RTD observation is 19:00 GMT and Moscow observation is 18:00 GMT. But I'm not sure.