seidler2547 / ble-mqtt-bridge

A Python Bluetooth LE to MQTT bridge
20 stars 7 forks source link

writeCharacteristic ends with error #5

Open animavitis opened 6 years ago

animavitis commented 6 years ago

Reading data from my comet blue is working fine, but i cant set anything. All writecharacteristic actions ends with this error:

 Connected to a5:80:bc:ca:66:b2
  Command {'action': 'writeCharacteristic', 'handle': 71, 'value': [64, 226, 1, 0]}
    Write b'@\xe2\x01\x00' to 71
Error: Error from Bluetooth stack (comerr)

After downgrading bluepy to version 1.0.5, 1.1.0, 1.1.2 same logs appear.

can someone help?

seidler2547 commented 6 years ago

Your thermostat is not accepting the PIN code. Which firmware do you have? Can you try upgrading the firmware using the official app: https://play.google.com/store/apps/details?id=com.delan.app.germanybluetooth

animavitis commented 6 years ago

My Comet Bleu is branded by LIDL. Vesion COBL0133 revision 0.0.10 & no new firmware avaible in official app. PIN from example is 123456, but it was not working for default 0 PIN too. I found this CLI tool https://github.com/xrucka/cometblue is working great, but im too dump to find why.

thx for all help :)

seidler2547 commented 6 years ago

Something might have changed with the PIN entry. Try removing this line: https://github.com/seidler2547/home-assistant-cc/blob/acf87dfa1e540d2a90b04c78e0ca382b9fb24c27/custom_components/climate/sygonix.py#L326 (it says "Try PIN 000000 first). That might help.

My firmware is COBL0126.

animavitis commented 6 years ago

sadly still same error

ble/a5:80:bc:ca:66:b2/commands b'{"tries": 1, "commands": [{"action": "writeCharacteristic", "handle": 71, "value": [64, 226, 1, 0]}, {"action": "writeCharacteristic", "handle": 63, "value": [128, 22, 128, 128, 128, 128, 128]}, {"action": "writeCharacteristic", "handle": 29, "value": [38, 18, 21, 1, 18]}, {"action": "readCharacteristic", "handle": 61}, {"action": "readCharacteristic", "handle": 63}, {"action": "readCharacteristic", "handle": 65}, {"action": "readCharacteristic", "handle": 20}, {"action": "readCharacteristic", "handle": 22}, {"action": "readCharacteristic", "handle": 24}, {"action": "readCharacteristic", "handle": 26}]}' using ble/a5:80:bc:ca:66:b2/commands len=3 Connecting to a5:80:bc:ca:66:b2 Waiting... Waiting... Waiting... Waiting... Connected to a5:80:bc:ca:66:b2 Command {'action': 'writeCharacteristic', 'handle': 71, 'value': [64, 226, 1, 0]} Write b'@\xe2\x01\x00' to 71 Error: Error from Bluetooth stack (comerr)

Installed Wireshark on my PC and start analyzing HCI snoop logs.. then SUCCESS :)
I found that in my firmware PIN is HANDLE 72 (0x0048) and to change temperature is used HANDLE 61 (0x003d) ..... now need to find rest

animavitis commented 6 years ago

Can u give some clues how changing mode of Comet Blue is working? this is last thing that i need to find/fix

seidler2547 commented 6 years ago

Interesting. I will try and see if I can upgrade mine to this firmware (haven't touched them in two years or so). But it might take a while.

seidler2547 commented 6 years ago

Ok, I could not update my firmware, but I see that the other tool uses GUIDs instead of the handles. I think I will change/implement this and then it would hopefully work.

seidler2547 commented 6 years ago

@animavitis please try with the new version of this bridge and of the climate component.

animavitis commented 6 years ago
rikroe commented 5 years ago

That is something I've seen as well with my thermostats.

If one is using GUIDs for access, they are the same for varying firmware versions. However, they're totally slow, so writing a value and then subsequently reading it will overwhelm the thermostat.

That's the reason why I implemented both handle and GUID configuration in #8, and let handles take priority.

Edit: Oh darn, just saw I dug up some really old issue... Sorry for the spam guys..^^