kind3r / hass-addons

Integration of the offline TTLock sdk into Home Assistant
59 stars 21 forks source link

Device Paired but no functions work #11

Open botts7 opened 3 years ago

botts7 commented 3 years ago
> ttlock-hass-integration@0.2.1 start /app
> node ./index.js

MQTT connected
Monitor started
Discovered new lock: {"id":"xxxxxxxxxxxx","manufacturer":"unknown","model":"unknown","hardware":"unknown","firmware":"unknown","address":"xxxxxxxxxxxx","rssi":-76,"protocolType":5,"protocolVersion":3,"scene":2,"groupId":0,"orgId":0,"lockType":5,"isTouch":true,"isUnlock":false,"hasEvents":false,"isSettingMode":true,"txPowerLevel":0,"batteryCapacity":76,"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":[]}
Server started
Monitor stopped
Connect to lock failed xxxxxxxxxxxx
========= init
========= init
========= AES key
Bad CRC should be 216 and we got 172
========= AES key: xxxxxxxxxxxxxxxxxxxxxxxxxx
========= admin
Setting adminPs xxxxxxx and unlockKey xxxxxxx
Error while initialising lock Error: Failed AddAdmin
    at TTLock.addAdminCommand (/app/node_modules/ttlock-sdk-js/dist/device/TTLockApi.js:147:23)
    at async TTLock.initLock (/app/node_modules/ttlock-sdk-js/dist/device/TTLock.js:139:27)
    at async Manager.initLock (/app/src/manager.js:167:19)
    at async WebSocket.<anonymous> (/app/api/index.js:52:30)
========= init
Bad CRC should be 19 and we got 184
Bad CRC should be 19 and we got 184
Bad CRC should be 19 and we got 184
========= init
========= AES key
Bad CRC should be 220 and we got 90
========= AES key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
========= admin
Setting adminPs xxxxxxxxx and unlockKey xxxxxxx
========= admin: { adminPs: xxxxxxxx, unlockKey: xxxxxxxxx }
========= time
========= time
========= feature list
<Buffer 4c 04 4c d5 f7>
========= feature list Set(15) { 0, 1, 2, 4, 5, 6, 7, 8, 10, 12, 14, 15, 18, 19, 22 }
========= lockSound
========= lockSound: 1
========= autoLockTime
Error while initialising lock Error: Failed to set/get autoLockTime
    at TTLock.searchAutoLockTimeCommand (/app/node_modules/ttlock-sdk-js/dist/device/TTLockApi.js:316:23)
    at async TTLock.initLock (/app/node_modules/ttlock-sdk-js/dist/device/TTLock.js:176:32)
    at async Manager.initLock (/app/src/manager.js:167:19)
    at async WebSocket.<anonymous> (/app/api/index.js:52:30)
Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false }

> ttlock-hass-integration@0.2.1 start /app
> node ./index.js

