Revival of Official Bluetooth Binding

What library are you relying on ? Still TinyB ?

I still use TinyB. Can’t wait to switch over to your new dbus binding though.

Ok, I think I’ve got gatt support working. There still seems to be a few hickups with installing the binding since it requires the same apache-commons-collections dependency as the 3rd party binding.
But if you don’t already have that dependency installed you can install it by running the following in the openhap-cli:

bundle:install -s https://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar

Here is latest bluetooth jar:
https://github.com/cpmeister/openhab-addons/raw/blind-engine-snapshots/org.openhab.binding.bluetooth-2.5.9.jar
You may notice that it is version 2.5.9, not 2.5.10-SNAPSHOT, which is due to my current build environment being out of date. Just make sure to uninstall openhab’s built-in bluetooth bundle using bundle:uninstall <bundleNumber> in the console before trying to run this new one.

Also here are the latest bluez and bluegiga bindings in case you run into some errors with the ones you already have installed. They are purely optional unless you run into problems.
https://github.com/cpmeister/openhab-addons/raw/blind-engine-snapshots/org.openhab.binding.bluetooth.bluegiga-2.5.9.jar

https://github.com/cpmeister/openhab-addons/raw/blind-engine-snapshots/org.openhab.binding.bluetooth.bluez-2.5.9.jar

Happy testing!

1 Like

Thanks for the offer, but I managed to get my tests working with my Govee temperature sensors (they are better used as beacons but they did have some services when you connect to them which is good enough for me to test with.

I’ve already created a binding for the Govee devices that should become available once the OH3 release goes out.

2 Likes

I just noticed a bug in the code that prevented the readable characteristics from auto-updating every 30 seconds. I just fixed it so you just need to redownload the bluetooth jar to get the changes.

Thanks for all the hard work on bringing the official bluetooth binding back from the dead!

I’m new to BLE and GATT but I’ve got a couple of Inkbird temperature & humidity sensors that I’d love to be able to read the details from in openhab. I’ve got a working blueZ (5.43) install on the RPi I’m running my openhab (2.5.9) install on and can connect and interrogate the sensors using bluetoothctl.

I’ve tried uninstalling the official bluetooth binding and adding the latest jars you posted above to my addons directory using the instructions above. However, whilst I can scan using the bluetooth binding and find the Inkbird temp sensors when I add them as a thing I still only see an RSSI channel.

Can you provide any more detail about what I should see when I add a device from the inbox as a thing? Is the expectation that I should be getting one channel per characteristic? Is there a config file somewhere to add the GATT characterists or should it just detect all that are available?

Thanks in advance for your help and great work on the binding!

If you only see the rssi channel then that means that your device was created as a beacon type. Try creating your device manually as a connected thing type instead. If it didn’t show up as a connected type during discovery then it means either it can’t be connected to or there was some other issue.

If after creating the connected type the device refuses to go online then I suspect that either your temperature sensors really are just beacons (which means that they broadcast their data through discovery advertisements, not through connections), or your device has some special protocol that I haven’t written support for yet.

Hi Connor,

Thanks for the rapid reply. The device does appear as a connected device both in the inbox:
image

and when created in the list of things:
image

but when I look at the detail I see only RSSI:
image

From bluetoothctl I can connect and explore the characteristics:
[sps]# list-attributes 49:42:06:00:00:8D
Primary Service
/org/bluez/hci0/dev_49_42_06_00_00_8D/service001f
0000fff0-0000-1000-8000-00805f9b34fb
Unknown
Characteristic
/org/bluez/hci0/dev_49_42_06_00_00_8D/service001f/char0039
0000fff9-0000-1000-8000-00805f9b34fb
Unknown
Descriptor
/org/bluez/hci0/dev_49_42_06_00_00_8D/service001f/char0039/desc003b
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
Characteristic
/org/bluez/hci0/dev_49_42_06_00_00_8D/service001f/char0036
0000fff8-0000-1000-8000-00805f9b34fb
Unknown
Descriptor
/org/bluez/hci0/dev_49_42_06_00_00_8D/service001f/char0036/desc0038
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
Characteristic
/org/bluez/hci0/dev_49_42_06_00_00_8D/service001f/char0033
0000fff7-0000-1000-8000-00805f9b34fb
Unknown

I’m actually wondering if I’m picking up your binding correctly. Any tips on how I confirm that I definitely have your binding loaded correctly?

From your screenshots it looks as if none of the advertised gatt characteristics are standard. It might be the case that the binding has no way of knowing how to display those characteristics so it doesn’t even try. You might be out of luck on this for now until you can reverse engineer the protocol being used by the sensor.
If you can figure the protocol I can add support for it in the binding.

Edit: there is a chance that those characteristics might be known somewhere so I’ll have to look into that.

I still can’t see any of the GATT characteristics but RSSI
I have 4-5 Xiaomi Mijia temperature and humidity sensor waiting for proper binding :frowning:
I tried connected and in beacon mode with no luck, both original and hacked firmwares, same, just RSSI no temperature neither humidity nor battery…

1 Like

The binding doesn’t work on OH3 :frowning: i have xiaomi temperature sensor too.

I have PR for adding it into OH3. It requires some changes in the core before it can get merged though. I still need to do more testing on OH3 before I’ll post a jar for it here though.

1 Like

Thanks for your work. I will test it when the jar will be available.

Did you uninstall the official binding and then manually install the latest jar in the addon folder?

I have Openhab v2.5.9, I have installed packages listed above by you, but system stated that those are allready installed and restarted OH services.

I have digged out ESP32 DEVBOARDV1 from shelve and flashed it with latest OpenMqttGateway. It hooked all BLE devices instantly so for now I’m using it over MQTT to send data to OH. One thing do:
Xiaomi humidity and temp sensors does not send data over BLE, those need to be flashed with custom firmware: https://github.com/atc1441/ATC_MiThermometer
only after that ESP starts sending temp&humidity and battery info. I think there is something to do with xiaomi encryption or something…

Next thing to hook up is Mi Kettle over BLE!

This is not the thread but, i have the same xiaomi sensor and work great over ble with https://github.com/JsBergbau/MiTemperature2
I will dig into your link to see what is about

devil is, to make it work with OH2, not just with scripts ;), in details…))

You need to uninstall the existing ones before you try installing the new ones. It won’t work if you don’t do that.

Thanks I will certainly try that later, as I do not want to mess up things now, spent 3 days trying to hook up those bloody sensors this way or other.

I’m not sure if I’m doing right, so I did the following:
uninstalled bundles, then installed them using openhab-cli console:

testing your method…

The command is supposed to be bundle:uninstall <bundleId>
bundleId would be the number associated with that installed bundle, use bundle:list to get a list of all the bundles and their associated bundle ids. You need to find the id of the currently installed bluetooth binding then uninstall id.

After you successfully uninstall the old binding the new binding should work after restarting OH.