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

**URL:** <https://community.openhab.org/t/how-can-i-determine-the-openhab-esh-version-in-my-binding/29880>\
**Category:** Other\
**Tags:** version, osgi, binding\
**Created:** [June 12, 2017, 5:01pm UTC](https://community.openhab.org/t/how-can-i-determine-the-openhab-esh-version-in-my-binding/29880 "2017-06-12T17:01:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakan](https://community.openhab.org/user_avatar/community.openhab.org/hakan/32/70815_2.png) [@hakan](https://community.openhab.org/u/hakan)\
**Post date:** [June 12, 2017, 5:01pm UTC](https://community.openhab.org/t/how-can-i-determine-the-openhab-esh-version-in-my-binding/29880/1 "2017-06-12T17:01:25Z")

</div>

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:

```auto
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 ☹

```auto
User-Agent=openHAB 2.1.0-SNAPSHOT / senseBox binding 2.1.0.201706121611

```

---

<div class="post-metadata">

**Author:** ![martinvw](https://community.openhab.org/user_avatar/community.openhab.org/martinvw/32/71288_2.png) [@martinvw](https://community.openhab.org/u/martinvw)\
**Post date:** [June 12, 2017, 8:37pm UTC](https://community.openhab.org/t/how-can-i-determine-the-openhab-esh-version-in-my-binding/29880/2 "2017-06-12T20:37:27Z")

</div>

~~Just found this while searching about some other idea I had~~ 😄

```java
OpenHAB.getVersion()

```

> <https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core/src/main/java/org/openhab/core/OpenHAB.java>

---

<div class="post-metadata">

**Author:** ![hakan](https://community.openhab.org/user_avatar/community.openhab.org/hakan/32/70815_2.png) [@hakan](https://community.openhab.org/u/hakan)\
**Post date:** [June 13, 2017, 3:52pm UTC](https://community.openhab.org/t/how-can-i-determine-the-openhab-esh-version-in-my-binding/29880/3 "2017-06-13T15:52:03Z")

</div>

> [@martinvw](#):
>
> OpenHAB.getVersion()

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

---

<div class="post-metadata">

**Author:** ![martinvw](https://community.openhab.org/user_avatar/community.openhab.org/martinvw/32/71288_2.png) [@martinvw](https://community.openhab.org/u/martinvw)\
**Post date:** [June 16, 2017, 7:15am UTC](https://community.openhab.org/t/how-can-i-determine-the-openhab-esh-version-in-my-binding/29880/4 "2017-06-16T07:15:17Z")

</div>

Correction bindings should not depend on the openHAB core
