How can I determine the openHab / ESH version in my binding?

My senseBox binding makes HTTP requests to the API of the project.

Wanting to be a good network citizen, I am setting an identifiable User-Agent string, in which the version of the binding is encoded:

Version version = FrameworkUtil.getBundle(this.getClass()).getVersion();

This allows me to put the version of the binding into the user agent, but I would like to have the version of openHAB and / or ESH as well. Is there some method to obtain this information programmatically?

Currently, my user agent is like the following, with the String “2.1.0-SNAPSHOT” manually hardcoded in the code :frowning:

User-Agent=openHAB 2.1.0-SNAPSHOT / senseBox binding

Just found this while searching about some other idea I had :smile:


Thank you, this solved my problem wonderfully. Time to amend the pull request and fix the last remaining TODO in it :smile:

Correction bindings should not depend on the openHAB core