self-host · 2023年10月28日 0

Resolve Bluetooth Tracker not working after upgrading Home Assistant

I am using Bluetooth Tracker intergration in Home Assistant to determine whether people at home. However, after updating Home Assistant, all devices showed as “away.” After checking the logs, it was discovered that the “PyBluez” library was missing. This passage explains how to make Bluetooth Tracker work with higher versions of Home Assistant.

Platform error: device_tracker - Requirements for bluetooth_tracker not found: ['PyBluez==0.22'].
Unable to install package PyBluez==0.22: error: subprocess-exited-with-error × Running setup.py install for PyBluez did not run successfully.

The reason Bluetooth Tracker isn’t working is that it requires a PyBluez version that doesn’t meet the requirements for Python 3.11 (the dependency version is too low). Therefore, you need to make Bluetooth Tracker intergration compatible with a higher version of PyBluez to get it working again.

First, navigate to the directory (you may need to switch to the homeassistant account, use sudo -u homeassistant -H -s):

cd /srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/bluetooth_tracker

Edit the manifest.json file for Bluetooth Tracker:

vim manifest.json

Change the PyBluez version to “PyBluez>=0.22” in the file:

{
  "domain": "bluetooth_tracker",
  "name": "Bluetooth Tracker",
  "codeowners": [],
  "documentation": "https://www.home-assistant.io/integrations/bluetooth_tracker",
  "iot_class": "local_polling",
  "loggers": ["bluetooth", "bt_proximity"],
  "requirements": ["bt-proximity==0.2.1", "PyBluez>=0.22"]
}

Now, restart Home Assistant, and the Bluetooth Tracker intergration should work correctly.

If Bluetooth Tracker still doesn’t work, you can change the config file as follow to get PyBluez from github.

{
"domain": "bluetooth_tracker",
"name": "Bluetooth Tracker",
"codeowners": [],
"documentation": "https://www.home-assistant.io/integrations/bluetooth_tracker",
"iot_class": "local_polling",
"loggers": ["bluetooth", "bt_proximity"],
"requirements": ["bt-proximity==0.2.1", "git+https://github.com/pybluez/pybluez.git#pybluez==0.30"]
}
心情表态
+1
1
+1
0
+1
0
+1
0
+1
0
+1
0