MQTT connected
Monitor started
Server started
Discovered new lock: {"id":"xxxxxxxxxxxx","manufacturer":"unknown","model":"unknown","hardware":"unknown","firmware":"unknown","address":"xxxxxxxxxxxxxx","rssi":-61,"protocolType":5,"protocolVersion":3,"scene":2,"groupId":0,"orgId":0,"lockType":5,"isTouch":true,"isUnlock":false,"hasEvents":false,"isSettingMode":true,"txPowerLevel":0,"batteryCapacity":100,"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 new lock: {"id":"xxxxxxxxxxxx","manufacturer":"unknown","model":"unknown","hardware":"unknown","firmware":"unknown","address":"xxxxxxxxxxxxxx","rssi":-69,"protocolType":5,"protocolVersion":3,"scene":2,"groupId":0,"orgId":0,"lockType":5,"isTouch":true,"isUnlock":false,"hasEvents":false,"isSettingMode":true,"txPowerLevel":0,"batteryCapacity":74,"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
========= init
========= init
========= AES key
========= AES key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
========= admin
Setting adminPs xxxxxx and unlockKey xxxxxxxx
========= admin: { adminPs: xxxxxxxx, unlockKey: xxxxxxxxx }
========= time
========= time
========= feature list
<Buffer 4a 04 4c d5 f7>
========= feature list Set(15) { 0, 1, 2, 4, 5, 6, 7, 8, 10, 12, 14, 15, 18, 19, 22 }
========= lockSound
========= lockSound: 1
========= autoLockTime
========= autoLockTime: 5
========= getAdminCode
========= getAdminCode 
========= set adminPasscode
Generated adminPasscode: xxxxxx
SetAdminKeyboardPwdCommand received: <Buffer 4a>
========= set adminPasscode: xxxxxxx
========= remoteUnlock
========= remoteUnlock: 1
========= finished
========= finished
========= device info
Bad CRC should be 30 and we got 73
Bad CRC should be 30 and we got 73
Bad CRC should be 30 and we got 73
========= device info: {
  featureValue: '',
  modelNum: 'SN238_PV53',
  hardwareRevision: '1.1',
  firmwareRevision: '4.4.2.190705',
  nbNodeId: '',
  nbOperator: '',
  nbCardNumber: '',
  nbRssi: -1,
  factoryDate: '20190706',
  lockClock: ''
}
Disconnected from lock xxxxxxxxxxxxxx
Monitor started
Monitor stopped
Disconnected from lock xxxxxxxxxxxxxx
Monitor started
Monitor stopped

have the below in supervisor - not sure if related?

21-05-01 06:03:47 INFO (SyncWorker_0) [supervisor.docker.addon] Starting Docker add-on xxxxxxxx/amd64-addon-ttlock-hass-integration with version 0.4.0
21-05-01 06:03:48 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.32.1:55099 ssl:default [Connect call failed ('172.30.32.1', 55099)]
21-05-01 06:03:50 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.32.1:55099 ssl:default [Connect call failed ('172.30.32.1', 55099)]
botts7 commented 3 years ago

I also cannot reset lock with rest pin. I can enter the admin code to enter new passcodes. If I hold down the reset pin for longer I get asked for initialisation pin, but don't know what that is?

logs

MQTT connected
Monitor started
Discovered paired lock: xxxxxxxxxxx
Monitor stopped
Server started
Disconnected from lock xxxxxxxxxxx
Monitor started
kind3r commented 3 years ago

From the log you posted I would investigate a communication issue, but on the other hand the RSSI value is good.

I'm not fammiliar with the model number but the firmware seems a bit older. Mine has version 5.1.0.200323. I would try to pair it with the app and check for an update.

To reset the lock to factory defaults, there is a swith on the PCB behind the keypad. You need to remove the back plate to get to it. Hold it for 4s and the lock should beep and reset to defaults. Less than that would just reboot the lock.

I'm not sure what you mean by the reset pin. There is no way that I am aware of to reset the lock after it was paired other than via the app it was paired with (besides using the hardware switch mentioned above).

botts7 commented 3 years ago

Reset pin = switch on back of keypad. I managed to get it back to default settings.

Long hold - lock voice asks for initialisation pin Enter 00000000 #

Since doing this I have tried at least 100 time to pair with add-on. But I get

Unable to set lock time

Or

Unable to set admin password

The lock says

Either

admin successfully added then admin successfully deleted

Or

Straight to admin successfully deleted

Any ideas?

kind3r commented 3 years ago

Could you post a link to the lock you have ? The one I have does not have voice and does not ask for an initialisation pin when hardware reseting.

Looking at the feature list I see the device reports HOTEL_LOCK. I remember from the Android SDK that those require some additional configuration steps during or after pairing. I'll have to look into it but it will take some time.

botts7 commented 3 years ago

https://www.doorguard.com.au/pages/how-works

botts7 commented 3 years ago

Just to note. Even with the official TTlock app the app fails to set clock time -but still pairs and functions

Im assuming your code in the sdk, deletes administrator if this fails?

Error while initialising lock Error: Failed setting lock time
    at TTLock.calibrateTimeCommand (/app/node_modules/ttlock-sdk-js/dist/device/TTLockApi.js:174:23)
    at async TTLock.initLock (/app/node_modules/ttlock-sdk-js/dist/device/TTLock.js:147:13)
    at async Manager.initLock (/app/src/manager.js:167:19)
    at async WebSocket.<anonymous> (/app/api/index.js:52:30)
kind3r commented 3 years ago

Altho I'm not sure that the issues are from setting time, I've now made it optional during initial pairinig so that it can be skipped in case of an error.

The SDK does not have a rollback procedure in case it fails at some point. The way it works is after all the setup commands have been issued there is an operateFinishedCommand which basically tells the lock to save it's settings. Else, in principle, it should not save and revert to the default state.

When you say The lock says I'm assuming you mean it actually speaks. The lock I have does not have any voice feedback, just some beeps.

II took a brief look at how the HOTEL locks are handled, but did not find anything yet that would differ from the regular pairing except you can set some extra info like buildinig number, floor number, room number etc. I did see some extra AES like keys that are used together with the hotel data, but not sure how those are obtained yet and what is their purpose so I need more time to dig in.

So, you might try the new update but I don't think it will make any difference yet.

botts7 commented 3 years ago

Got lock to paired - but functions dont work image

Yes the lock has speech - locked, unlocked, etc

Peripheral connect start Peripheral connect triggered Peripheral connect error: Error: connection canceled! at Peripheral.cancelConnect (/app/node_modules/@abandonware/noble/lib/peripheral.js:61:26) at NobleDevice.connect (/app/node_modules/ttlock-sdk-js/dist/scanner/noble/NobleDevice.js:91:37) at async TTBluetoothDevice.connect (/app/node_modules/ttlock-sdk-js/dist/device/TTBluetoothDevice.js:47:17) at async TTLock.connect (/app/node_modules/ttlock-sdk-js/dist/device/TTLock.js:53:27) at async Manager._connectLock (/app/src/manager.js:583:21) at async Manager.unlockLock (/app/src/manager.js:187:13) at async WebSocket. (/app/api/index.js:78:30) Connect failed

Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false } lockUpdated { batteryCapacity: true, newEvents: false, lockedStatus: false } Emmiting paramsChanged { batteryCapacity: true, newEvents: false, lockedStatus: false } lockUpdated { batteryCapacity: true, newEvents: false, lockedStatus: false } Peripheral connect start Peripheral connect triggered Peripheral connect error: Error: connection canceled! at Peripheral.cancelConnect (/app/node_modules/@abandonware/noble/lib/peripheral.js:61:26) at NobleDevice.connect (/app/node_modules/ttlock-sdk-js/dist/scanner/noble/NobleDevice.js:91:37) at async TTBluetoothDevice.connect (/app/node_modules/ttlock-sdk-js/dist/device/TTBluetoothDevice.js:47:17) at async TTLock.connect (/app/node_modules/ttlock-sdk-js/dist/device/TTLock.js:53:27) at async Manager._connectLock (/app/src/manager.js:583:21) at async Manager.unlockLock (/app/src/manager.js:187:13) at async WebSocket. (/app/api/index.js:78:30) Lock connect failed Connect to lock failed

