How do i fix Unable to install package pybluez==0.22: error:

Solutions provided by @EthanBezz is working on docker based instalation. As he wrote this is for docker based installation. Probably this will not work on haos or debian supervised installation. If some manage to make it work on those installations feel free to post solution for others.

It doesnt work on supervised installation.
I found no way - no Idea how to manipulate the homeassistant.json, where the image is defined. Maybe there is a way to change the entrypoint for the container ā€¦
So i have to change the container on every update and install gcc etcā€¦

After update to 2023.6.1 I got error

Platform error device_tracker.bluetooth_tracker - Requirements for bluetooth_tracker not found: ['PyBluez==0.30'].

As @miky_italy suggested I done inside homeassistant container

apk add gcc musl-dev bluez-dev

but this didnā€™t resolve the issue.
It was working with 6.0 update.

But bluetooth_le_tracker is working .

device_tracker:
  - platform: bluetooth_le_tracker
    interval_seconds: 60
    consider_home: 180
    track_new_devices: yes

Got this working yesterday in docker, discovered today the Pybluez==0.30 error. Re-read the post and saw the updated changes. Edited my docker-compose file, did all the other steps, and now the error is gone. Thank you!

Strangely, I now get a new error -

2023-06-09 16:24:23.983 ERROR (SyncWorker_0) [custom_components.bluetooth_tracker.device_tracker] Couldn't discover bluetooth devices: [Errno 16] Error communicating with local bluetooth adapter: Resource busy

Repeating every minute. Not sure why. From within the container console Iā€™m able to see the bluetooth adapter (ā€œhcitool devā€) and bluetoothctl scans and sees devices. So clearly, from within the container the operating system has access to the bluetooth controller.

More info: Running bluetoothctl either on the host or in the container displays endless [CHG] records, which are normally seen when you do a scan from within bluetoothctl. But you canā€™t stop them - ā€˜scan offā€™ fails:

[bluetooth]# scan off
Failed to stop discovery: org.bluez.Error.Failed

One reason for this spam may happen also inadvertently if gnome-control-center bluetooth GUI is open as well, which is continuously scanning for devices. In my case, this isnā€™t running.

$systemctl restart bluetoothctl doesnā€™t help.
Stopping the home assistant container immediately stops the spamming and Iā€™m able to get control back running bluetoothctl on the host. This tells me thereā€™s something happening in the container thatā€™s causing non-stop scanning.

I would expect the bluetooth_tracker.device_tracker component to be turning on the bluetooth scan, but if thatā€™s what itā€™s doing itā€™s having trouble since itā€™s the one reporting the error. Perhaps itā€™s failing to disable the first scan, and any subsequent scan attempts fail because the first one is still in progress.

On a suspicion I plugged in a bluetooth dongle I had lying around and disabled the built-in one. Rebooted, and no errors in the log now. Thereā€™s now a bluetooth integration thingie appearing, so thatā€™s good. It hasnā€™t found? done anything? with the devices it must be scanning though. Not that any of them are likely to be known devices. But at least it shows up now so thatā€™s good.

According to PR#92122 it seems the change was intentional, it was just left out of breaking changes

Thatā€™s unfortunate then. I use a composite person for tracking and BT was always reliable within the house.

Wish this was more visible, earlier, so we could figure out an alternative.

2 Likes

So, no more BT tracking all of a sudden? Without mention in the breaking changes? Coolā€¦

1 Like

Same problem here using HassOS. Does this affect bluetooth proxies?

Yeah, not sure how this wasnā€™t listed under the breaking changes.

Have a workaround for debian supervised installation.
Wrote a simple script that starts after homeassistant starts (after an upgradeā€¦)
Check if pybluez is installed (pip list |grep PyBluez)
If not, then do the following 3 steps:

url="http://localhost:8123/api/services/homeassistant/restart"
pip list|grep PyBluez
RC=$?
if [ "$RC" -ne "0" ]
then
 apk add gcc musl-dev bluez-dev
 pip install git+https://github.com/pybluez/pybluez.git#egg=pybluez
 [ "$?" -ne "0" ] && (exit 1)
 curl -X POST -H "Authorization: Bearer $token" -H "content-type: application/json" $url
fi

Dont found a better way to restart Homeassistent from the container as the curl callā€¦

No, my bluetooth proxy is still working, once I removed the bluetooth_tracker entry in my configuration.yaml

It looks like even in the new patch thereā€™s no fix for the BTā€¦ :frowning:
I donā€™t have installed it, Iā€™ve just read the changelog on the main page.

Iā€™m not sure that theyā€™ll fix that, probably few people use it?

I installed the 2023.6.2 hoping it would fix the Bluetooth issue also.
It does not fix the issue, still does not see my cellphone as home.
I have alot of automations that run based on if my cellphone is home or not.
Does anyone know if their is an open ticket for this issue?

When I run the Configuration Check Validation this is the error message:
Platform error device_tracker.bluetooth_tracker - Requirements for bluetooth_tracker not found: [ā€˜pybluez==0.22ā€™].

You find the solution in this thread.
The workaround works.
There is no other solution at the moment.

My bluetooth tracker works with pybluez 0.30
No problems.

I saw the fix.
Running on Raspberry PI HassOS.
Last time I did a workaround it caused more problems.
I just rolled back to a version that worked and will wait for official fix.
Thanksā€¦

Did exactly the same. And I think that thereā€™s no other solution atm.

How about for HA OS?

1 Like

Noticed a update to Home Assistant Operating System 10.3
Read the release notes and didnā€™t see anything specific to this issue.
Something about BLE so just installed to see if I got lucky and issue was fixed.
Installed and did reboot, did not fix the issue.

1 Like

For anyone hoping for a fix.
Installed 2023.6.3 and problem is still there.

3 Likes

Iā€™ve removed a step from my solution above as itā€™s now been fixed by the Home Assistant devs and no longer needs to be done.

However, that was only 1 of the fixes that were needed to solve this problem, so it still remands an issue.

ā€œWell then why didnā€™t they fix it completely?ā€, I hear you ask!
The answer to that is here.