Open hkpanchani opened 2 years ago
I have the same issue, please someone help us?
I have the same issue, please someone help us?
I have the same issue on Arch Linux with kernel version 5.15.41-1-lts
I have same issue too
Me too (on Fedora 36 with Pipewire).
Python 3.10.4
Ubuntu 22.04.1
File "./Bluetooth_Headset_Battery_Level/bluetooth_battery.py", line 101, in _perform_query
sock.connect(self._bt_settings)
File "
But it worked on Ubuntu 20.04 earlier.
Did you try disconnecting the device before running the script?
Sorry for the late response. I'm currently super busy with work.
Did you try disconnecting the device before running the script?
Sorry for the late response. I'm currently super busy with work.
I changed the version of setuptools
as a workaround from #83.
Then I installed the version of pybluez
as a workaround from #78.
And only then the script started to work, finally.
For anyone else having this issue (which for me showed up after upgrading from debian bullseye to bookworm), I've found a workaround:
Before reading battery level, disconnect from the device using bluetoothctl, then reconnect after. I've wrapped this in a shell script for ease of use.
It's annoying that I can no longer read battery level during an active connection, but it's better than nothing!
That's literally in the 'Readme' that no one reads 🤦♂️
I used the toggle button in settings to disconnect the device and connected it again. But, no matter what I do, I get this error again. :(
Even used the " bluetoothctl " command as suggested above.
Using Ubuntu 22.04. Thanks
Fedora 36, after I disconnect "Jabra Evolve 65" it gets few lines of code further but still:
Traceback (most recent call last):
File "/tmp/Bluetooth_Headset_Battery_Level/./bluetooth_battery.py", line 166, in <module>
main()
File "/tmp/Bluetooth_Headset_Battery_Level/./bluetooth_battery.py", line 163, in main
print("Battery level for {} is {}".format(device, str(query)))
File "/tmp/Bluetooth_Headset_Battery_Level/./bluetooth_battery.py", line 93, in __str__
return "{:.0%}".format(self._perform_query() / 100)
File "/tmp/Bluetooth_Headset_Battery_Level/./bluetooth_battery.py", line 105, in _perform_query
sock.send(b"+BRSF: 1024")
File "/tmp/Bluetooth_Headset_Battery_Level/./bluetooth_battery.py", line 66, in send
return super().send(b"\r\n" + data + b"\r\n")
File "<string>", line 5, in send
bluetooth.btcommon.BluetoothError: [Errno 14] Bad address
I had the same issue. It was resolved for me by following this advice, or rather the way it's done here. I.e.:
/etc/systemd/system/bluetooth.service.d/
if not already existent/etc/systemd/system/bluetooth.service.d/override.conf
to be:
[Service]
ExecStart=
ExecStart=/usr/lib/bluetooth/bluetoothd --experimental
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
Now bluetooth_battery
tool works again for me (or rather, I still have to run it twice or thrice sometimes to get an output, but at least i can somehow get the battery status of my headphones eventually).
I had the same issue. It was resolved for me by following this advice, or rather the way it's done here. I.e.:
* Create folder `/etc/systemd/system/bluetooth.service.d/` if not already existent * Edit file `/etc/systemd/system/bluetooth.service.d/override.conf` to be:
[Service] ExecStart= ExecStart=/usr/lib/bluetooth/bluetoothd --experimental
* Load the new config with: `sudo systemctl daemon-reload` * Restart bluetooth with: `sudo systemctl restart bluetooth` * Restart/reconnect bluetooth headphones
Now
bluetooth_battery
tool works again for me (or rather, I still have to run it twice or thrice sometimes to get an output, but at least i can somehow get the battery status of my headphones eventually).
Tried this, no luck :(
@meetdilip Enabling experimental features in BlueZ allows PulseAudio 16.0 and PipeWire 0.3.34 to report battery status for the device back to it, on recent versions. It does so based on the most common AT commands similar to this script, hence you won't need / should not use this script at all anymore (and BlueZ will itself propagate battery information if a battery GATT or similar is available).
(You will need "some" utility that reads out the battery status from BlueZ and/or UPower[^1] over DBus, though. For i3blocks I've made my own: https://github.com/MarijnS95/i3blocks-contrib/blob/master/bluetooth-battery/bluetooth-battery, and other WMs may display extra battery icons for devices listed by UPower)
[^1]: For completeness: UPower picks up and propagates reported battery levels for Bluetooth devices when exposed by BlueZ over DBus
@TheWeirdDev perhaps it is time to start pointing users towards this in the README, as it effectively deprecates this script and perhaps even conflicts with it?
See the relevant changelog items in PulseAudio 16.0: https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/16.0/#bluetoothdevicebatterylevelreportingadded https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/16.0/#bluetoothbatterylevelreportingviabluezrequiresenablingexperimentalsfeaturesinbluez
And for PipeWire I'm unsure if it landed 0.3.34 or 0.3.24 already.
I had the same issue. It was resolved for me by following this advice, or rather the way it's done here. I.e.:
* Create folder `/etc/systemd/system/bluetooth.service.d/` if not already existent * Edit file `/etc/systemd/system/bluetooth.service.d/override.conf` to be:
[Service] ExecStart= ExecStart=/usr/lib/bluetooth/bluetoothd --experimental
* Load the new config with: `sudo systemctl daemon-reload` * Restart bluetooth with: `sudo systemctl restart bluetooth` * Restart/reconnect bluetooth headphones
Now
bluetooth_battery
tool works again for me (or rather, I still have to run it twice or thrice sometimes to get an output, but at least i can somehow get the battery status of my headphones eventually).
Thanks a lot @Garbaz ! I've been looking for this for soo long... This not only solved the issue with this python script not being able to connect to some devices, but also added the missing bluetooth devices to the "Power" tab in GNOME Settings. Cheers!
Not working on ubuntu 20.04 with pipewire configuration.
And without pipewire I cant use mic from bluetooth headset so cant switch back.