Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth.btcommon.BluetoothError: [Errno 111] Connection refused #74

Open
manel00 opened this issue Jan 19, 2022 · 5 comments
Open

bluetooth.btcommon.BluetoothError: [Errno 111] Connection refused #74

manel00 opened this issue Jan 19, 2022 · 5 comments

Comments

@manel00
Copy link

manel00 commented Jan 19, 2022

Hello,

I've already installed everything but it gives me this error:

Traceback (most recent call last):
  File "/home/manel/Documentos/bluetooth_battery.py", line 166, in <module>
    main()
  File "/home/manel/Documentos/bluetooth_battery.py", line 163, in main
    print("Battery level for {} is {}".format(device, str(query)))
  File "/home/manel/Documentos/bluetooth_battery.py", line 93, in __str__
    return "{:.0%}".format(self._perform_query() / 100)
  File "/home/manel/Documentos/bluetooth_battery.py", line 101, in _perform_query
    sock.connect(self._bt_settings)
  File "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: [Errno 111] Connection refused

I am adding the parameter when i am executing the py file **

@jrom99
Copy link

jrom99 commented Sep 22, 2022

Can you provide more information about your device (make and model)? Also if it's mentioned in the output of upower -d and whether you can see its battery levels in other devices (phone, Mac or Windows)

I have the same problem with an Edifier W800BT and it was due to it not reporting battery at all.

@meetdilip
Copy link

Almost the same issue here

$ ./bluetooth_battery.py My_MAC_Addr.3
Traceback (most recent call last):
  File "<string>", line 3, in connect
_bluetooth.error: (111, 'Connection refused')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dilip/Downloads/Bluetooth_Headset_Battery_Level-master/./bluetooth_battery.py", line 166, in <module>
    main()
  File "/home/dilip/Downloads/Bluetooth_Headset_Battery_Level-master/./bluetooth_battery.py", line 163, in main
    print("Battery level for {} is {}".format(device, str(query)))
  File "/home/dilip/Downloads/Bluetooth_Headset_Battery_Level-master/./bluetooth_battery.py", line 93, in __str__
    return "{:.0%}".format(self._perform_query() / 100)
  File "/home/dilip/Downloads/Bluetooth_Headset_Battery_Level-master/./bluetooth_battery.py", line 101, in _perform_query
    sock.connect(self._bt_settings)
  File "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: [Errno 111] Connection refused

@peylight
Copy link

I have the same problem.
the output of upower -d doesn't show my bluetooth device.
However in my android phone it is showing the percentage of battery.

@jrom99
Copy link

jrom99 commented Sep 22, 2023

I have the same problem. the output of upower -d doesn't show my bluetooth device. However in my android phone it is showing the percentage of battery.

Have you tried enabling experimental features in Bluez? My device started appearing in upower (however it only repliies with mutiples of 20%, the same as my phone).

@peylight
Copy link

@jrom99 Thx, The problem has been solved after enabling experimental features in Bluez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants