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

I’ve started using the custom bluetooth tracker. It’s working on a Home Assistant Blue with a BCM20702A0 Broadcom bluetooth dongle.

Nice to have bluetooth presence working again.

Update: Yeah, not working so great. Keeps dying, needs a server reboot to bring it back to life for a bit until it just dies again. :slightly_frowning_face:

1 Like

Curious if anyone knows what the “unsupported” method of installing the patch is when using HASS OS would be?

I have this adapter, and I have the custom bluetooth integration installed. It works for a while but then Bluetooth dies. Wondering if this patch is the issue.

I’m now getting this error “Platform error device_tracker.bluetooth_tracker - Requirements for bluetooth_tracker not found: [‘PyBluez==0.22’].” since 2023.9.0 update.

BTW, @Neil_Brownlee , could you give more information about MM? What’s that and how to use with HA?

I use these : TuYa ZY-M100-L control via MQTT | Zigbee2MQTT

You can get them from a variety of places - cheapest being Ali Express.

I’m writing a bluetooth-based custom component for a device that is not BLE-compatible. The new bluetooth integration, including the advice on building a bluetooth integration, only supports BLE. Ran into a whole lot of pain (including trying to install pybluez on HAOS – impossible), but this is what worked for me:

  • First, make sure that that the new bluetooth integration is disabled – it takes full control over the bluetooth device and makes it scan for only BLE-compatible devices.
  • Next, SSH in and use bluetoothctl to find and pair with the device you want to communicate with.
  • To get a serial port, you don’t need pybluez anymore for simple serial communication: Bluetooth Programming with Python 3 - Kevin Doran
  • This code worked for me:
import socket
s = socket.socket(
    socket.AF_BLUETOOTH,
    socket.SOCK_STREAM,
    socket.BTPROTO_RFCOMM,
)
s.connect(('XX:XX:XX:XX:XX:XX', 1))

(replace XX:XX:XX:XX:XX:XX with the MAC address of the device you want a bluetooth serial connection to – find via bluetoothctl)

1 Like

Hello everyone,
This bug depends only on software or depends also from hardware. I use hass os: if I buy an external USB bluetooth antenna, can I solve the problem?

Thanks

This is software related

2 Likes

My workaround, described in #29, still works for me.
The developers did not released the code with the python3.11 fix yet. But the changes are already committed…
You just have to build it. It works.
I can detect my bt devices as before.

This is not a bug.
It is simply a feature that has been deprecated.
HASS used PyBluez, which is the module that allows Python code to access the host machine’s Bluetooth resources.
PyBluez development seems to be abandoned (stale code for over a year), and does not support the latest Python version that HASS uses.
Until PyBluez is updated or someone contributes an updated module to HASS development, it will not work.
Perhaps you should look into BLE as an alternative for device tracking, if that is what you are attempting to do.

I have different feelings about bug vs deprecation.

If it is deprecated, as usual, we should have a notice couple of months ahead.

They were enforced to remove it given that the library cannot run on the new python version. This doesn’t look like deprecation to me.

1 Like

Perhaps I could have used another term:

“It is simply a feature that has been removed.”

A bug refers to faulty code. This is not a bug.

1 Like

Ditto here. Integration and pass through look to work ok but when I try and add the trackers it gives that error.

Thank you bro.Your solution has solved this problem that has cost me a lot of time.

Happy New 2024 Year from Beijing . :sparkler: :sparkler: :sparkler: