-
-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Add supported_features to cover component #6082
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,15 @@ | |
| 'garage', # Garage door control | ||
| ] | ||
|
|
||
| SUPPORT_OPEN = 1 | ||
| SUPPORT_CLOSE = 2 | ||
| SUPPORT_SET_POSITION = 4 | ||
| SUPPORT_STOP = 8 | ||
| SUPPORT_OPEN_TILT = 16 | ||
| SUPPORT_CLOSE_TILT = 32 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, can be merged with open tilt ? |
||
| SUPPORT_STOP_TILT = 64 | ||
| SUPPORT_SET_TILT_POSITION = 128 | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| ATTR_CURRENT_POSITION = 'current_position' | ||
|
|
@@ -226,6 +235,21 @@ def state_attributes(self): | |
|
|
||
| return data | ||
|
|
||
| @property | ||
| def supported_features(self): | ||
| """Flag supported features.""" | ||
| supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | ||
|
|
||
| if self.current_cover_position is not None: | ||
| supported_features |= SUPPORT_SET_POSITION | ||
|
|
||
| if self.current_cover_tilt_position is not None: | ||
| supported_features |= ( | ||
| SUPPORT_OPEN_TILT | SUPPORT_CLOSE_TILT | SUPPORT_STOP_TILT | | ||
| SUPPORT_SET_TILT_POSITION) | ||
|
|
||
| return supported_features | ||
|
|
||
| @property | ||
| def is_closed(self): | ||
| """Return if the cover is closed or not.""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why would we separate open and close? I don't think there will ever be a use case that has no open and close.
Even if a device does not have open and close specific but has set position, they could mimick open and close by setting position to fully open or fully closed. So I think that we can remove those.
Uh oh!
There was an error while loading. Please reload this page.
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.
I do think that we need to keep the open/close separate from the set position, because although set position can emulate open/close, the opposite isn't true. It's very possible that there is a device that tracks position, but only has binary open/close commands.
As far as open/close being separate, I don't have any example of a device, but it certainly could be possible. I wouldn't have predicted a media player that does support next track but doesn't support previous, and then Pandora came around.
What about a compromise, where we have one flag
SUPPORT_OPENCLOSE = 3, that way they could be broken out in the future if necessary, but don't clutter the current code? It's not necessary for my case, but I'd like to leave options open for the future.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.
Okay, you convinced me. I'm fine with it.