Revival of Official Bluetooth Binding

Tags: #<Tag:0x00007f5c9de56fe0>

The easiest way would be to wait a week or so for the 2.5.3 release and then just upgrade to it. The release will have the latest version of the bluetooth binding you can just install through paperUI.

If you can’t wait that long then you download the 2.5.3 snapshots by following these instructions

i upgraded to 2.5.3 ,installed bluetooth binding 2.5.3 snapshot but i think something is wrong with my system.I get nothing at my PaperUi inbox.If i install the 3rd party market binding + tinyb binding i get a bluez bluetooth adapter and then i can scan for bluetooth devices.When i add a bluez adapter manually ,i set the right bt mac of my Rpi at binding settings ,and when i add the thing i get

Status: UNINITIALIZED - HANDLER_INITIALIZING_ERROR BlueZ JNI connection cannot be established.

fix it…like this

wget https://github.com/openhab/openhab-addons/raw/2.5.x/bundles/org.openhab.binding.bluetooth.bluez/src/main/resources/lib/armv6hf/libtinyb.so
wget https://github.com/openhab/openhab-addons/raw/2.5.x/bundles/org.openhab.binding.bluetooth.bluez/src/main/resources/lib/armv6hf/libjavatinyb.so
sudo cp lib* /opt/jdk/zulu8.40.0.178-ca-jdk1.8.0_222-linux_aarch32hf/jre/lib/aarch32/
sudo apt purge bluez
wget http://archive.raspberrypi.org/debian/pool/main/b/bluez/bluez_5.43-2+rpt2+deb9u2_armhf.deb
sudo dpkg -i bluez_5.43-2+rpt2+deb9u2_armhf.deb
sudo apt-get install pi-bluetooth
sudo usermod -a -G bluetooth openhab
sudo reboot

now the adapter is online and i get several bluetooth devices at inbox…Still i cant see devices thing channels like i did with 3rd party binding ,for example for my MiKettle i only get RSSI channel.

1 Like

The official bluetooth binding doesn’t currently have the full functionality that the 3rd party binding does, so you won’t see channels other than RSSI and maybe a battery channel. I’m working on it though!

1 Like

many thnx mate.

Is this still relevant, from the official Bluetooth binding here: https://www.openhab.org/addons/bindings/bluetooth.bluez/

“Please note that at least BlueZ 5.43 is required, while 5.48 or above are not (yet) supported either.”

Or will busters 5.5 default version work with the pi 4?

And any other install it requirement oddities with your fixes? Or a link would suffice.

Thanks for what you’re doing!

1 Like

From what I remember, the reason that the older versions were recommended is because the newer ones chose to hide certain gatt characteristics (battery level iirc) from getting queried the traditional way. Due to that the older BlueZ versions are considered a more faithful implementation of the bluetooth stack.

It might also be that tinyb does not work with the newer version anyway but I don’t know myself since I never bothered trying the newer version first.

Feel free to give it a shot and let us know how it goes!

1 Like

I guess what I’m asking is, what version BlueZ do you have, that you know works?
(Revealed via: bluetoothctl -v )
Thanks!

I’m currently using dbus and bluez v5.47. But I’ve also had my setup use dbus v5.5 and bluez v5.47, more or less on accident, it actually worked fine but I reverted back in order to try and fix an issue that ultimately wasn’t caused by the newer version at all.

Holy crap 2 days later I got it to work with this! More specifically though, I updated to the latest snapshot, did this fix, and added the thing below and am now seeing my Bluetooth adapter show up in PaperUI. It did automatically discover bluetooth devices so that’s a great sign. (I’m only trying to get bluetooth people presence functionality.) I’ll try playing around with getting the presence to work next, and report back. But anyone have any existing guides for next steps?

Thing:

Bridge bluetooth:bluez:hci0 "BluetoothAdapter" [ address="DC:00:00:00:00:00", discovery=false ]

BTW I have “openhab-distro: 2.5.4-snapshot, build #73”. I’m still pretty new to openhab, and especially snapshots so hope I did this right. And I’m hoping this shapshot/build has your latest Binding fixes.

THANKS!!!

Do you happen to have a URL with a changelog for your specific updates? Settings, etc? Or anything that could be helpful? I’m assuming the existing documentation is out of date, or especially not relevant to this snapshot. Thanks!

I don’t really have any meaningful URL I can point your towards since at this moment the bluetooth binding is rather bare of features since most of my work up until this point has just been fixing bugs. Right now the binding is stable and robust, but the extensions the only real useful aspect of the binding ATM. The generic beacon binding might be enough for you to work with if you get creative with rules.

But fret not! I have a PR in the works that will allow bluetooth device location to be tracked if you have multiple bluetooth adapters. It is the first of many feature enhancements that I have in mind.

