xrucka / eclipse-smarthome-bluetooth-binding-device-cometblue

OpenHab plugin for Eurotronic's CometBlue smart radiator valve
3 stars 1 forks source link

Automatic pin code authentication #1

Open vkolotov opened 6 years ago

vkolotov commented 6 years ago

Noticed this: https://github.com/xrucka/eclipse-smarthome-bluetooth-binding-device-cometblue/blob/fe3f7b14a1c0ed6e4a75db1c3185191d1a3edce2/src/main/resources/gatt/characteristic/org.eurotronic.cometblue.characteristic.pin_code.xml#L14

Just a hint to do some magic with authentication via pin code. I have not documented this yet, but you could define pin code value in your gatt spec like that:

https://github.com/sputnikdev/bluetooth-gatt-parser/blob/0e8f1f74bbe501abf7333defae9864de04848fda/src/main/resources/gatt/characteristic/com.minew.bluetooth.characteristic.keyfinder_pin_code.xml#L37

You also leave "Authentication strategy" in the OH device settings as "Auto": image

This would mean that if the binding finds a characteristic with "Pin code" name, then it will try to find pin code value in its enumeration list by PIN_CODE key. If it finds it, then it will use it automatically when performing authentication.

It is just a "nice to have" thing that would make using your device easier....

PS. You don't have to specify "Auth Status" in your gatt spec, if is it omitted, then the binding won't check/listen if authentication is successful. If it is specified, then the binding tries to add a value listener and it checks values when pin code is written.

Here is another example: https://github.com/sputnikdev/bluetooth-gatt-parser/blob/0e8f1f74bbe501abf7333defae9864de04848fda/src/main/resources/gatt/characteristic/com.xiaomi.bluetooth.characteristic.miflora_pin_code.xml#L12

It is just a hint, just close this issue if you think it is better to do manual authentication for any reason.

Cheers