HASS Addon TTLock offline integration

I am having the same issue… anyone have a solution?

HASS Addon TTLock offline integration - #80 by netsplit64 this post includes information about how to fix the build failures

Thanks for your work there! But even after following that i am getting build errors:

In file included from src/gw_settings.h:5,
                 from src/gw_settings.cpp:1:
src/security.h:4:10: fatal error: hwcrypto/aes.h: No such file or directory
 #include <hwcrypto/aes.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\esp-wrover\src\util.cpp.o
Compiling .pio\build\esp-wrover\src\web.cpp.o
Generating partitions .pio\build\esp-wrover\partitions.bin
In file included from src/security.cpp:1:
src/security.h:4:10: fatal error: hwcrypto/aes.h: No such file or directory
 #include <hwcrypto/aes.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio\build\esp-wrover\libfa3\WiFi\WiFi.cpp.o
Compiling .pio\build\esp-wrover\libfa3\WiFi\WiFiAP.cpp.o
Compiling .pio\build\esp-wrover\libfa3\WiFi\WiFiClient.cpp.o
Compiling .pio\build\esp-wrover\libfa3\WiFi\WiFiGeneric.cpp.o
*** [.pio\build\esp-wrover\src\gw_settings.cpp.o] Error 1
*** [.pio\build\esp-wrover\src\security.cpp.o] Error 1
In file included from src/gw_settings.h:5,
                 from src/web.h:16,
                 from src/web.cpp:1:
src/security.h:4:10: fatal error: hwcrypto/aes.h: No such file or directory
 #include <hwcrypto/aes.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp-wrover\src\web.cpp.o] Error 1
In file included from src/gw_settings.h:5,
                 from src/main.cpp:7:
src/security.h:4:10: fatal error: hwcrypto/aes.h: No such file or directory
 #include <hwcrypto/aes.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp-wrover\src\main.cpp.o] Error 1
In file included from src/gw_settings.h:5,
                 from src/noble_api.h:12,
                 from src/noble_api.cpp:1:
src/security.h:4:10: fatal error: hwcrypto/aes.h: No such file or directory
 #include <hwcrypto/aes.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp-wrover\src\noble_api.cpp.o] Error 1

There’s something up with your dependencies.

Here’s my working platform.io file from the project. Maybe compare and see if anything is different to yours:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
platform = espressif32
framework = arduino
monitor_speed = 92160078uhjy632iku10
upload_speed = 921600
lib_deps = 
	bblanchon/ArduinoJson@^6.17.2
	links 201004/WebSockets@^2.3.3
	; h2zero/NimBLE-Arduino@^1.1.0
	[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
board_build.partitions = min_spiffs.csv

[env:esp-wrover-debug]
board = esp-wrover-ie-module
build_type = debug
build_flags =
		-DCORE_DEBUG_LEVEL=3
    ; -DBOARD_HAS_PSRAM
		; -mfix-esp32-psram-cache-issue
		-DLOG_LOCAL_LEVEL=ESP_LOG_INFO

[env:esp-wrover]
board = esp-wrover-ie-module
build_flags =
    ; -DBOARD_HAS_PSRAM
		; -mfix-esp32-psram-cache-issue
		; -DCORE_DEBUG_LEVEL=5

I experience the same outcome from my PI 4B when trying to pair with my locks.
When I ssh into the PI and scan using bluetoothctl, [scan on] I can easily see both locks.
@luishang did you find a resolution to your issue?

My Log

MQTT connected
Monitor started
Server started
Discovered unknown lock: {"id":"d234a3bddd70","manufacturer":"unknown","model":"unknown","hardware":"unknown","firmware":"unknown","address":"D2:34:A3:BD:DD:70","rssi":-61,"protocolType":5,"protocolVersion":3,"scene":2,"groupId":0,"orgId":0,"lockType":5,"isTouch":true,"isUnlock":false,"hasEvents":true,"isSettingMode":false,"txPowerLevel":0,"batteryCapacity":45,"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":[]}
Discovered unknown lock: {"id":"dfe174a3dd0c","manufacturer":"unknown","model":"unknown","hardware":"unknown","firmware":"unknown","address":"DF:E1:74:A3:DD:0C","rssi":-69,"protocolType":5,"protocolVersion":3,"scene":2,"groupId":0,"orgId":0,"lockType":5,"isTouch":true,"isUnlock":false,"hasEvents":false,"isSettingMode":false,"txPowerLevel":0,"batteryCapacity":15,"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":[]}
Monitor stopped
BLE Scan started
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }
BLE Scan stopped
Refreshing paired locks
Monitor started
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }
processLeAdvertisingReport: Caught illegal packet (buffer overflow): RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 24. Received 66
processLeAdvertisingReport: Caught illegal packet (buffer overflow): RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 28. Received 219
Monitor stopped
BLE Scan started
BLE Scan stopped
Refreshing paired locks
Monitor started
processLeAdvertisingReport: Caught illegal packet (buffer overflow): RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 24. Received 104
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }
Monitor stopped

