HASS Addon TTLock offline integration

When I touch my keypad to wake up the lock, it says “please add a bluetooth administrator”. Should I do that before following your instructions?

Hi! I have a problems with installation of addon can you help me
" Failed to install add-on

The command ‘/bin/ash -o pipefail -c apk update’ returned a non-zero code: 2"

Thanks you @kind3r for the awesome work!

I did manage to install the addon seamlessly on my RPI3. Following your instructions, the pairing was successful right away. I actually tried it a couple of times with 4 different locks (same brand) and pairing always succeeded on first shot.
However, I couldn’t do anything from the Web UI beyond the pairing. Unlock, change settings, retrieving/setting credentials they all fail. I turned on the debug settings and below is the log. I will appreciate any guidance.
Thanks!

[10:40:31] ERROR: Got unexpected response from the API: Service not enabled
IGNORE CRC TRUE
Debug communication ON

[email protected] start
node ./index.js
Monitor started
Discovered paired lock: 8B:F5:A8:29:A3:D7
Server started
Monitor stopped
Peripheral connect start
Peripheral connect triggered
Peripheral state: connected
Device emiting connected
BLE Device reading basic info
BLE Device discover services start
BLE Device discover services end
BLE Device read characteristics start
BLE Device read characteristics end
BLE Device read characteristics start
BLE Device read characteristics end
BLE Device read basic info
BLE Device subscribed
Connected to known lock, reading general data
========= feature list
Sending command: 7f5a0503010001000101aa001c0d0a
Lock waiting for connection to be completed
Received response: 7f5a050302000a002254aa20a4f4f6bdaf84476905cf151c7d3a668880fb279904e46b3e602afc1c3cb7c85f9a0d0a
Command: 20754cd1f700000f440000000000000000
<Buffer 20 75 4c d1 f7 00 00 0f 44 00 00 00 00 00 00 00 00>
========= feature list Set(18) {
0,
1,
2,
4,
5,
6,
7,
8,
12,
14,
15,
18,
19,
22,
24,
28,
29,
30
}
========= check admin
Sending command: 7f5a0503010001000141aa106f78b19fc4a5ff0c9a084ac28f7d54e4700d0a
Received response: 7f5a050302000a002254aa1019b3c4287b28599cb580e2afd2b15426130d0a
Command: 00009cc0
========= check admin: 40128
========= check random
Sending command: 7f5a0503010001000130aa102fdeed08f211fd9486653efb7e3a07b3920d0a
Received response: 7f5a050302000a002254aa10dca39d10ac99a8904e0df1038db9762cd50d0a
Command: 20
========= check random
========= autoLockTime
Sending command: 7f5a0503010001000136aa10623b625846dbd13cbe994d6b5cd74459890d0a
Received response: 7f5a050302000a002254aa10c7948a939daa78d185a2b83278a552023d0d0a
Command: 2001000500010384
========= autoLockTime: 5
========= lockSound
Sending command: 7f5a0503010001000162aa10623b625846dbd13cbe994d6b5cd74459770d0a
Received response: 7f5a050302000a002254aa10a7dbb05a70eade41051fbecd1322831c150d0a
Command: 200101050102
========= lockSound: 1
Connected to paired lock 8B:F5:A8:29:A3:D7
Successful connect attempt to paired lock 8B:F5:A8:29:A3:D7
Disconnected from lock 8B:F5:A8:29:A3:D7
Connect allready in progress
Connect to lock failed 8B:F5:A8:29:A3:D7
Connect allready in progress
Connect to lock failed 8B:F5:A8:29:A3:D7

I had those same problems. Was thinking it was broken, but ended up building the wifi/BLE gate way linked above, and here just to be easy. It’s working fine now. Getting the thing to build was a bit tricky because the development libraries changed and it hadn’t been updated in a while, but there’s been a lot of activity in the project since then so that’s probably not the case anymore.

The board I used was: https://www.amazon.com/dp/B07QDFP3WC

Edit to make it clear who I was responding too.
Edit corrected link

Thank you @netsplit64 for your tips!

I also suspected some Bluetooth reliability issues. However, the fact that the pairing process seems to work consistently every time on first shot made me think that there was a reasonable connection. Also, every time I start the addon, the paired lock detection and fetching of its attributes seems to work fine. I was hoping there could be something in the log that could hint to the problem.

Re the ESP32 gateway project pointed to by your message (GitHub - h2zero/NimBLE-Arduino: A fork of the NimBLE library structured for compilation with Ardruino, designed for use with ESP32.). Is it different than the one referred to by @kind3r in a message above (GitHub - kind3r/esp32-ble-gateway: WiFi to BLE gateway on ESP32)? Are they equivalent?

Do you know whether these would run on an ESP32 WROOM? Or do they absolutely require a WROVER?

Thanks!

Whoops I got mixed up.

GitHub - kind3r/esp32-ble-gateway: WiFi to BLE gateway on ESP32 is the correct one. Sorry for the mistake.

The bluetooth issues I had connecting to the Pi directly were it’d pair sometimes. IF I got it to pair it’d start erroring out putting in credentials. If I managed to put in a key fob, or a passcode it’d still soon disconnect and refuse to work. Never did figure out the issue, but decided to give the gateway a go and it’s been pretty solid.

I can’t say for sure about a WROOM. The project does have this comment:

At the moment, the project is only configured to work on ESP32-WROVER boards. If you have a different board, you need to edit the platformio.ini file and create your own env configuration. As of this writing the code takes about 1.5Mb so I’m using the min_spiffs.csv partition scheme in order to be able to hopefully do OTA in the future.

So possibly. All I know for sure is by that point I was pretty frustrated and just got a WROVER board, and it worked solid once it built and installed it on the WROVER board.

That said getting VScode to build it was it’s own little bit of fun. The build instructions are bit hackish to start, but still don’t work. I tracked the issues down to two problems in the platformio.ini file:

line 20: [email protected]:h2zero/NimBLE-Arduino.git#refactor-advertised-device

Somehow there’s a comment on the same line as library dependency

Change that to:

line 20: [email protected]:h2zero/NimBLE-Arduino.git
#refactor-advertised-device

or just delete the comment.

line 23: platform_packages =
line 24:     platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

Comment out these or delete them. Otherwise you’ll get lots of build failures. They cause VScode to get the wrong dependencies.

1 Like

thank you so much for the quick response and sharing of your experience!
I will order a WROVER and will give it a try.
Thanks!

1 Like

Here’s what I’ll use for wroom, it was able to build but I will try to upload it on one of my wroom. I was using a pi zero w before but I needed to reuse it for room-assistant.

EDIT: wroom only has 4mb flash size and the bin file is 1.4mb so cannot do OTA. I haven’t tried uploading this yet.

[env]
platform = espressif32
framework = arduino
monitor_speed = 921600
upload_speed = 921600
lib_deps =
    bblanchon/ArduinoJson@^6.17.2
    links2004/WebSockets@^2.3.3
    h2zero/NimBLE-Arduino@^1.3.6
    ; [email protected]:h2zero/NimBLE-Arduino.git#refactor-advertised-device
    esp32_https_server@^1.0.0
monitor_filters = esp32_exception_decoder
platform_packages =
   platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#46d5afb17fb91965632dc5fef237117e1fe947fc
board_build.partitions = min_spiffs.csv
[env:espwroom32-debug]
platform = espressif32
board = nodemcu-32s
build_type = debug
build_flags =
        -DCORE_DEBUG_LEVEL=3
    ; -DBOARD_HAS_PSRAM
        ; -mfix-esp32-psram-cache-issue
        -DLOG_LOCAL_LEVEL=ESP_LOG_INFO
[env:espwroom32]
platform = espressif32
board = nodemcu-32s
build_flags =
    ; -DBOARD_HAS_PSRAM
        ; -mfix-esp32-psram-cache-issue
        ; -DCORE_DEBUG_LEVEL=5
1 Like

thank you @accelle. please let me know how it goes when you upload it to a wroom.

Thanks

I did build the GW using a ROVER and finally got it to work. Thanks again @netsplit64 for the details on what to change in the platformio.ini file!

