jbergler / hass-ttlock

Home Assistant integration for TTLock locks
57 stars 13 forks source link

[question] New lock not appearing in Home Assistant #102

Closed LanceMcCarthy closed 6 months ago

LanceMcCarthy commented 7 months ago

Describe the bug

I two locks being served by the gateway, both have Remote Unlock enabled, but only one lock has entities.

Looking at the diagnostics json, it's clear that the add-on only registered one of them:

image

I reloaded the Integration, to see if it will pull in fresh data from the TTLock API, no luck. Then I went back to the dev portal and double checked everything is good there, and it is:

image

I even deleted the Integration and re-added it, just incase it can only pull in the lock list on that first installation, but no luck there either.

To Reproduce

Steps to reproduce the behavior:

  1. Start with one lock, set everything up and ensure that is working as expected
  2. Now, add a new lock, and ensure all prerequisites are met (remote unlock, added to the gateway, etc)
  3. Go back to Home Assistant and reload the Integration (or even restart HA to hget a fresh start)
  4. Observe hass-ttlock doesn't detect the newly added lock in step 2

Expected behavior

All locks that have "Remote Unlock" feature enabled should be available in hass-ttlock.

Diagnostic info

config_entry-ttlock-28e776688fb089afc337d5a462be061d.json

jbergler commented 7 months ago

Thanks for grabbing the diagnostic info, can you please also collect the debug logs from the integration (enable debug logging, reload integration, disable debug logging)

LanceMcCarthy commented 7 months ago

I was looking at #70 but am not sure it is related. I didn't get a 2nd webhook, because after adding the 2nd lock, I reinstalled the Integration and have just one webhook.

LanceMcCarthy commented 7 months ago

@jbergler Got it, thanks for the steps. Here are the relevant entries from the reload:

2024-03-08 13:46:12.218 DEBUG (MainThread) [custom_components.ttlock.api] [fa93] Sending request to https://euapi.ttlock.com/v3/lock/list with args={'pageNo': 1, 'pageSize': 1000}

2024-03-08 13:46:12.966 DEBUG (MainThread) [custom_components.ttlock.api] [fa93] Received response: status=200: body={'list': [{'date': 1651534439000, 'lockAlias': 'Bedroom CR', 'groupId': 263436, 'electricQuantityUpdateDate': 1651534439000, 'lockMac': '***REDACTED***', 'featureValue': '644CD5F7', 'hasGateway': 0, 'wirelessKeypadFeatureValue': '0', 'lockName': 'H31_aabcca', 'specialValue': 1682757111, 'noKeyPwd': '***REDACTED***', 'passageMode': 2, 'timezoneRawOffset': -21600000, 'lockId': 5382206, 'electricQuantity': 100, 'groupName': 'Costa Rica', 'bindDate': 1651534439000, 'lockData': '***REDACTED***', 'keyboardPwdVersion': 4, 'lockVersion': {'showAdminKbpwdFlag': True, 'groupId': 10, 'protocolVersion': 3, 'protocolType': 5, 'orgId': 34, 'logoUrl': '', 'scene': 2}}, {'date': 1612993306000, 'lockAlias': 'Electronics Room', 'groupId': 263436, 'electricQuantityUpdateDate': 1709405905000, 'lockMac': '***REDACTED***', 'featureValue': '44CD5F7', 'hasGateway': 1, 'wirelessKeypadFeatureValue': '0', 'lockName': 'H31_cce40d', 'specialValue': 72144375, 'noKeyPwd': '***REDACTED***', 'passageMode': 2, 'timezoneRawOffset': -21600000, 'lockId': 2822080, 'electricQuantity': 100, 'groupName': 'Costa Rica', 'bindDate': 1612993306000, 'lockData': '***REDACTED***', 'keyboardPwdVersion': 4, 'lockVersion': {'showAdminKbpwdFlag': True, 'groupId': 10, 'protocolVersion': 3, 'protocolType': 5, 'orgId': 34, 'logoUrl': '', 'scene': 2}}], 'pageNo': 1, 'pageSize': 1000, 'pages': 1, 'total': 2}

2024-03-08 13:46:12.968 DEBUG (MainThread) [custom_components.ttlock.api] [312d] Sending request to https://euapi.ttlock.com/v3/lock/detail with args={'lockId': 2822080}

2024-03-08 13:46:13.169 DEBUG (MainThread) [custom_components.ttlock.api] [312d] Received response: status=200: body={'date': 1612993306000, 'lockAlias': 'Electronics Room', 'lockSound': 1, 'modelNum': 'SN246_PV53', 'lockMac': '***REDACTED***', 'privacyLock': 0, 'deletePwd': '', 'featureValue': '44CD5F7', 'adminPwd': '***REDACTED***', 'soundVolume': 5, 'hasGateway': 1, 'autoLockTime': 60, 'wirelessKeypadFeatureValue': '0', 'lockKey': '***REDACTED***', 'isFrozen': 2, 'lockName': 'H31_cce40d', 'resetButton': 0, 'firmwareRevision': '5.0.1.200320', 'tamperAlert': 0, 'specialValue': 72144375, 'displayPasscode': 0, 'noKeyPwd': '***REDACTED***', 'passageMode': 2, 'passageModeAutoUnlock': 2, 'timezoneRawOffset': -21600000, 'lockId': 2822080, 'electricQuantity': 100, 'lockFlagPos': 0, 'lockUpdateDate': 1698943206000, 'keyboardPwdVersion': 4, 'aesKeyStr': '***REDACTED***', 'hardwareRevision': '1.1', 'openDirection': 0, 'lockVersion': {'groupId': 10, 'protocolVersion': 3, 'protocolType': 5, 'orgId': 34, 'scene': 2}, 'sensitivity': -1}

2024-03-08 13:46:13.170 DEBUG (MainThread) [custom_components.ttlock.api] [8189] Sending request to https://euapi.ttlock.com/v3/lock/queryOpenState with args={'lockId': 2822080}
2024-03-08 13:46:14.792 DEBUG (MainThread) [custom_components.ttlock.api] [8189] Received response: status=200: body={'state': 0, 'sensorState': 0}
2024-03-08 13:46:14.793 DEBUG (MainThread) [custom_components.ttlock.api] [3a9b] Sending request to https://euapi.ttlock.com/v3/lock/getPassageModeConfig with args={'lockId': 2822080}
2024-03-08 13:46:15.001 DEBUG (MainThread) [custom_components.ttlock.api] [3a9b] Received response: status=200: body={'autoUnlock': 2, 'weekDays': [], 'passageMode': 2}
2024-03-08 13:46:15.002 DEBUG (MainThread) [custom_components.ttlock.coordinator] Finished fetching ttlock data in 2.034 seconds (success: True)
2024-03-08 13:46:15.003 INFO (MainThread) [custom_components.ttlock] Webhook registered at https://ha.***REDACTED***.com/api/webhook/7032***REDACTED***3ed0

It is interesting, the API is only sending json data for one lock. How can I get it to send hass-ttlock data for both locks?

jbergler commented 6 months ago

One of the locks has "hasGateway": 0 which is likely why we're excluding it.

This logic exists to prevent entities from being added that we can't poll for status or otherwise interact with.

If I remember correctly someone else had this issue and removed the lock, and re-added it to their TTLock account which fixed this.

LanceMcCarthy commented 6 months ago

Sorry for the delay, currently travelling. that sounds like valid rationale, and enough justification for me to consider this closed (hass-ttlock is working as intended).

I cant confirm if the detach and reattach solution will work for a couple months, but I will come back here and update thiis thread with the final result.