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

Scan is made but no connect #41

Open
TetianaKolpakova opened this issue Dec 4, 2022 · 1 comment
Open

Scan is made but no connect #41

TetianaKolpakova opened this issue Dec 4, 2022 · 1 comment

Comments

@TetianaKolpakova
Copy link

TetianaKolpakova commented Dec 4, 2022

Hello @rytilahti
I managed to run this code on Debian 11, Phyton 3.9 and I even can do scan and find my lamp, however when I try to connect and ON / OFF it I get errors:

freya@Dalek:~$ yeelightbt --mac f8:24:41:c3:d9:79 on
WARNING:yeelightbt.connection:Unable to connect to the device f8:24:41:c3:d9:79, retrying: Failed to connect to peripheral f8:24:41:c3:d9:79, addr type: public
ERROR:yeelightbt.connection:Second connection try to f8:24:41:c3:d9:79 failed: Failed to connect to peripheral f8:24:41:c3:d9:79, addr type: public
Traceback (most recent call last):
File "/home/freya/.local/lib/python3.9/site-packages/yeelightbt/connection.py", line 55, in connect
self._conn.connect(self._mac)
File "/home/freya/.local/lib/python3.9/site-packages/bluepy/btle.py", line 445, in connect
self._connect(addr, addrType, iface)
File "/home/freya/.local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral f8:24:41:c3:d9:79, addr type: public

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/yeelightbt", line 33, in
sys.exit(load_entry_point('python-yeelightbt==0.0.4', 'console_scripts', 'yeelightbt')())
File "/home/freya/.local/lib/python3.9/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/home/freya/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/freya/.local/lib/python3.9/site-packages/click/core.py", line 1654, in invoke
super().invoke(ctx)
File "/home/freya/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/freya/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/freya/.local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/freya/.local/lib/python3.9/site-packages/yeelightbt/cli.py", line 60, in cli
lamp.connect()
File "/home/freya/.local/lib/python3.9/site-packages/yeelightbt/lamp.py", line 89, in connect
self._conn.connect()
File "/home/freya/.local/lib/python3.9/site-packages/yeelightbt/connection.py", line 59, in connect
self._conn.connect(self._mac)
File "/home/freya/.local/lib/python3.9/site-packages/bluepy/btle.py", line 445, in connect
self._connect(addr, addrType, iface)
File "/home/freya/.local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral f8:24:41:c3:d9:79, addr type: public
freya@Dalek:~$

Any advice how to fix this?

@rytilahti
Copy link
Owner

Sorry, no idea. Looks like a problem in your bluetooth stack, for some reason it cannot form a connection with the device. You could try to use bluetoothctl to connect to the device to see if that works:

❯ bluetoothctl 
Agent registered
[xx]# connect F8:24:41:xx:xx:xx
Attempting to connect to F8:24:41:xx:xx:xx
[CHG] Device F8:24:41:xx:xx:xx Connected: yes
Connection successful
[CHG] Device F8:24:41:xx:xx:xx Name: XMCTD_8A6F
[CHG] Device F8:24:41:xx:xx:xx Alias: XMCTD_8A6F
[CHG] Device F8:24:41:xx:xx:xx ServicesResolved: yes

Note, that this library has not been maintained for years, so even if you get the connection working you will likely need to use a very old version of construct to make the commands work.

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

2 participants