I was able to get this to compile finally; here is everything i did that deviated from instructions:
platformio.ini

Then in explorer go to .pio/src/security.h

  • change line 4 to #include <esp32/aes.h>

Then build, you will run into an error that’s expected.

In explorer navigate to .pio/build/libdeps/esp-wrover/esp32_https_server/src/HTTPConnection.hpp

  • change line 9 to #include <esp32/sha.h>

You should now be able to build and compile code for upload. Don’t forget to upload file system image first and you can ignore the loop stack size due to commenting out platform packages.

Hope this helps others. I can confirm i was able to get my lock up an running within home assistant.

This is awesome

Finally a way to get a doorlock for under 250,- into Home Assistant

Does anyone have This lock working ?

I hope someone is able to pick back up where the author started. I don’t fault them at all for not having the time to work on this project, but it is really cool and almost works for me.

I am able to pair with my lock but then further commands never work. All the logs look good, but clicking unlock or anything just never does anything.

Did you get this working ?

i actually got the Tuya version and that one seems to have a separate board connected on the inside part that has the tuya wifi chip on it
soldering a esp8266 on it looks like it will be possible but i don’t have a clue how to write the firmware

Like mentioned before, this would be a lot more work and hacking. Just going for the BLE version with a dongle might be easier.

But it would be a cleaner solution of course to have your lock running ESPHome.
Could you take some pictures of the pcbs in your lock?

Thank you so much for your tips!
I was able to make mine working after following your steps.

Hey Badmuz. Still can’t get mine working. Thoughts? What exactly did you follow.

Hi all…

Hope someone can help me getting this to work.
I have installed a fresh HA on a spare Raspberry Pi 4 for testing.
Installed the ttlock addon. and when starting the addon, the log only gives me

IGNORE CRC TRUE
Debug communication ON
Debug MQTT
Debug gateway
> [email protected] start
> node ./index.js
ERROR:	Could not load manufacturer list from "./manufactures-hex.json".
	Please see "/app/node_modules/@abandonware/noble/scripts/manufactures/README.md" for instructions.
ERROR:	Could not load manufacturer list from "./manufactures-dec.json".
	Please see "/app/node_modules/@abandonware/noble/scripts/manufactures/README.md" for instructions.
[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
TypeError: this.noble.on is not a function
    at NobleScanner.initNoble (/app/node_modules/ttlock-sdk-js/dist/scanner/noble/NobleScanner.js:25:24)
    at new NobleScanner (/app/node_modules/ttlock-sdk-js/dist/scanner/noble/NobleScanner.js:18:14)
    at new BluetoothLeService (/app/node_modules/ttlock-sdk-js/dist/scanner/BluetoothLeService.js:14:28)
    at TTLockClient.prepareBTService (/app/node_modules/ttlock-sdk-js/dist/TTLockClient.js:43:31)
    at Manager.init (/app/src/manager.js:90:48)
    at module.exports (/app/src/init.js:60:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Server started

I noticed that the BT device on the rpi is added under devices and entities. Is that ok? og should i remove it from devices and entities?

The BLE scan never starts.

Any advice is greatly appreciated.

Hi, does this work with bluetooth proxy (esphome)?
Would be great if i could just place an esp32 near the lock

Also, has anyone paired with this bluetooth lock?
This one’s using ttlock

https://www.walmart.com/ip/782246813

3 Likes

Hi All,

I second this question as I would like to know if it’s possible. ta

1 Like

I’ve been trying to do this… but no luck yet!

hi, although I made these changes when I go to upload the upload file system image it gives me the following error:

Building in release mode
Building FS image from ‘data’ directory to .pio\build\esp-wrover\spiffs.bin
/index.html.gz
SPIFFS_write error(-10001): File system is full.

error adding files!
*** [.pio\build\esp-wrover\spiffs.bin] Error 1

do you know how I can solve it? Thank you

Curious myself.