PatrickE94 / pycalima

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

Unable to connect #5

Closed JohanLeirnes closed 5 years ago

JohanLeirnes commented 5 years ago

im getting an error trying to run your code.

sudo python3 cmdline.py -l
Running  /usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper
Sent:  le on

Got: 'rsp=$mgmt code=$success\n'
Sent:  scan

Got: 'rsp=$mgmt code=$success\n'
Got: "rsp=$stat state=$scan dst='(null) mtu=h0 sec='low\n"
Got: 'rsp=$scan addr=b3F406149E717 type=h2 rssi=h20 flag=hFFFFFFFC d=b02011B0BFF4C000906030BC0A80146\n'
Discovered device 3f:40:61:49:e7:17
Got: 'rsp=$scan addr=bB8E8563E70E1 type=h1 rssi=h52 flag=h0 d=b02010607FF4C0010020B00\n'
Discovered device b8:e8:56:3e:70:e1
Got: 'rsp=$scan addr=b4AFFBD7C0B18 type=h2 rssi=h50 flag=h0 d=b02010613FF4C000C0E083BAB32603FB1F6A2B84993DF11\n'
Discovered device 4a:ff:bd:7c:0b:18
Got: 'rsp=$scan addr=b5032379AA68F type=h1 rssi=h20 flag=h0 d=b02011A07FF4C0010020104\n'
Discovered device 50:32:37:9a:a6:8f
Got: 'rsp=$scan addr=b531190DF6888 type=h2 rssi=h51 flag=hFFFFFFFC d=b03039FFE17169FFE02655A517072667876736E6300000166EB1C6BC109FFE000016CCA9F3A72\n'
Discovered device 53:11:90:df:68:88
Got: 'rsp=$scan addr=b5DDAEADA6F9B type=h2 rssi=h33 flag=h0 d=b02011A0AFF4C001005019815D1A8\n'
Discovered device 5d:da:ea:da:6f:9b
Got: 'rsp=$scan addr=b6EE8D41EC571 type=h2 rssi=h3D flag=h0 d=b02011A0AFF4C0010050A1C18D742\n'
Discovered device 6e:e8:d4:1e:c5:71
Got: 'rsp=$scan addr=b5032379AA68F type=h1 rssi=h2D flag=hFFFFFFFC\n'
Discovered device 50:32:37:9a:a6:8f
Got: 'rsp=$scan addr=bC47C8D6443BF type=h1 rssi=h3D flag=h0 d=b020106030295FE0F1695FE310298000EBF43648D7CC40D\n'
Discovered device c4:7c:8d:64:43:bf
Got: 'rsp=$scan addr=b0007801F41FF type=h1 rssi=h3B flag=h0 d=b020106110721314E93B59BC889564906E52F89C3FE\n'
Discovered device 00:07:80:1f:41:ff
Got: 'rsp=$scan addr=b4AFFBD7C0B18 type=h2 rssi=h3C flag=hFFFFFFFC\n'
Discovered device 4a:ff:bd:7c:0b:18
Got: 'rsp=$scan addr=bC47C8D6443BF type=h1 rssi=h4A flag=hFFFFFFFC d=b0C09466C6F7765722063617265\n'
Discovered device c4:7c:8d:64:43:bf
Got: 'rsp=$scan addr=b5DDAEADA6F9B type=h2 rssi=h40 flag=hFFFFFFFC\n'
Discovered device 5d:da:ea:da:6f:9b
Got: 'rsp=$scan addr=b0007801F41FF type=h1 rssi=h4B flag=hFFFFFFFC d=b0D09474C31353139303030343331\n'
Discovered device 00:07:80:1f:41:ff
Got: 'rsp=$scan addr=bC47C8D644387 type=h1 rssi=h51 flag=h0 d=b020106030295FE0F1695FE31029800CF8743648D7CC40D\n'
Discovered device c4:7c:8d:64:43:87
Got: 'rsp=$scan addr=b582BDB00AC42 type=h1 rssi=h50 flag=h0 d=b02010603030A1803190000020AFE0B095041582043616C696D61\n'
Discovered device 58:2b:db:00:ac:42
Got: 'rsp=$scan addr=bC47C8D6443D5 type=h1 rssi=h5B flag=h0 d=b020106030295FE0F1695FE31029800D6D543648D7CC40D0C09466C6F7765722063617265\n'
Discovered device c4:7c:8d:64:43:d5
Got: 'rsp=$scan addr=bC47C8D644387 type=h1 rssi=h60 flag=hFFFFFFFC d=b0C09466C6F7765722063617265\n'
Discovered device c4:7c:8d:64:43:87
Select timeout
Sent:  scanend

Got: 'rsp=$mgmt code=$success\n'
Stopping  /usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper
('58:2b:db:00:ac:42',)
sudo python3 run.py
Running  /usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper
Sent:  conn 58:2b:db:00:ac:42 public

Got: "rsp=$stat state=$tryconn dst='58:2b:db:00:ac:42 mtu=h0 sec='low\n"
Got: "rsp=$stat state=$disc mtu=h0 sec='low\n"
Stopping  /usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper
Traceback (most recent call last):
  File "run.py", line 27, in <module>
    fan = Calima("58:2b:db:00:ac:42", "14130655")
  File "/home/homeassistant/pycalima/pycalima/Calima.py", line 51, in __init__
    self.conn = ble.Peripheral(deviceAddr=addr)
  File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py", line 361, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py", line 411, in _connect
    "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType))
bluepy.btle.BTLEException: Failed to connect to peripheral 58:2b:db:00:ac:42, addr type: public
Exception ignored in: <bound method Calima.__del__ of <pycalima.Calima.Calima object at 0xb6aa5130>>
Traceback (most recent call last):
  File "/home/homeassistant/pycalima/pycalima/Calima.py", line 55, in __del__
    self.conn.disconnect()
AttributeError: 'Calima' object has no attribute 'conn'
PatrickE94 commented 5 years ago

I don't see any straight solution, the main error is simply the failure when bluepy tries to connect. It has nothing really to do with this script. Are you running on a Raspberry Pi? BluePy has been very intermittent on those.

The issue tracker on BluePy is littered with this error, maybe you can get more help there?

BluePu Issues

 bluepy.btle.BTLEException: Failed to connect to peripheral 58:2b:db:00:ac:42, addr type: public
JohanLeirnes commented 5 years ago

Im using it on hassbian. I just read in the installation docs that there is no Bluetooth LE support. Might try this script on another computer with ubuntu and see if i can get it to work.

Thanks for the pointers.