-
-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Update vizio component to prepare for config flow and zeroconf support #30522
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 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
26bf3fc
move constants, move schema validation to init, prepare for zeroconf/…
raman325 bf91c01
update requirements_all and make setup validation more pythonic
raman325 f411f77
mistake in refactor
raman325 61ede0f
un-revert change from previous PR
raman325 f85074e
rename schema var
raman325 0f730a2
update .coveragerc, move validate_auth to __init__, only attempt to g…
raman325 b9797d5
reinstate validate_setup but change logic to use new connection test …
raman325 5b728bd
fix schema validation
raman325 8aeafcb
simplify string empty check logic
raman325 d8bb1a6
missed commit
raman325 8d1c1cb
Merge branch 'dev' into vizio_zeroconf
raman325 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
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 |
|---|---|---|
| @@ -1 +1,43 @@ | ||
| """The vizio component.""" | ||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.const import ( | ||
| CONF_ACCESS_TOKEN, | ||
| CONF_DEVICE_CLASS, | ||
| CONF_HOST, | ||
| CONF_NAME, | ||
| ) | ||
| from homeassistant.helpers import config_validation as cv | ||
|
|
||
| from .const import ( | ||
| CONF_SUPPRESS_WARNING, | ||
| CONF_VOLUME_STEP, | ||
| DEFAULT_DEVICE_CLASS, | ||
| DEFAULT_NAME, | ||
| DEFAULT_VOLUME_STEP, | ||
| ) | ||
|
|
||
|
|
||
| def validate_auth(config): | ||
| """Validate presence of CONF_ACCESS_TOKEN when CONF_DEVICE_CLASS=tv.""" | ||
| token = config.get(CONF_ACCESS_TOKEN) | ||
| if config[CONF_DEVICE_CLASS] == "tv" and (token is None or token == ""): | ||
| raise vol.Invalid( | ||
| f"When '{CONF_DEVICE_CLASS}' is 'tv' then '{CONF_ACCESS_TOKEN}' is required.", | ||
| path=[CONF_ACCESS_TOKEN], | ||
| ) | ||
| return config | ||
|
|
||
|
|
||
| VIZIO_SCHEMA = { | ||
| vol.Required(CONF_HOST): cv.string, | ||
| vol.Optional(CONF_ACCESS_TOKEN): cv.string, | ||
| vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, | ||
| vol.Optional(CONF_SUPPRESS_WARNING, default=False): cv.boolean, | ||
| vol.Optional(CONF_DEVICE_CLASS, default=DEFAULT_DEVICE_CLASS): vol.All( | ||
| cv.string, vol.Lower, vol.In(["tv", "soundbar"]) | ||
| ), | ||
| vol.Optional(CONF_VOLUME_STEP, default=DEFAULT_VOLUME_STEP): vol.All( | ||
| vol.Coerce(int), vol.Range(min=1, max=10) | ||
| ), | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| """Constants used by vizio component.""" | ||
|
|
||
| CONF_SUPPRESS_WARNING = "suppress_warning" | ||
| CONF_VOLUME_STEP = "volume_step" | ||
|
|
||
| DEFAULT_NAME = "Vizio SmartCast" | ||
| DEFAULT_VOLUME_STEP = 1 | ||
| DEFAULT_DEVICE_CLASS = "tv" | ||
| DEVICE_ID = "pyvizio" | ||
| DEVICE_NAME = "Python Vizio" | ||
|
|
||
| DOMAIN = "vizio" | ||
|
|
||
| ICON = {"tv": "mdi:television", "soundbar": "mdi:speaker"} |
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.
Uh oh!
There was an error while loading. Please reload this page.