core icon indicating copy to clipboard operation
core copied to clipboard

Allow Switchbot users to force nightlatch

Open mjoops opened this issue 1 year ago • 2 comments

Breaking change

Proposed change

Adds boolean option to force lock to operate as if night latch was detected. This is easiest way I found around the broken night latch detection in pySwitchbot library for the new Lock Pro. It will be easily removable if someone found way to correctly detect night latch.

Type of change

  • [ ] Dependency upgrade
  • [x] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [ ] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

We currently don't know how to fix night latch detection on Lock Pro. So i decided to crate this PR which simply allow users force night latch operation (enables action OPEN). Links for discussions around this issue: https://github.com/Danielhiversen/pySwitchbot/pull/245 https://github.com/Danielhiversen/pySwitchbot/issues/233

  • This PR fixes or closes issue: fixes #123899, #121165
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [ ] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [ ] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

mjoops avatar Aug 20 '24 19:08 mjoops

Hey there @danielhiversen, @renierm26, @murtas, @eloston, @dsypniewski, mind taking a look at this pull request as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot] avatar Aug 20 '24 19:08 home-assistant[bot]

I made the new option available only for lock pro entries. I can't test this this with real lock pro - don't own one, but i tested it with the old one and it works fine.

mjoops avatar Aug 22 '24 20:08 mjoops

the broken night latch detection in pySwitchbot library for the new Lock Pro

Can you elaborate on this? What is needed to fix this in the first place?

joostlek avatar Sep 03 '24 12:09 joostlek

the broken night latch detection in pySwitchbot library for the new Lock Pro

Can you elaborate on this? What is needed to fix this in the first place?

There is a difference between the old lock, which have one bit in ADV indicating lock is configured with nightlatch functionality. This is no longer the case in the new lock pro model, we firstly believed the bit is still there but after some time we discoverer is no longer there. For now detection for this feature on lock pro was disabled, but the lock can support open call. This integration just need to know if the lock is configured with this feature enabled. https://github.com/home-assistant/core/pull/125113 https://github.com/Danielhiversen/pySwitchbot/pull/247

Because there is practically no documentation for switchbot ble api there is a need for reverse engineer new way to detect if lock is configured to support this.

mjoops avatar Sep 03 '24 13:09 mjoops

As a owner of a SwitchBot Lock Pro and that manually applied this PR, I can confirm that it works fine and is very much needed. Without it, there is no way to unlock the door without opening it, or to open an unlocked door with the deadbolt unlocked when the lock is in "night latch" mode.

stephanedupont avatar Sep 03 '24 13:09 stephanedupont

Isn't it possible to set it always to True for those models?

joostlek avatar Sep 03 '24 13:09 joostlek

Isn't it possible to set it always to True for those models?

No, because then users which are not using this feature will need to unlock their doors with open call instead of unlock, and the unlock call will cause lock to partially unlock and then lock back.

mjoops avatar Sep 03 '24 13:09 mjoops

Would be really great if this makes it into .9.0 together with the updated pyswitchbot version.

tbrasser avatar Sep 04 '24 12:09 tbrasser