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

error in code when connection fails #34

Open
minscof opened this issue Nov 9, 2019 · 9 comments
Open

error in code when connection fails #34

minscof opened this issue Nov 9, 2019 · 9 comments

Comments

@minscof
Copy link

minscof commented Nov 9, 2019

I test the script and an error occurs vhen the connection fails.
Here are the logs
`Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/eq3bt/connection.py", line 36, in enter
self._conn.connect(self._mac)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 455, in connect
self._connect(addr, addrType, iface)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 447, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType) , rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 00:1A:22:0E:D0:FD, addr type: publi c

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./eq3cli", line 10, in
sys.exit(cli())
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1114, in invoke
return Command.invoke(self, ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/eq3bt/eq3cli.py", line 34, in cli
thermostat.update()
File "/home/pi/.local/lib/python3.7/site-packages/eq3bt/eq3btsmart.py", line 205, in update
self._conn.make_request(PROP_WRITE_HANDLE, value)
File "/home/pi/.local/lib/python3.7/site-packages/eq3bt/connection.py", line 71, in make_request
with self:
File "/home/pi/.local/lib/python3.7/site-packages/eq3bt/connection.py", line 40, in enter
self._conn.connect(self._mac)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 455, in connect
self._connect(addr, addrType, iface)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 447, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType) , rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 00:1A:22:0E:D0:FD, addr type: publi c
`
Can you modify the code to avoid this ?

@rytilahti
Copy link
Owner

The error reporting is not indeed very nice, this is tangentially related to #29 .

@vhristev
Copy link

I have the same problem but i didn't get what is the root cause. It is too far away causing issues?

Any suggestion from where to start troubleshooting

@zyndata
Copy link

zyndata commented Mar 3, 2020

I am sorry to say but I have the same problem

`Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/eq3bt/connection.py", line 36, in enter
self._conn.connect(self._mac)
File "/usr/local/lib/python3.6/dist-packages/bluepy/btle.py", line 445, in connect
self._connect(addr, addrType, iface)
File "/usr/local/lib/python3.6/dist-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 00:1A:22:13:8C:73, addr type: public

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/eq3cli", line 11, in
sys.exit(cli())
File "/usr/lib/python3/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/eq3bt/eq3cli.py", line 34, in cli
thermostat.update()
File "/usr/local/lib/python3.6/dist-packages/eq3bt/eq3btsmart.py", line 205, in update
self._conn.make_request(PROP_WRITE_HANDLE, value)
File "/usr/local/lib/python3.6/dist-packages/eq3bt/connection.py", line 71, in make_request
with self:
File "/usr/local/lib/python3.6/dist-packages/eq3bt/connection.py", line 40, in enter
self._conn.connect(self._mac)
File "/usr/local/lib/python3.6/dist-packages/bluepy/btle.py", line 445, in connect
self._connect(addr, addrType, iface)
File "/usr/local/lib/python3.6/dist-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 00:1A:22:13:8C:73, addr type: public
`

@rytilahti
Copy link
Owner

The root cause is the inability to connect to the device, which can be caused by various reasons. Some users have reported low battery or too long distance as potential causes for this. There is unfortunately nothing that can be done code-wise here, besides making the error reporting of the client tool nicer by suppressing the stacktrace.

@BentHaase
Copy link

BentHaase commented Oct 11, 2020

The root cause is the inability to connect to the device, which can be caused by various reasons. Some users have reported low battery or too long distance as potential causes for this. There is unfortunately nothing that can be done code-wise here, besides making the error reporting of the client tool nicer by suppressing the stacktrace.

What about a configurable retry rate? After trying to run a command for example 5-15 times it finally get's through to the device. It would be nice if your cli utility / library would offer some way to just add a retry.

@rytilahti
Copy link
Owner

That could be done, PRs are welcome!

@Predator83
Copy link

The above mentioned errors (e.g. from zyndata above) occur in my case when I try to connect a second time to the SAME bluetooth thermostats while the first request to it is not finished yet. A connection to different thermostats at the same time is NO problem.

The behavior can be reproducably provoked by calling the python script from Schnup89 from two different terminal windows right after each other.

Also, it seems that the adapter dies (turns red in IOBroker) when this occurs.

@gmoelter
Copy link

In case someone is interested, I have submitted a pull request (#46) that is supposed to fix this issue. If you have any feedback, please let me know.

@dbuezas
Copy link
Contributor

dbuezas commented Jan 16, 2022

This question may be out of context: I use this through the Home Assistant Integration and retries would finally make these radiators solid. Do you maintain that integration?

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

Successfully merging a pull request may close this issue.

8 participants