[Bluetooth BlueZ binding] Access denied

Hi all, I just installed openHAB2.4.0 on my Ubuntu 16.04, with bluez 5.45. When I install Bluetooth binding from paperUI and search for devices, it shows me:
[ernal.discovery.BlueZDiscoveryService] - Cannot access BlueZ stack due to permission problems. Make sure that your OS user is part of the 'bluetooth' group of BlueZ.
However, I have to say that I checked the current user using openhab-cli info, and the information is shown below:
Version: 2.4.0 (Build)
User: openhab (Active Process 2195)
User Groups: openhab bluetooth

I think I have added user openhab to bluetooth group, but it can not work. I even add openhab to root, but still it can not work. Can anyone help me figure it out? I have been struggling for a long time!

BTW, I have the following two questions irrelative to this topic, but it confuses me alot.

  • Where is the binding installed from paperUI stored? I try to find any configure file and jsonDB, but there is no binding information.

  • How can I debug a single bundle? For example I saw the source code of BlueZBridgeHandler from here and I believe that this bundle gives me the wrong information. If I want to modify this source code, for example add some output sentence to check what exactly the error information is, like this message e in line 101
    if (e.getMessage() != null && e.getMessage().contains("AccessDenied"))

How can I use maven to install and execute my test? Any idea is valueable for me and thanks a lot!

[UPDATE] I just modifed the openhab2.service. In the service I use root, instead of openhab2, to start the service. Now it posts:
Failed to scan for Bluetooth devices: Native library is out of date. Please update the native library.
But I still don’t know why the priviledge of user “openhab” can not work.

After adding openhab to the group did you also reboot?

Typically you setup debugs for individual bindings in the karaf console.

Yes I have tried rebooting, but it can not work.

That is not the normal way to check Linux group membership. The easiest way is to use the “id” command.

If you are actually running OpenHAB as the root user you are running it in a totally unsupported manner and must either move to a supported restricted user or debug and fix any issues yourself.

I have solved this problem. Thanks Bruce. But can you instruct me how to solve the new problem?
[ERROR] [ernal.discovery.BlueZDiscoveryService] - Failed to scan for Bluetooth devices: Native library is out of date. Please update the native library.
I have struggled for a long time.

I do not know if this is your issue but I found this posting that says the normal binding works poorly but there is a 3rd party one that works well. I believe installation instructions are in that thread too.

Hi, I met the same problem today :
Cannot access BlueZ stack due to permission problems. Make sure that your OS user is part of the ‘bluetooth’ group of BlueZ
How did you solve this problem?
Thanks

Please follow instructions here.

https://github.com/sputnikdev/bluetooth-manager-tinyb
The issue is: it seems that in ubuntu, group “bluetooth” does not control the bluetooth adapter, and you need to manually add the in the file /etc/dbus-1/system.d/bluetooth.conf to give it the power to control the bluetooth adapter.

Thanks! Now it works

I created a PR to improve the docs: https://github.com/openhab/openhab2-addons/pull/6475

1 Like