笔者使用Home Assistant中Bluetooth Tracker作为判断是否有人的依据,但在更新Home Assistant后所有设备均显示“离家”状态,翻阅logs后发现提示找不到“PyBluez”。本文将介绍如何在高版本使Bluetooth Tracker恢复正常工作。
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.
Bluetooth Tracker无法运行的原因是其需要的PyBluez版本在Python 3.11上没有符合要求的包(依赖版本太低),因此需要使Bluetooth Tracker支持高版本的PyBluez来使其恢复运行。
首先进入目录(可能需要切换到homeassistant账户,输入sudo -u homeassistant -H -s
,路径取决于您的Python版本等)
cd /srv/homeassistant/lib/python3.12/site-packages/homeassistant/components/bluetooth_tracker
编辑Bluetooth Tracker的manifest.json文件
vim manifest.json
将其中PyBluez版本号修改为“PyBluez>=0.22
”,文件变为:
{
"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"]
}
此时重启Home Assistant,蓝牙围栏即可正常使用。如果还不能使用,可以参照以下内容修改配置以从github获取指定版本的PyBluez:
{
"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
2
+1
1
+1
+1
+1
+1
期待博主的最新博文!
每次升级ha都是一个挑战
是的,它对Python版本的限制也比较死,比如2024.04仅支持Python12。