PatrickE94 / pycalima

Python interface for Pax Calima Fan via Bluetooth LE
Apache License 2.0
45 stars 22 forks source link

Cant Connect #18

Open asifma opened 4 years ago

asifma commented 4 years ago

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'
PatrickE94 commented 4 years ago

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?

Nornode commented 3 years ago

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

pecuna commented 2 years ago

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'
philsson commented 2 years ago

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

larsgu commented 1 year ago

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 commented 1 year ago

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: