jbergler / hass-ttlock

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

My lock is not detected #57

Closed vsok01 closed 1 year ago

vsok01 commented 1 year ago

My lock is not detected by your integration. May be something wrong with integration settings on my side. Could you help, please? Here are my steps:

The lock is absent in integration... Here is a log:

 "integration_manifest": {
    "domain": "ttlock",
    "name": "TTLock",
    "after_dependencies": [
      "cloud"
    ],
    "codeowners": [
      "@jbergler"
    ],
    "config_flow": true,
    "dependencies": [
      "application_credentials",
      "persistent_notification",
      "webhook"
    ],
    "documentation": "https://github.com/jbergler/hass-ttlock",
    "homekit": {},
    "iot_class": "cloud_polling",
    "issue_tracker": "https://github.com/jbergler/hass-ttlock/issues",
    "requirements": [
      "pydantic"
    ],
    "ssdp": [],
    "version": "v0.5.2",
    "zeroconf": [],
    "is_built_in": false
  },
  "data": {
    "config_entry": {
      "entry_id": "53aeb651064760e25250313a84",
      "version": 1,
      "domain": "ttlock",
      "title": "Lock",
      "data": {
        "auth_implementation": "ttlock_fdedf0bee934eeead933dc4bf257",
        "token": "**REDACTED**",
        "webhook_id": "8dc3747e22d35567ce531ce52f89295c542c727ed47eda52bd404a"
      },
      "options": {},
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": null,
      "disabled_by": null
    },
    "locks": []
  }
vsok01 commented 1 year ago

Just one more detail: my lock has a built-in WiFi module, so it works without gateway.

jbergler commented 1 year ago

Hey @vsok01 this is likely the result of me filtering out locks without gateways to address another bug - I can try and revisit that but I'll need more info, can you put the integration into debug mode, reload it and share the logs please?

vsok01 commented 1 year ago

Thank you for quick response. Here are the logs:

2023-07-03 14:36:29.113 DEBUG (MainThread) [custom_components.ttlock.api] [96e2] Sending request to https://euapi.ttlock.com/v3/lock/list with args={'pageNo': 1, 'pageSize': 1000} 2023-07-03 14:36:29.611 DEBUG (MainThread) [custom_components.ttlock.api] [96e2] Received response: status=200: body={'list': [{'date': 1688230672000, 'specialValue': 1967977975, 'lockAlias': 'Door', 'noKeyPwd': 'XXXXXXX', 'electricQuantityUpdateDate': 1688230672000, 'lockMac': 'A2:BB:DD:9B:60:93', 'passageMode': 1, 'timezoneRawOffset': 10800000, 'lockId': 8597203, 'featureValue': '10C2F44754CF5F7', 'electricQuantity': 100, 'bindDate': 1688230672000, 'lockData': 'vBB7v23vYEsSddLY9nwxfkUNjw8bELL9qArEiajJusg/h/v1xINSenOUmRK/SqSImlwERbFwdSfBn63At7tNF2UUeRtBrFnciyduH2EJy2i5j01E5xUV0GuPKxVUAceOoaiXhiXDrQsDj0yxWZ8uyOqnh+HqB4c2kGDaCjKIldTM+PEKCbs6FlFu3PbUkTLo6BFWwaC9ElVYQEFy+llodStgC2Wp/mthereqBcpcSfn/tZSXVwGXVTM3YemnbCWqklEiRG+Cl8v87DA1I3md1rEeE9OigFI6YfUppBedgGlkLjiIGmTgpXOW+C49jomzOBd1phtsR3UoxvpSNwobP+BWMtqZ7cofW1JfIFdierDXw+mRWxyN1+seJbDL5GTwDyxlNpCGJxfKi/BRlfGwRdjhtD7Z9EsOnp2t33ThtTHShG4E4kroIyQI5trxJE8fNTBeqyjrdfncgfQ7N5S9u6e/V6cY527QAHkXN+2NPDorXiWxnoioKusJ/R9yVUn6+A+1dlrgxvcaMYOAhYWOqkW9Bps9iWxFah2IyjjSjd1GUfP5ZeFFx1EXnUW7YODzDcxQwSIddx6MuLzE3sNsqo9VTIUShE+brI52/Akvw0ZIXHVzP7x42eJaqe1682kEbpGCZe5yVxKtH1dwsy7wvYUNQXZG0s3i+swrOAGZjPXIHTtPLgbkwjC0R1L+gErUBMhqQ43gvJiA1bXMPAELYELhtZHMUEvliGbhJzHUFT4fUKMVLvcmy8JKqaCzVxkUJ2uC/tMEA6Q9ihFYQrljgqK73Jpgkw==', 'hasGateway': 0, 'keyboardPwdVersion': 4, 'wirelessKeypadFeatureValue': '0', 'lockVersion': {'showAdminKbpwdFlag': True, 'groupId': 1, 'protocolVersion': 3, 'protocolType': 5, 'orgId': 1, 'logoUrl': '', 'scene': 2}, 'lockName': 'W301_93609a'}], 'pageNo': 1, 'pageSize': 1000, 'pages': 1, 'total': 1} 2023-07-03 14:36:29.613 INFO (MainThread) [custom_components.ttlock] Webhook registered at http://192.168.0.22:8123/api/webhook/6968d7e5bf793f81e4c4166d4313514442419f72e26289d0f460eeb4c696b886

vsok01 commented 1 year ago

You are right. I've removed your filter (if lock["hasGateway"] != 0) and now all works fine.

jbergler commented 1 year ago

I don't have any of these locks to test, so I don't know if the web hooks have the same format, or what other differences need to be taken into account. The API as a whole is very inconsistent even across similar locks the message schemas seem to have random differences.

I added the hasGateway check to work around issues where locks that need a gateway, but weren't connected to one were causing random failures downstream, so I'd want to try and figure out how to tell wifi locks apart from ble ones.

That probably requires parsing the featureValue': '10C2F44754CF5F7' field, but I don't have the time at the moment to implement and test that. If you wanted to take a crack at it, I'd be happy to look at it, otherwise I'll leave this sitting here until I have some time.

adarshk23 commented 1 year ago

Are you providing support for Homekit via home assistant? My locks are working perfectly on home assistant but they are appearing on the homekit (via. HA).

jbergler commented 1 year ago

From Home Assistants perspective they're just like any other lock so they'll be shared with HomeKit based on your config

adarshk23 commented 1 year ago

Precisely right but that’s not happening.

vsok01 commented 1 year ago

jbergler Webhook works fine for my lock. Could you post here an example (response) for ble lock without gateway? May be I could help you to set up a new filter...

adarshk23 commented 1 year ago

It’s working. The issue is, if I add it as a device using bridge as hub on HA, it doesn’t show up. If I add a bridge as an accessory, it works.

jbergler commented 1 year ago

@adarshk23 Isn't that expected? https://www.home-assistant.io/integrations/homekit/#accessory-mode

@vsok01 I don't have examples handy, but there are docs for the featureValue field which I think might be the key to this.

adarshk23 commented 1 year ago

My bad. I wasn’t aware of it. Thanks mate for your help.

vsok01 commented 1 year ago

What about Mac address? Is this present for ble lock? (lockMac value)

jbergler commented 1 year ago

@vsok01 I'm not at home at the moment, so I can't easily test the PR I put together, would you be able to install it and see if it works as expected?

vsok01 commented 1 year ago

I do apologize for a stupid question, but how to install it? Should I reinstall your ttlock integration, or I need to download and replace 5 changed files? I'm not familiar with github enough.

jbergler commented 1 year ago

It's not a stupid question, hacs doesn't make this easy. The best way I know of is just to manually put the ttlock directory in place (or just the 3 files in question, you can ignore the tests)

vsok01 commented 1 year ago

Thank you for the explanations. I've tested it. All works correctly.

jbergler commented 1 year ago

Wonderful, thanks for your help. I'm going to leave this unreleased for a little bit so I have a chance to do a bit of testing when I get home at the end of the week but it will be in the next release.

vsok01 commented 1 year ago

Thank you very much.