Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTLock fails to load with multiple locks (since 0.4.x) #34

Closed
HerveB opened this issue Apr 23, 2023 · 26 comments · Fixed by #35
Closed

TTLock fails to load with multiple locks (since 0.4.x) #34

HerveB opened this issue Apr 23, 2023 · 26 comments · Fixed by #35
Labels
bug Something isn't working

Comments

@HerveB
Copy link

HerveB commented Apr 23, 2023

I get the following error message:
Retrying setup: 1 validation error for LockState state field required (type=value_error.missing)

0.3.x was working fine. I deleted the entities when I upgraded to 0.4.3 and go the error above. Same error persisted with 0.4.4 and 0.4.5

@jbergler
Copy link
Owner

Thanks for the report @HerveB.

Can you please turn on debug logging for the component (since HA 2023.4 you should be able to do this from the integration UI) and share the last few log lines before the error. Should look something like this:

2023-04-23 14:42:17.424 DEBUG (MainThread) [custom_components.ttlock.api] Sending request to https://euapi.ttlock.com/v3/lock/detail with args={'lockId': 7252408}
2023-04-23 14:42:17.730 DEBUG (MainThread) [custom_components.ttlock.api] Received response: {'date': 1669690212000, 'lockAlias': 'Front Door', 'lockSound': 2, 'modelNum': 'SN9206_PV53', 'lockMac': '16:72:4C:CC:01:C4', 'privacyLock': 2, 'deletePwd': '', 'featureValue': 'F44354CD5F3', 'adminPwd': '<REMOVED>', 'soundVolume': 5, 'hasGateway': 1, 'autoLockTime': 60, 'wirelessKeypadFeatureValue': '0', 'lockKey': '<REMOVED>', 'isFrozen': 2, 'lockName': 'S31_c401cc', 'resetButton': 1, 'firmwareRevision': '6.0.6.210622', 'tamperAlert': 1, 'specialValue': 894227955, 'displayPasscode': 0, 'noKeyPwd': '<REMOVED>', 'passageMode': 1, 'passageModeAutoUnlock': 2, 'timezoneRawOffset': 46800000, 'lockId': 7252408, 'electricQuantity': 90, 'lockFlagPos': 0, 'lockUpdateDate': 1682201024000, 'keyboardPwdVersion': 4, 'aesKeyStr': '<REMOVED>', 'hardwareRevision': '1.6', 'openDirection': 0, 'lockVersion': {'groupId': 10, 'protocolVersion': 3, 'protocolType': 5, 'orgId': 34, 'scene': 2}, 'sensitivity': -1}
2023-04-23 14:42:17.731 DEBUG (MainThread) [custom_components.ttlock.api] Sending request to https://euapi.ttlock.com/v3/lock/queryOpenState with args={'lockId': 7252408}
2023-04-23 14:42:19.547 DEBUG (MainThread) [custom_components.ttlock.api] Received response: {'state': 1}
2023-04-23 14:42:19.547 DEBUG (MainThread) [custom_components.ttlock.api] Sending request to https://euapi.ttlock.com/v3/lock/getPassageModeConfig with args={'lockId': 7252408}
2023-04-23 14:42:19.860 DEBUG (MainThread) [custom_components.ttlock.api] Received response: {'autoUnlock': 2, 'isAllDay': 2, 'endDate': 1200, 'weekDays': [1, 2, 3, 4, 5, 6, 7], 'passageMode': 1, 'startDate': 420}

I'd suggest removing adminPwd, lockKey, noKeyPwd and aesKeyStr as I have above since those are potentially sensitive bits of data.

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

@HerveB you'll need to put the extension into debug mode and probably reload it.

The docs on how to do this are here: https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

Thanks, although I think replying via email may have dropped the data you attached, I only see 

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

Looks like the extension might be overwhelming the gateway, are all these locks attached to the same gateway?

I'll definitely add some error handling and I'll see if I can do something about fetching the lockedState less aggressively

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

@HerveB thanks for the logs, I've added some rate-limiting to the gateway access as well as improving the error handling. Please try v0.4.6, and let me know if the problem is fixed or not.

@jbergler jbergler reopened this Apr 23, 2023
@jbergler jbergler added the bug Something isn't working label Apr 23, 2023
@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

Hmm, that's a fairly cryptic error from the TTLock API.

Could you send me the full logs again please? I added extra info to the logs to help me understand how the parallel requests are executing. It might be that its just hitting the API too fast now that it's setting up multiple locks in parallel.

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

Thanks.

"what has changed" -> almost everything, I rewrote most of the internals of the extension to support exposing multiple entities.

If you could, would you also send me the logs from 0.3.x for me to compare.

@jbergler jbergler changed the title TTLock fails to load since 0.4.x TTLock fails to load with multiple locks (since 0.4.x) Apr 23, 2023
@jbergler
Copy link
Owner

In 0.4.3 I get "LockState state field required", there are no error logs
Originally posted by @stevearmitage in #1 (comment)

@stevenarmitage I suspect you're running into the same issue as was reported by @HerveB.
Can you please upgrade to 0.4.6, turn debug logging on per these instructions and then attach the logs here

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023 via email

@jbergler
Copy link
Owner

jbergler commented Apr 23, 2023

You can enable the debugging via your configuration.yaml file to log in debug mode before the integration is initialized.

logger:
  logs:
    custom_components.ttlock: debug

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023

I no longer have the ability to redownload version 0.3.x in HACS

@jbergler
Copy link
Owner

No worries, that log is actually pretty helpful.

I think I have a quick fix for now to keep going when we hit these errors from the API and I'll spend some time later in the week to solve the problem properly.

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023

Great. I appreciate the work you have done on this integration! Thanks!

@jbergler
Copy link
Owner

Hopefully v0.4.7 gets you past this problem for now. You'll probably see some of your locks not report a locked/unlocked status for the first 15 minutes after restarting home assistant.

@HerveB
Copy link
Author

HerveB commented Apr 23, 2023

0.4.7 seems to be working

@stevearmitage
Copy link

Screenshot_20230423_173135_Home Assistant
0.4.7 loaded ok and also found my second lock. I'll post details in the other thread. I'll test more on Tuesday

@ortwin20000
Copy link

I tried this integration with 0.4.8 and get an error after setting it up:
Setup erneut versuchen: 1 validation error for Lock autoLockTime field required (type=value_error.missing)

I use a gateway G2 with 2 locks. In the log i didn't found a callback url. i think it's because the validation of the locks failed.
The model number of both locks is C001C with NFC and Bluetooth.

@jbergler
Copy link
Owner

I tried this integration with 0.4.8 and get an error after setting it up: Setup erneut versuchen: 1 validation error for Lock autoLockTime field required (type=value_error.missing)

I use a gateway G2 with 2 locks. In the log i didn't found a callback url. i think it's because the validation of the locks failed. The model number of both locks is C001C with NFC and Bluetooth.

@ortwin20000 I'll need the debug logging to help with this. Could you please turn debug logging on for the integration and then open a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants