Today I’ve submitted a pull request to openhab2-addons repo with my first binding attempt The README file explains all the basics needed to get it work in your environment. If not, please let me know!
Zip file is included to the first pull request comment. You just need to change the extension to jar
That’s great @kubawolanin Congrats on your first (of many?) bindings
I did not get around to follow the tutorial but using the binding will be a piece of cake That is by the way a very professional and informative README. If the binding works as good as the readme indicates, this will be a nice addition to everyone’s home!
Hey @kubawolanin!
Great to see this happening. Since air quality is nowadays hot topic in Poland tracking it with ease inside openhab is great idea!
I reviewed your code and found that JSON response handling could be improved. I removed synchronized block and instance field for keeping response. This value can be kept in local stack of refresh task. I also removed reflection calls in favor of direct method invocations. You can find sources in my fork of your widelec (fork in polish): splatch/openhab2-addons/feature/airquality.
I didn’t compile nor complete these changes because I don’t have up-to-date sources with all dependencies. Feel free to do whathever you want with this proposal. If you will have any questions about gson feel free to post questions or contact me in any way you prefer.
You are very likely first pole supplying OH2 compatible binding. Congratulations!
Wow, thank you so much for your expertise, Łukasz!
My “first language” is JavaScript, so it was an interesting experience for me to make this binding
I merged your widelec into my branch and added attribution to the classes you’ve improved.
Then I’ve squashed our commits into one.
Awesome stuff, I’m sure there’s much more for me to explore!
I am pulling data from station ID 5772 (Rotterdam).
To be of more help I have switched logging to DEBUG already.
Update: the README explains that this might be due to CO not being measured at his station. If so, I would expect the binding to handle this more gracefully, for example through a more descriptive message in the log like ‘station XXX doesn’t provide XXX measurement’.
Another issue (why I was looking at the logs in the first place).
The air quality for station 5772 is updated once an hour. But now, at 7:00 the observation time shows 6:00. Perhaps this is correct, but maybe the binding is not respecting time zones. I live in CET and like to know if observation time is correct or in UTC time zone (which would explain the 1 hour difference).
Update: This is the debug message:
2017-01-22 07:05:27.667 [DEBUG] [airquality.handler.AirQualityHandler] - aqiData = {"status":"ok","data":{"idx":5772,"aqi":103,"ti
me":{"v":1485064800,"s":"2017-01-22 06:00:00","tz":"+01:00"},"city":{"name":"Rotterdam","url":"http:\/\/aqicn.org\/city\/rotterdam
\/","geo":["51.9xxxx","4.4xxxx"]},"attributions":[{"name":"RIVM - Rijksinstituut voor Volksgezondheid en Milieum, Landelijk Meet
net Luchtkwaliteit","url":"http:\/\/www.luchtmeetnet.nl\/"},{"name":"World Air Quality Index Project","url":"http:\/\/waqi.info\/"
}],"iaqi":{"pm25":{"v":103},"pm10":{"v":35},"o3":{"v":1},"no2":{"v":41},"t":{"v":-6},"p":{"v":1027},"h":{"v":100}}}}
The observation time is in local time and the time zone is provided separately.
In my sitemap it is shown as 6:00 so the +1:00 is ignored.
And yes, the air quality is at 103 so I am not using the binding for nothing.
Hi Robert, many thanks for the testing! Much appreciated.
I will add the message you proposed to the logs. Great idea!
As for the timezones, it’s certainly a bug and I will handle that too
Everything’s in @Kai’s power - given that there are 70 PR’s to be merged (and we’re expecting 2.0 release soon), I think it’ll last for a couple months before it appears on the branch This gives us some time to test it heavily and find as many bugs as possible before it lands as official binding.
I’ll make updates of the JAR accordingly.
Cheers!
I hope it will be quicker! I have it on the radar and once 2.0 is out, I can again focus more on binding PRs. As quite some others are already eagerly helping on reviewing and testing, this will be much quicker! But so far, I haven’t seen an approval from any of the reviewers, so I will wait for that
I’ve noticed that there is no formatting like [%.1f °C] in the item configuration example provided, but everything is displayed as it should. Is this some sort of default behavior specific for this binding?
Many thanks to the Author!
I was thinking about it actually but couldn’t find time lately to research all possible units for values like PM2.5, NO,O2 etc. Would you be interested in providing these? I’d appreciate your help
Cheers!
It depends on what the actual value means. Is it “ppm” or just an index?
I am more interested in the meaning of the values, for example in a scale from HEALTHY to HAZARDOUS.
I’ve installed the binding by changing from .zip to .jar. Placed inside of addons and rebooted. Binding has shown up in PaperUI but I’ve encountered the following error in PaperUI
Status: OFFLINE - COMMUNICATION_ERROR java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 27 path $.data
Re-entered API key, generated a second lot of geo coordinates from different supplier http://www.gps-coordinates.net. But still returning duplicate error from above.
I’d be more than happy to send my API key and coordinates privately for you to replicate the results?