python-eq3bt icon indicating copy to clipboard operation
python-eq3bt copied to clipboard

error in code when connection fails

Open minscof opened this issue 5 years ago • 9 comments

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 ?

minscof avatar Nov 09 '19 17:11 minscof

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

rytilahti avatar Nov 10 '19 19:11 rytilahti

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

vhristev avatar Jan 18 '20 01:01 vhristev

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 `

zyndata avatar Mar 03 '20 20:03 zyndata

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.

rytilahti avatar Mar 03 '20 20:03 rytilahti

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.

BentHaase avatar Oct 11 '20 17:10 BentHaase

That could be done, PRs are welcome!

rytilahti avatar Oct 11 '20 17:10 rytilahti

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.

Predator83 avatar Jan 03 '21 17:01 Predator83

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.

gmoelter avatar Jan 16 '22 12:01 gmoelter

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?

dbuezas avatar Jan 16 '22 14:01 dbuezas