openHAB with Bluetooth
Topics
- Topics
Add BT Support in Ubuntu- Test discovery and functionality
- Installing Addons in openHAB
- Managing BT Devices
- A Thing in openHAB
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 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.....
Add BT Support in Ubuntu
First discovery was that the Ubuntu OS had no BT installed, so we need to do this:
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 systemctl daemon-reload
sudo systemctl restart bluetooth
Test discovery and functionality
A little testing of discovery etc:
[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:
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:
Bluetooth:
Apple Bluetooth Software Version: 6.0.9f2
Hardware, Features, and Settings:
Name: batman
Address: 08-6D-41-E7-FF-7B
Bluetooth Low Energy Supported: Yes
Handoff Supported: Yes
Instant Hot Spot Supported: Yes
Manufacturer: Broadcom
Transport: USB
Chipset: 20702B0
Firmware Version: v149 c9314
Bluetooth Power: On
Discoverable: Off
Connectable: Yes
Auto Seek Pointing: On
Remote wake: On
Vendor ID: 0x05AC
Product ID: 0x8289
HCI Version: 4.0 (0x6)
HCI Revision: 0x2462
LMP Version: 4.0 (0x6)
LMP Subversion: 0x4195
Device Type (Major): Computer
Device Type (Complete): Mac Desktop
Composite Class Of Device: 0x380104
Device Class (Major): 0x01
Device Class (Minor): 0x01
Service Class: 0x1C0
Auto Seek Keyboard: On
Devices (Paired, Configured, etc.):
Normann P. Nielsen’s Mouse #2:
Address: B8-44-D9-F1-15-59
Major Type: Peripheral
Minor Type: Mouse
Services: Magic Mouse 2
Paired: Yes
Configured: Yes
Connected: Yes
Manufacturer: Broadcom (0x5, 0x240C)
Battery Level: 67%
Firmware Version: 0x0064
Vendor ID: 0x004C
Product ID: 0x0269
Class of Device: 0x05 0x20 0x0580
AFH: On
AFH Map: F9FFFF7FFFFFDBFFFF7F
RSSI: -45
Role: Master
Connection Mode: Sniff Mode
Interval: 11.25 ms
Host Connectable: Yes
EDR Supported: Yes
eSCO Supported: No
SSP Supported: Yes
Soveværelse:
Address: D0-03-4B-E5-A3-73
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Apple TV:
Address: C8-D0-83-C5-BB-4C
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Anette W. Nielsens iPhone:
Address: 4C-7C-5F-7D-8A-4A
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
jarvis (2):
Address: 78-4F-43-A0-21-3A
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Normann P. Nielsen’s iPad:
Address: 54-AE-27-10-02-87
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Normann P.'s iPhone:
Address: 90-B0-ED-99-75-28
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
iPhone:
Address: 80-EA-96-16-60-B7
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Normann P.'s iPhone:
Address: 34-AB-37-EF-C3-CE
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Services:
Bluetooth File Transfer:
Folder other devices can browse: ~/Public
When receiving items: Accept all without warning
State: Disabled
Bluetooth File Exchange:
Folder for accepted items: ~/Downloads
When other items are accepted: Save to location
When receiving items: Accept all without warning
State: Disabled
Bluetooth Internet Sharing:
State: Disabled
Incoming Serial Ports:
Bluetooth-Incoming-Port:
RFCOMM Channel: 3
Requires Authentication: No
batman:~ bnp$
[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]#



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:


