-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
Add invert option to switch_as_x #107535
Merged
Merged
Add invert option to switch_as_x #107535
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dc6c24f
Add invert option to switch_as_x
emontnemery d450d43
Store invert flag in entity options
emontnemery 4cf8d5e
Add options flow
emontnemery d1aaa44
Update strings
emontnemery 8f83215
Add tests
emontnemery 8f56e78
Address review comment
emontnemery b5099dc
Update homeassistant/components/switch_as_x/strings.json
emontnemery 4f0386f
Address review comments
emontnemery 6032e23
Inline get_suggested which was only used once in tests
emontnemery 2ebf8d5
Address review comments
emontnemery 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 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 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 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 |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
DOMAIN: Final = "switch_as_x" | ||
|
||
CONF_INVERT: Final = "invert" | ||
CONF_TARGET_DOMAIN: Final = "target_domain" |
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1 +1,39 @@ | ||
"""The tests for Switch as X platforms.""" | ||
|
||
from homeassistant.const import ( | ||
STATE_CLOSED, | ||
STATE_LOCKED, | ||
STATE_OFF, | ||
STATE_ON, | ||
STATE_OPEN, | ||
STATE_UNLOCKED, | ||
Platform, | ||
) | ||
|
||
PLATFORMS_TO_TEST = ( | ||
Platform.COVER, | ||
Platform.FAN, | ||
Platform.LIGHT, | ||
Platform.LOCK, | ||
Platform.SIREN, | ||
Platform.VALVE, | ||
) | ||
|
||
STATE_MAP = { | ||
False: { | ||
Platform.COVER: {STATE_ON: STATE_OPEN, STATE_OFF: STATE_CLOSED}, | ||
Platform.FAN: {STATE_ON: STATE_ON, STATE_OFF: STATE_OFF}, | ||
Platform.LIGHT: {STATE_ON: STATE_ON, STATE_OFF: STATE_OFF}, | ||
Platform.LOCK: {STATE_ON: STATE_UNLOCKED, STATE_OFF: STATE_LOCKED}, | ||
Platform.SIREN: {STATE_ON: STATE_ON, STATE_OFF: STATE_OFF}, | ||
Platform.VALVE: {STATE_ON: STATE_OPEN, STATE_OFF: STATE_CLOSED}, | ||
}, | ||
True: { | ||
Platform.COVER: {STATE_ON: STATE_CLOSED, STATE_OFF: STATE_OPEN}, | ||
Platform.FAN: {STATE_ON: STATE_ON, STATE_OFF: STATE_OFF}, | ||
Platform.LIGHT: {STATE_ON: STATE_ON, STATE_OFF: STATE_OFF}, | ||
Platform.LOCK: {STATE_ON: STATE_LOCKED, STATE_OFF: STATE_UNLOCKED}, | ||
Platform.SIREN: {STATE_ON: STATE_ON, STATE_OFF: STATE_OFF}, | ||
Platform.VALVE: {STATE_ON: STATE_CLOSED, STATE_OFF: STATE_OPEN}, | ||
}, | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
This means that if someone has upgraded and configured a
switch_as_x
withinvert=True
and then downgrades it will change the option for that entry toinvert=False
hence changing how that entity works (even if the user then upgrade again).It should probably only set this option if it's not already there?