rytilahti / python-eq3bt

Python library and command-line tool for eQ-3 Smart Bluetooth thermostats
MIT License
115 stars 36 forks source link

running eq3cli with bleak backend keeps hanging #63

Closed krakowski closed 1 year ago

krakowski commented 2 years ago

Hi,

I just tested the latest python-eq3bt version and found that eq3cli hangs whenever I use the bleak backend. Both bluepy and gattlib seem to be working fine though. Here are some log outputs:

--backend gattlib

$> eq3cli --debug --mac 00:1A:XX:XX:XX:XX --backend gattlib
DEBUG:eq3bt.eq3btsmart:Querying the device..
DEBUG:eq3bt.gattlibconnection:Trying to connect to 00:1A:XX:XX:XX:XX
DEBUG:eq3bt.gattlibconnection:Connected to 00:1A:XX:XX:XX:XX
DEBUG:eq3bt.gattlibconnection:Writing b'0316091c170724' to 1041
DEBUG:eq3bt.gattlibconnection:Waiting for notifications for 1
DEBUG:eq3bt.gattlibconnection:Got notification from 1057: b'1b210402010900041c0000000018032a2207'
DEBUG:eq3bt.eq3btsmart:Received notification from the device..
DEBUG:eq3bt.eq3btsmart:Got status: b'02010900041c0000000018032a2207'
DEBUG:eq3bt.eq3btsmart:Parsed status: Container: 
    cmd = 2
    mode = Container: 
        AUTO = True
        MANUAL = True
        DST = True
    valve = 0
    target_temp = 14.0
    away = b'\x00\x00\x00\x00' (total 4)
    presets = Container: 
        window_open_temp = 12.0
        window_open_time = 0:15:00
        comfort_temp = 21.0
        eco_temp = 17.0
        offset = 0.0
DEBUG:eq3bt.eq3btsmart:Valve state:      0
DEBUG:eq3bt.eq3btsmart:Mode:             manual (14.0C) dst
DEBUG:eq3bt.eq3btsmart:Target temp:      14.0
DEBUG:eq3bt.eq3btsmart:Away end:         None
DEBUG:eq3bt.eq3btsmart:Window open temp: 12.0
DEBUG:eq3bt.eq3btsmart:Window open time: 0:15:00
DEBUG:eq3bt.eq3btsmart:Comfort temp:     21.0
DEBUG:eq3bt.eq3btsmart:Eco temp:         17.0
DEBUG:eq3bt.eq3btsmart:Temp offset:      0.0
[00:1A:XX:XX:XX:XX] Target 14.0 (mode: manual (14.0C) dst, away: no)
Locked: False
Batter low: False
Window open: False
Window open temp: 12.0
Window open time: 0:15:00
Boost: False
Current target temp: 14.0
Current comfort temp: 21.0
Current eco temp: 17.0
Current temp offset: 0.0
Current mode: manual (14.0C) dst
Valve: 0

--backend bluepy

$> eq3cli --debug --mac 00:1A:XX:XX:XX:XX --backend bluepy
DEBUG:eq3bt.eq3btsmart:Querying the device..
DEBUG:eq3bt.connection:Trying to connect to 00:1A:XX:XX:XX:XX
DEBUG:eq3bt.connection:Connected to 00:1A:XX:XX:XX:XX
DEBUG:eq3bt.connection:Writing b'0316091c170807' to 1041 with with_response=True
DEBUG:eq3bt.connection:Waiting for notifications for 1
DEBUG:eq3bt.connection:Got notification from 1057: b'02010900041c0000000018032a2207'
DEBUG:eq3bt.eq3btsmart:Received notification from the device..
DEBUG:eq3bt.eq3btsmart:Got status: b'02010900041c0000000018032a2207'
DEBUG:eq3bt.eq3btsmart:Parsed status: Container: 
    cmd = 2
    mode = Container: 
        AUTO = True
        MANUAL = True
        DST = True
    valve = 0
    target_temp = 14.0
    away = b'\x00\x00\x00\x00' (total 4)
    presets = Container: 
        window_open_temp = 12.0
        window_open_time = 0:15:00
        comfort_temp = 21.0
        eco_temp = 17.0
        offset = 0.0
DEBUG:eq3bt.eq3btsmart:Valve state:      0
DEBUG:eq3bt.eq3btsmart:Mode:             manual (14.0C) dst
DEBUG:eq3bt.eq3btsmart:Target temp:      14.0
DEBUG:eq3bt.eq3btsmart:Away end:         None
DEBUG:eq3bt.eq3btsmart:Window open temp: 12.0
DEBUG:eq3bt.eq3btsmart:Window open time: 0:15:00
DEBUG:eq3bt.eq3btsmart:Comfort temp:     21.0
DEBUG:eq3bt.eq3btsmart:Eco temp:         17.0
DEBUG:eq3bt.eq3btsmart:Temp offset:      0.0
[00:1A:XX:XX:XX:XX] Target 14.0 (mode: manual (14.0C) dst, away: no)
Locked: False
Batter low: False
Window open: False
Window open temp: 12.0
Window open time: 0:15:00
Boost: False
Current target temp: 14.0
Current comfort temp: 21.0
Current eco temp: 17.0
Current temp offset: 0.0
Current mode: manual (14.0C) dst
Valve: 0

--backend bleak

$> eq3cli --debug --mac 00:1A:XX:XX:XX:XX --backend bleak
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:eq3bt.eq3btsmart:Querying the device..
DEBUG:eq3bt.bleakconnection:Trying to connect to 00:1A:XX:XX:XX:XX

Is there any way I can debug this further? I am running bluez-5.65 on my host system (not in a container).

krakowski commented 2 years ago

After rebooting my machine I got another error message, which looks like a bug to me.

Traceback (most recent call last):
  File "/XXXXX/XXXXX/.local/lib/python3.9/site-packages/eq3bt/bleakconnection.py", line 80, in on_notification
    handle = handle + 1
TypeError: unsupported operand type(s) for +: 'BleakGATTCharacteristicBlueZDBus' and 'int'
krakowski commented 2 years ago

Looks like I found the culprit.

A few days ago the first argument's type for the notification callback was changed from int to BleakGATTCharacteristic making it unusable in arithmetic operations.