Topics
During another problem/trouble shooting I ran:
sudo systemctl stop openhab2 sudo openhab-cli clean-cache sudo systemctl start openhab2
That seems to remove the BT Bindings... but a reinstall fixed it (and no Things was lost)
As my openHAB installation is on a Laptop with Ubuntu 18-04 (Server, no UI) i knew that Bluetooth (BT) was somewhat avaliable.
The main purpose of playing with BT is "whos home" and "when has a devices been seen last time" - do look at this link, as we will use this excellent binding.
An interesting part to notice there is:
The easiest and most effective way to detect presence is to use so called "Bluetooth beacon" devices.
Normally, most of Bluetooth devices broadcast messages, however there are some devices that try to hide themselves from receivers providing privacy for their owners. Many of modern mobile phones (iPhone and Android) every so often (roughly every 10 minutes) randomly generate a new Bluetooth address and abandon old one making it impossible to track them by its address.
The latter part being a problem I think. Do read these links: Bluetooth Technology Protecting Your Privacy and MAC address randomization joins Apples heap of iOS 8.....
Theres a excellent community thread at https://community.openhab.org/t/3rd-party-bluetooth-binding-beta-testers-needed for this Binding
Add BT Support in Ubuntu
First discovery was that the Ubuntu OS had no BT installed, so we need to do this:
sudo apt-get install bluez sudo systemctl status bluetooth ? bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2019-01-23 18:27:43 UTC; 2 days ago Docs: man:bluetoothd(8) Main PID: 14880 (bluetoothd) Status: "Running" Tasks: 1 (limit: 3930) CGroup: /system.slice/bluetooth.service ??14880 /usr/lib/bluetooth/bluetoothd Jan 23 18:27:43 robin systemd[1]: Starting Bluetooth service... Jan 23 18:27:43 robin bluetoothd[14880]: Bluetooth daemon 5.48 Jan 23 18:27:43 robin bluetoothd[14880]: Starting SDP server Jan 23 18:27:43 robin systemd[1]: Started Bluetooth service. Jan 23 18:27:43 robin bluetoothd[14880]: Bluetooth management interface 1.14 initialized
Ok, so BT was up and running, and to make sure openHAB could use it:
sudo usermod -a -G bluetooth openhab sudo systemctl daemon-reload sudo systemctl restart bluetooth
Test discovery and functionality
A little testing of discovery etc:
sudo bluetoothctl [NEW] Controller F0:03:8C:61:7E:2E Bluetooth robin [default] [NEW] Device 08:6D:41:E7:FF:7B 08-6D-41-E7-FF-7B [NEW] Device 53:EA:0B:88:DC:13 53-EA-0B-88-DC-13 Agent registered [CHG] Device 08:6D:41:E7:FF:7B RSSI: -79 [bluetooth]# list Controller F0:03:8C:61:7E:2E Bluetooth robin [default] [bluetooth]# [bluetooth]# show Controller F0:03:8C:61:7E:2E (public) Name: robin Alias: Bluetooth robin Class: 0x0000010c Powered: yes Discoverable: no Pairable: yes UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) Modalias: usb:v1D6Bp0246d0530 Discovering: yes [bluetooth]#
Scan for devices:
[bluetooth]# scan on Discovery started [CHG] Device 08:6D:41:E7:FF:7B RSSI: -79 [CHG] Device 08:6D:41:E7:FF:7B RSSI: -78 [CHG] Device 53:EA:0B:88:DC:13 RSSI: -75 [CHG] Device 53:EA:0B:88:DC:13 ManufacturerData Key: 0x004c [CHG] Device 53:EA:0B:88:DC:13 ManufacturerData Value: 0c 0e 08 f4 f0 09 f7 7f b0 f5 01 69 dd 37 b6 eb ...........i.7.. [CHG] Device 53:EA:0B:88:DC:13 RSSI: -75 [CHG] Device 53:EA:0B:88:DC:13 ManufacturerData Key: 0x004c [CHG] Device 53:EA:0B:88:DC:13 ManufacturerData Value: 0c 0e 08 f5 f0 21 56 5b 46 b4 8c 0a 54 79 16 02 .....!V[F...Ty.. [CHG] Device 08:6D:41:E7:FF:7B RSSI: -78 [CHG] Device 53:EA:0B:88:DC:13 RSSI: -76 [CHG] Device 08:6D:41:E7:FF:7B RSSI: -81 [bluetooth]# [CHG] Device 53:EA:0B:88:DC:13 RSSI: -78
Installing Addons in openHAB
OK - so we are ready for openHAB - the short story is to follow https://github.com/sputnikdev/eclipse-smarthome-bluetooth-binding - (remember to press "Save" in the Configuration → System → Market dialog ) You need to use a 3rd party BT binding that s not pr. default available in openHAB.
Follow the installation, and You should be running - this should be quite clear in the inbox, it should be populated with discovered devices..:
Managing BT Devices
This is actually where it gets tricky and I am partly stucked, as I am having a hard time pairing a lot (Yes, You have a lot of BT devices in Your home and the tip in the top Tip Box may play a part here ) and their MAC adresses to real physical devices.
BT Devices has a MAC address like a Network Interface, and there are several ways to discover devices and addresses:
What I do notice, it the the name of the devices is rarely present, and that the MAC address rarely matches the MAC addresses found in openHAB. That is currently an ongoing investigation. Any good clues here? Feel free to mail me at bnp@mos-eisley.dk or drop a comment
There are several lookup tools like https://macaddresschanger.com/bluetooth-mac-lookup that should help, but I find the reliability of them low... often my MACs are not resolved to a Vendor
A Thing in openHAB
A few samples of discovered BT Things in openHAB, its worth noticing that the capabilities can differ quite a lot - refer to Bluetooth on Wikipedia; currently the specs range from version 1 to 5: