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

Allow Switchbot users to force nightlatch #124326

Merged

Conversation

Michal4K
Copy link
Contributor

@Michal4K Michal4K commented Aug 20, 2024

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
  • 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:
sblibs/pySwitchbot#245
sblibs/pySwitchbot#233

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • 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:

@home-assistant
Copy link

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.

@Michal4K Michal4K changed the title Switchbot allow force nightlatch Switchbot - allow users to force nightlatch Aug 21, 2024
@Michal4K
Copy link
Contributor Author

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.

@Michal4K Michal4K marked this pull request as draft August 22, 2024 20:48
@MartinHjelmare MartinHjelmare changed the title Switchbot - allow users to force nightlatch Allow Switchbot users to force nightlatch Aug 24, 2024
@Michal4K Michal4K force-pushed the switchbot-configurable-nightlatch branch from be85e29 to bbbc8bf Compare September 2, 2024 22:38
@Michal4K Michal4K marked this pull request as ready for review September 2, 2024 22:42
@joostlek
Copy link
Member

joostlek commented Sep 3, 2024

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?

@Michal4K
Copy link
Contributor Author

Michal4K commented Sep 3, 2024

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.
#125113
sblibs/pySwitchbot#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.

@Michal4K Michal4K force-pushed the switchbot-configurable-nightlatch branch from bbbc8bf to 454827a Compare September 3, 2024 13:01
@stephanedupont
Copy link

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.

@joostlek
Copy link
Member

joostlek commented Sep 3, 2024

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

@Michal4K
Copy link
Contributor Author

Michal4K commented Sep 3, 2024

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.

@tbrasser
Copy link

tbrasser commented Sep 4, 2024

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

@joostlek joostlek merged commit 5c35ccb into home-assistant:dev Sep 4, 2024
27 of 28 checks passed
iloveicedgreentea pushed a commit to iloveicedgreentea/core that referenced this pull request Sep 4, 2024
* Add option to force nightlatch operation mode

* Fix format

* Make the new option available only for lock pro entry

* use senor_type instead of switchbot model + tests

* Update homeassistant/components/switchbot/lock.py

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lock Pro „open door“ gone
5 participants