1 Like

This is my first time using this. Again, I’m hoping to use this just for presence detection.

That said, I was able to search for things in the PaperUI Inbox, and added my phone as a Thing. My phone then showed ONLINE. Then I turned bluetooth on my phone off for a minute, then back on. PaperUI never showed it as ONLINE since. Its been a couple hours. I restarted my phone, still never showed up as ONLINE.

What are the expectations of this binding, and as I indicated above my snapshot (am I even using your recent updates?!?), should what I’m trying to do show my phone as ONLINE a few minutes later? Or am I supposed to do something else? Or am I doing this all wrong?.. Or did I find a bug?

Thanks!

Presence detection won’t work for phones since they randomly generate their mac address and change it every couple of minutes or so.
Phones do this for security reasons so I can’t complain about it. Just turning on bluetooth won’t work for presence detection but I think there are apps you can download that make you phone act like a bluetooth beacon though.

don’t count on Paper UI for this type of testing… look at the logs duh

WiFi presence detection with ARP ping works pretty well, and might have better range in your house than Bluetooth.

Many of us don’t trust in a single device for presence detection, as it’s not 100% reliable. But it can be fine depending on your use case.

Good news, I just finished writing my first draft of the roaming bluetooth device feature which allows a device to be tracked across multiple bluetooth adapters and keep track of which adapter it is closest to.
I need volunteers to be guinea pigs for testing since I lack any bluetooth beacons to test with, and the outbreak has made it difficult to obtain them.

This feature should mimic the feature from the 3rd party bluetooth binding. The only difference is that you need to add a Roaming Bluetooth Adapter thing which will appear in the inbox in order to activate the feature. This new adapter will act as a virtual bridge for bluetooth devices. So when devices are discovered you need to pick the discovered device for the roaming adapter.

To test this feature you need to uninstall the official bluetooth binding and upload these jars to the addons directory:

Required:
https://github.com/cpmeister/openhab-addons/raw/blind-engine-snapshots/org.openhab.binding.bluetooth-2.5.4-SNAPSHOT.jar

For Bluez users:
https://github.com/cpmeister/openhab-addons/raw/blind-engine-snapshots/org.openhab.binding.bluetooth.bluez-2.5.4-SNAPSHOT.jar

For bluegiga users:
https://github.com/cpmeister/openhab-addons/raw/blind-engine-snapshots/org.openhab.binding.bluetooth.bluegiga-2.5.4-SNAPSHOT.jar

Happy testing!
If nothing works let me know, I probably goofed.

Sorry I wasn’t clear; I was looking at both the logs & PaperUI.

In researching, and personal testing, I found the random mac is an issue with iphones, not Android (I only have Android phones), so I’m hoping this will work for me.

I’m struggling to find an Android beacon app that works with this, can anyone make any recommendations?

However, I found that not using any phone beacon app, I can get 2 Android phones to report their rssi values several times (even after reboots, etc), but ONLY while the phone is in pair mode (making itself discoverable I believe). Is this expected? Restarting the phone and turning the bluetooth on and off does NOT trigger any rssi events to openhab (but again, putting the phone is pair mode then gets rssi events to show up in openhab for a couple minues). I’m not quite sure if this is a configuration issue on my end, my 2 phones, the Bluetooth Binding, or openhab itself (or a beacon app is required).

BTW I’m using openhab logs to troubleshoot this and determine the rssi events.

Would your latest fix address any of this by any chance?

My configs:

Things:
Bridge bluetooth:bluez:hci0 "BluetoothAdapter" [address="[MY_ADAPTER_MAC_ADDRESS]", discovery=false]
bluetooth:beacon:hci0:b1 "Kevin Phone" (bluetooth:bluez:hci0) [address="[MY_PHONE_MAC_ADDRESS]"]
Item:
Number openhab4_Kevin_RSSI "Kevin Phone Beacon [%.0f]" PubItems {channel="bluetooth:beacon:hci0:b1:rssi"}

Thanks again for what you’re doing!

To do the update, where do we put the jars (pi 4/raspbian/Debian)? And do we first need to uninstall anything?

I’ve been playing around with “Beacon Simulator” for Android. It allows you to create simulated advertising beacons such as ibeacon, eddystone, & altbeacon. I tried creating several but nothing is recognized in PaperUi via a search in the inbox. The are a lot of seeing for these beacons tho that I don’t understand. Is this expected or should these be showing up? I’m testing it this way because if this does show up & work with openhab then I could potentially use this as a beacon on my phone to do the presence detection. Thanks!

UPDATE: Just reporting that BlueZ version 5.43 & 5.50 works with this. (ie, sudo apt-get update & sudo apt-get upgrade will not break this if going to 5.50)