I actually bought 2 different ESP32 ROVER boards and for some reason the first one I tried didn’t work for me (https://www.amazon.com/dp/B087TF2L27?psc=1&ref=ppx_yo2_dt_b_product_details). It occasionally managed to discover the lock but would not even succeed at pairing (no matter how close to the lock I put it).

The second one (https://www.amazon.com/dp/B09BC5CNHM psc=1&ref=ppx_yo2_dt_b_product_details ) is the one that worked. I had to place it really close to the lock in order to pair successfully. Since then, I moved it a little bit away and it seems to be working fine.

Thanks again @kind3r for your work! I guess next step is to figure out a way to get multiple ESP32 GWs working with the addon to allow controlling the multiple ttlock devices in the house.

1 Like

Hi using the details from this post, Iam now up and running, if anyone is interested i used this board Freenove ESP32.

Sorry for the continued annoying post by myself, i had to pull the batteries today, to take the Multipoint lock to pieces, as it keeps catching, i note on repowering up i now have invalid date anyone know how to fix this?

Hi, I would like to understand what ready-made usb adapter I could take for RPI4. In a usb I have the conbee 2, I still have a free one I would like to understand what I can use? something simple to use with hassio.
The Rpi4 does not have bluetooth already integrated that I can use? Thank you.

Hi, can’t pair my door lock but the log discovered one lock. Can anyone help?

‘’’

[email protected] start
node ./index.js
[Error: ENOENT: no such file or directory, access ‘/data/lockData.json’] {
errno: -2,
code: ‘ENOENT’,
syscall: ‘access’,
path: ‘/data/lockData.json’
}
[Error: ENOENT: no such file or directory, access ‘/data/aliasData.json’] {
errno: -2,
code: ‘ENOENT’,
syscall: ‘access’,
path: ‘/data/aliasData.json’
}
MQTT connected
Monitor started
Server started
Discovered unknown lock: {“id”:“2572f0f9aeac”,“manufacturer”:“unknown”,“model”:“unknown”,“hardware”:“unknown”,“firmware”:“unknown”,“address”:“25:72:F0:F9:AE:AC”,“rssi”:-51,“protocolType”:5,“protocolVersion”:3,“scene”:2,“groupId”:0,“orgId”:0,“lockType”:5,“isTouch”:true,“isUnlock”:false,“hasEvents”:false,“isSettingMode”:false,“txPowerLevel”:0,“batteryCapacity”:60,“date”:0,“isWristband”:false,“isRoomLock”:true,“isSafeLock”:false,“isBicycleLock”:false,“isLockcar”:false,“isGlassLock”:false,“isPadLock”:false,“isCyLinder”:false,“isRemoteControlDevice”:false,“isDfuMode”:false,“isNoLockService”:false,“remoteUnlockSwitch”:0,“disconnectStatus”:0,“parkStatus”:0,“lockSound”:-1,“autoLockTime”:-1,“privateData”:{},“operationLog”:} ‘’’

Hi, can you please tell me how did you manage to get notification, add the Ttlock supported lock to HomeKit?
I’m using a smart door lock from Aliexpress (see picture), I only have one old MacBook Pro 2010 running High Sierra,


I don’t have Windows computer or Raspberry PI. It is possible to add my smart door lock to Apple HomeKit (for automation, receive notifications, see status update)? Please let me know. Maybe @kind3r will guide me with step by step what to do from the beginning.

Have a great day!

Hi ya,

Thank you so much for the development and great effort!
After i read the this post, i was really excited and placed an order for TTLOCK door handle lock with finger print and passwords. I have tried on my raspi4 using this integration but i was struggling to get it connected. I managed to find the lock during the scanning and managed to pair it. However, without a sec delay, the lock is disconnected. I have attached the logs as per below:

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’

IGNORE CRC TRUE
Debug communication ON
Debug MQTT
Debug gateway

[email protected] start
node ./index.js
MQTT connected
Monitor started
Discovered paired lock: CE:97:A8:92:87:A2
Monitor stopped
Peripheral connect start
Server started
Peripheral connect triggered
Peripheral state: connected
Device emiting connected
BLE Device reading basic info
BLE Device discover services start
BLE Device discover services end
BLE Device read characteristics start
BLE Device read characteristics end
BLE Device read characteristics start
BLE Device read characteristics end
BLE Device read basic info
BLE Device subscribed
Connected to known lock, reading general data
========= feature list
Sending command: 7f5a0503010001000101aa001c0d0a
Lock waiting for connection to be completed
Received response: 7f5a050302000a005454aa20709580730566cc7b9a08ef87eb00d6d87446e16a06bda8970de258c9dae055d3410d0a
Bad CRC should be 19 and we got 65
Command: 3821c4f1f5000c27440000000000000000
<Buffer 38 21 c4 f1 f5 00 0c 27 44 00 00 00 00 00 00 00 00>
========= feature list Set(16) { 0, 2, 4, 5, 6, 7, 8, 12, 13, 14, 15, 18, 22, 23, 24, 29 }
========= check admin
Sending command: 7f5a0503010001000141aa103cb4a149eb4b69b92629970b37e9276ab40d0a
Received response: 7f5a050302000a005454aa102702e1fc7009d2fe745e64b553b769dd660d0a
Bad CRC should be 194 and we got 102
Command: 0000cdf8
========= check admin: 52728
========= check random
Sending command: 7f5a0503010001000130aa104ee9bb50b396077513d695cbbb48b541080d0a
Received response: 7f5a050302000a005454aa1005ab116e11ac2eb5da08ada4e4646a216f0d0a
Bad CRC should be 203 and we got 111
Command: 38
========= check random
========= autoLockTime
Sending command: 7f5a0503010001000136aa10fd2dbcfaf511511e8e91b896de81683d7c0d0a
Received response: 7f5a050302000a005454aa101d0ee2cce79ae75a911e125465e9ec9a640d0a
Bad CRC should be 192 and we got 100
Command: 380100050001038401
========= autoLockTime: 5
========= lockSound
Sending command: 7f5a0503010001000162aa10fd2dbcfaf511511e8e91b896de81683d820d0a
Received response: 7f5a050302000a005454aa10311f58524f9e5e0c53cc05dc6588f78ee90d0a
Bad CRC should be 77 and we got 233
Command: 380101
========= lockSound: 1
Connected to paired lock CE:97:A8:92:87:A2
MQTT Publish homeassistant/lock/ce97a89287a2/lock/config {“unique_id”:“ttlock_ce97a89287a2”,“name”:“PLDT190_a28792\u0000\u0000\u0000\u0000”,“device”:{“identifiers”:[“ttlock_ce97a89287a2”],“name”:“PLDT190_a28792\u0000\u0000\u0000\u0000”,“manufacturer”:“Sciener”,“model”:“SN373-R-150MS-T12”,“sw_version”:“6.4.11.220206”},“state_topic”:“ttlock/ce97a89287a2”,“command_topic”:“ttlock/ce97a89287a2/set”,“payload_lock”:“LOCK”,“payload_unlock”:“UNLOCK”,“state_locked”:“LOCK”,“state_unlocked”:“UNLOCK”,“value_template”:“{{ value_json.state }}”,“optimistic”:false,“retain”:false}
MQTT Publish homeassistant/sensor/ce97a89287a2/battery/config {“unique_id”:“ttlock_ce97a89287a2_battery”,“name”:“PLDT190_a28792\u0000\u0000\u0000\u0000 Battery”,“device”:{“identifiers”:[“ttlock_ce97a89287a2”],“name”:“PLDT190_a28792\u0000\u0000\u0000\u0000”,“manufacturer”:“Sciener”,“model”:“SN373-R-150MS-T12”,“sw_version”:“6.4.11.220206”},“device_class”:“battery”,“unit_of_measurement”:“%”,“state_topic”:“ttlock/ce97a89287a2”,“value_template”:“{{ value_json.battery }}”}
MQTT Publish homeassistant/sensor/ce97a89287a2/rssi/config {“unique_id”:“ttlock_ce97a89287a2_rssi”,“name”:“PLDT190_a28792\u0000\u0000\u0000\u0000 RSSI”,“device”:{“identifiers”:[“ttlock_ce97a89287a2”],“name”:“PLDT190_a28792\u0000\u0000\u0000\u0000”,“manufacturer”:“Sciener”,“model”:“SN373-R-150MS-T12”,“sw_version”:“6.4.11.220206”},“unit_of_measurement”:“dB”,“icon”:“mdi:signal”,“state_topic”:“ttlock/ce97a89287a2”,“value_template”:“{{ value_json.rssi }}”}
MQTT Publish ttlock/ce97a89287a2 {“battery”:56,“rssi”:-50,“state”:“LOCK”}
Successful connect attempt to paired lock CE:97:A8:92:87:A2
Disconnected from lock CE:97:A8:92:87:A2
“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”

I tried all the suggestions you have mentioned in the post, i.e. wait for restart, wait for 30sec, touch the lock and pairing them. But still no luck. Could you kindly point me to the right direction? really appreciate that.

Can anyone break down for me the hardware needed for this? I’d love to get one of these TTLock multipoints, but its a little unclear exactly how you get the BLE to work.

My Hass is a virtual server (VMWare) in another part of the house, so is there such a thing as a bluetooth to WIFI dongle, or bluetooth to ethernet hardware that I’d need to be able to do this?

Am I better off just getting the gateway that these come with to connect to my WIFI, can HASS and this integration use the gateway to control the locks instead of bluetooth?

I am not an expert but:
I think the gateway uses its own Bluetooth to connect with the locks. The locks don’t have any other connectivity, only Bluetooth - so either you connect with them by standing close by and using Bluetooth from a phone etc, or you connect with them using the gateway, which you can access through wifi and this integration.

My HA’s Bluetooth is not used for any of these connections; HA → gateway → locks.

Unsure how you could do this without the gateway, since the integration uses the manufacturer’s API to interact with the gateway connection to the locks.

Yeah thanks, that’s what I wanted to know. It seemed like we were talking about Bluetooth being the only connectivity. But the API is available through the gateway, so it can work offline ?

That’s pretty much all I wanted to know! Thanks

1 Like

The API calls back to TTLOCK’s servers, so no, it’s not able to work offline.