Hi automation enthusiasts !
During the past couple of month I have worked on developing an addon for the ‘open’ TTLock BLE biometric locks that can be controlled without a gateway by directly connecting it to your HA instance (provided your host has a Bluetooth adapter). I think I am now ready to share my work with the community so here it goes:
There are a couple of caveats for now for which I’m sure that a solution will be presented in time:
- The signal of the lock is pretty weak so it needs to be fairly close to your Bluetooth device especially if using a Raspberry PI that is known for it’s weak wireless capabilities. It would be possible to manufacture a proxy gateway using some ESP32 in the future.
There are no notifications for locking and unlocking yet. It will require analyzing the TTLock gateway communication to see how to activate this feature (see below why).
- Not all the features present in the TTLock app have yet been implemented in the UI but it will be possible in time
The hardest part of the development was the reverse engineering of TTLock BLE protocol and creating my own SDK (I choose typescript for this as it was more convenient). This was done from their Android SDK sources, which includes code for multiple (older) lock types and protocols and honestly is a mess to follow. Also sometimes the lock does not react to input as it should and also not everything from their app is implemented in their Android SDK. My guess is because they don’t actually use this SDK in their official app.
UPDATE 27.03.2021: I figured out how the gateway finds out about those events and implemented the same mechanism in the latest addon release.
The code for activation of the lock/unlock event notifications is not present in their Android SDK as it would not make sense (the phone is not always in range of the lock and it would just drain battery). This is why a gateway is used for this purpose so at the moment it is not possible to receive such notifications. But, since the official gateway uses an ESP8266 and an external BLE module, it is possible to sniff the communication and figure out what commands the gateway sends and replicate them.
Now, for the interesting part of this development, I did all of this without actually having the lock myself (I ordered one but did not pay much attention and I got a Tuya WiFi version ) so a big shoutout to @Valentino_Stillhardt who actually started all this and provided me with remote access to his lock, a PI and his HA installation. Cheers !
As this is my first addon and very much in the ALPHA stage, there will be bugs so please be gentle I would preffer the bug reports to go directly into the github issues for better tracking.