MIIB1 commented 3 years ago

hi

any update i have same problem my hass-addons con't Connect to lock it failed

justinlawrence commented 2 years ago

I'm having a similar pairing issue. My lock also speaks. If I do a short-press of the reset button after a long-press factory reset, it says, "add bluetooth administrator" and if I short-press the reset once more, it says something like "input new administrator passcode". Then it asks me to confirm the new passcode and seems happy, but then the lock doesn't show in the HA/TTLock pairing list.

If I do another factory reset, then I can see it in the pairing list, but it doesn't ever pair.

Which of those two routes should I be taking please?

jmayes2 commented 2 years ago

I am having the same problem, I can get it to pair but then nothing, if I go to credentials I get 3 lines with swirls one for each type of input (fingerprint, keypad, card). It never moves on and I can not program it. Hitting any key causes it to say to input a "Bluetooth admin password". Resetting the lock will cause it to fail pairing until I delete the configuration information in your addon. I have tried two different locks on two different HA installations. Both use pi-3b and I have the locks within a few feet of them. Any help would be great! J

ronluna commented 2 years ago

I'm having the same problem. It seems that after pairing noble simply crash. no new commands are sent after pairing . I'm running the latest firmware (5.1) the deivce can pair but no fruther commands are processed after pairing.

The logs show everything ok . but after disconnecting during the initialization of the addon no fruther commands can be sent to the lock

Any ideas ?

` [19:14:32] ERROR: Got unexpected response from the API: Service not enabled

ttlock-hass-integration@0.2.1 start node ./index.js Monitor started Discovered paired lock: CF:95:59:0F:2B:A1 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 Lock waiting for connection to be completed <Buffer 64 20 44 d1 f7> ========= feature list Set(14) { 0, 1, 2, 4, 5, 6, 7, 8, 12, 14, 15, 18, 22, 29 } ========= check admin ========= check admin: 11562 ========= check random ========= check random ========= autoLockTime ========= autoLockTime: 5 ========= lockSound ========= lockSound: 1 Connected to paired lock CF:95:59:0F:2B:A1 Successful connect attempt to paired lock CF:95:59:0F:2B:A1 Disconnected from lock CF:95:59:0F:2B:A1 `

Fusseldieb commented 2 years ago

I'm sure this is unrelated, but please don't update firmwares when working with hacky stuff, since this will likely break stuff even more, not improve it.