pycalima icon indicating copy to clipboard operation
pycalima copied to clipboard

Cant Connect

Open asifma opened this issue 4 years ago • 6 comments

Hi, Probably not an issue in the script, but do you have any experience of this?

root@raspberrypi:/home/pi/pycalima# python3 cmdline.py -m 58:2b:db:02:37:64 -p 7926XXXX
Traceback (most recent call last):
  File "cmdline.py", line 134, in <module>
    main()
  File "cmdline.py", line 80, in main
    fan = Calima(mac_address, pincode)
  File "/home/pi/pycalima/pycalima/Calima.py", line 79, in __init__
    self.conn = ble.Peripheral(deviceAddr=addr)
  File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.7/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 58:2b:db:02:37:64, addr type: public
Exception ignored in: <function Calima.__del__ at 0x7650fae0>
Traceback (most recent call last):
  File "/home/pi/pycalima/pycalima/Calima.py", line 83, in __del__
    self.conn.disconnect()
AttributeError: 'Calima' object has no attribute 'conn'

asifma avatar Sep 29 '20 00:09 asifma

This, sadly, don't say more than that the bluez stack failed to connect with the BLE device. If you retry a few times does it ever work? Does it work with the App in the phone?

PatrickE94 avatar Oct 16 '20 15:10 PatrickE94

I had similar error messages when the device was too faar away from the fan. Try moving it closer, it worked for me.

Nornode avatar Mar 15 '21 06:03 Nornode

I have the same problem on Armbian Bullseye. The setup worked for some time on Armbian Buster. But after switching to Bulsseye I cant connect to the fan. Tried different bluepy versions from pip repo. The fan is visible via scanning. The distance between the devices is the same as before.

python3 cmdline.py -m 58:2b:db:34:2c:e0 -p 9XXXXXXX

Traceback (most recent call last):
  File "/usr/share/hassio/homeassistant/custom_components/pycalima/pycalima/cmdline.py", line 134, in <module>
    main()
  File "/usr/share/hassio/homeassistant/custom_components/pycalima/pycalima/cmdline.py", line 80, in main
    fan = Calima(mac_address, pincode)
  File "/usr/local/lib/python3.9/dist-packages/Calima-2.0.0-py3.9.egg/pycalima/Calima.py", line 79, in __init__
    self.conn = ble.Peripheral(deviceAddr=addr)
  File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 353, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 401, in _connect
    raise BTLEException(BTLEException.DISCONNECTED,
bluepy.btle.BTLEException: Failed to connect to peripheral 58:2b:db:34:2c:e0, addr type: public
Exception ignored in: <function Calima.__del__ at 0xb66326a0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/Calima-2.0.0-py3.9.egg/pycalima/Calima.py", line 83, in __del__
AttributeError: 'Calima' object has no attribute 'conn'

pecuna avatar Nov 16 '21 07:11 pecuna

I can confirm this as well. Tried on both raspberry os on a pi zero and ubuntu server on a rpi 4. After a few retries though it works so it might just be the distance as @Nornode pointed out

philsson avatar Nov 22 '21 10:11 philsson

I have the same exact issue as described, running on a pi zero with Raspbian Bullseye. Moreover, the thoughts on closing the distance and making several attempts have no impact. (My Pi zero is within a few feet and has been moved in different directions in the same range. I have also made 20+ attempts to connect, without success.)

The cmdline.py -l command works fine and lists my one device, so logically it should be in range to connect. Connecting via the Android app also works fine.

larsgu avatar Dec 12 '22 10:12 larsgu

I have the same exact issue as described, running on a pi zero with Raspbian Bullseye. Moreover, the thoughts on closing the distance and making several attempts have no impact. (My Pi zero is within a few feet and has been moved in different directions in the same range. I have also made 20+ attempts to connect, without success.)

The cmdline.py -l command works fine and lists my one device, so logically it should be in range to connect. Connecting via the Android app also works fine.

I finally managed to resolve my connect issue, though I'm not sure what was the key step:

  • I performed the extra installation step listed for the Bluepy repo https://github.com/IanHarvey/bluepy (sudo apt-get install python-pip libglib2.0-dev)
  • A sequence of apt-get update etc
  • A reboot

larsgu avatar Dec 12 '22 13:12 larsgu