Skip to content

Commit b4c490b

Browse files
committed
Remove PyBluez dependency, use Python socket instead
1 parent eae9957 commit b4c490b

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ If you try to control another Divoom device, the connection to the first device
4242

4343
## Requirements
4444
### Bluetooth Hardware
45-
This component uses PyBluez library for Bluetooth communication. PyBluez is based on BlueZ official Linux Bluetooth stack.
45+
This component uses Python sockets for Bluetooth communication.
4646

47-
Any Bluetooth hardware supported by your operating system should work. The Bluetooth interface built in to the Raspberry Pi 3 probably works, but hasn't yet been tested.
47+
Any Bluetooth hardware supported by your operating system should work. The Bluetooth interface built in to the Raspberry Pi 3 probably works, but hasn't been tested yet.
4848

4949
To check if your Bluetooth hardware is supported, run the following command on your system:
5050
```bash
@@ -57,9 +57,6 @@ Your Bluetooth interface should be listed as "hciX". If you have more than one,
5757
### Home Assistant installation
5858
Any Home assistant installation should be supported: OS, Container, Core, Supervised.
5959

60-
**Notes for Home Assistant Core Installations**: This platform requires pybluez to be installed. On Debian based installs, run
61-
`sudo apt install bluetooth libbluetooth-dev python3-bluez`
62-
6360
If you run Home Assistant in a virtual machine, you have to connect your computer Bluetooth hardware to the VM:
6461
- On VMWare: VM > Removable devices > (Your Bluetooth device i.e. Intel Wireless Bluetooth) > Connect
6562
- On VirtualBox: Devices > USB devices > (Your Bluetooth device i.e. Intel Wireless Bluetooth)

custom_components/timebox_mini/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from homeassistant.util import slugify
44
from itertools import product
55
from .timebox import Timebox
6-
import bluetooth
76
import datetime
87
import logging
98
import math
@@ -250,8 +249,8 @@ def handle_action(call):
250249
dev = Timebox(mac)
251250
dev.connect()
252251
_LOGGER.debug('Connected to %s' % mac)
253-
except bluetooth.BluetoothError as be:
254-
_LOGGER.error('Error connecting to %s : %s' % (mac, be))
252+
except Exception as e:
253+
_LOGGER.error('Error connecting to %s : %s' % (mac, e))
255254
return
256255

257256
c = color_convert(Color("white").get_rgb())

custom_components/timebox_mini/manifest.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"domain": "timebox_mini",
33
"name": "Timebox Mini",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"documentation": "https://github.com/mathoudebine/homeassistant-timebox-mini",
66
"issue_tracker": "https://github.com/mathoudebine/homeassistant-timebox-mini/issues",
77
"requirements": [
88
"colour",
99
"pillow",
10-
"python-dateutil",
11-
"pybluez"
10+
"python-dateutil"
1211
],
1312
"dependencies": [],
1413
"codeowners": [

custom_components/timebox_mini/timebox.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import bluetooth
21
import logging
2+
import socket
33

44
_LOGGER = logging.getLogger(__name__)
55

6+
BTPROTO_RFCOMM = 3
7+
68
class Timebox:
79
debug = False
810

911
def __init__(self, target):
10-
if (isinstance(target, bluetooth.BluetoothSocket)):
12+
if isinstance(target, socket.socket):
1113
self.sock = target
1214
self.addr, _ = self.sock.getpeername()
1315
else:
14-
self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
16+
self.sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, BTPROTO_RFCOMM)
1517
self.addr = target
1618
self.sock.connect((self.addr, 4))
1719

0 commit comments

Comments
 (0)