-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
Clarify cover toggle logic; prevent opening when already open #107920
Clarify cover toggle logic; prevent opening when already open #107920
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
not stale, awaits review |
34fd226
to
1f8b3c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thanks @vexofp 👍
I'd like a second opinion before merging though.
Thanks! |
Proposed change
This is a follow-on to #106848. During that review, it became clear that the logic by which
CoverEntity.toggle()
chooses which action to take next was confusing, and could possibly misbehave in some unusual edge cases.This PR refactors
_get_toggle_function()
and adds comments to improve clarity. All cases covered by the existing tests continue to work the same. It also adds a new test case for toggling after the unusual state sequence:Such a sequence of states might occur if the cover was moved manually or due to dropped communication. Previously in this case,
toggle()
would map toopen_cover()
, because the most recent transitional state was "closing" (despite knowing that we are already fully open). The refactored logic correctly maps this case toclose_cover()
.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: