Improve validation of device trigger config#26910
Merged
emontnemery merged 7 commits intoSep 27, 2019
Merged
Conversation
balloob
reviewed
Sep 25, 2019
| return {CONF_ID: self._id} | ||
|
|
||
|
|
||
| async def async_validate_config_item(hass, config, full_config): |
Member
There was a problem hiding this comment.
Let's move this into a new file config.py
balloob
reviewed
Sep 25, 2019
| return config | ||
|
|
||
|
|
||
| async def async_validate_config(hass, config): |
balloob
reviewed
Sep 25, 2019
|
|
||
| # mypy: allow-untyped-defs, no-check-untyped-defs | ||
|
|
||
| TRIGGER_SCHEMA = vol.Schema( |
Member
There was a problem hiding this comment.
We should expand the TRIGGER_BASE_SCHEMA from device_automation and add extra=vol.ALLOW_EXTRA
Member
There was a problem hiding this comment.
Suggested change
| TRIGGER_SCHEMA = vol.Schema( | |
| TRIGGER_SCHEMA = device_automation.TRIGGER_BASE_SCHEMA.extend( |
balloob
reviewed
Sep 25, 2019
|
|
||
| async def async_validate_trigger_config(hass, config): | ||
| """Validate config.""" | ||
| return await device_automation.async_validate_trigger_config(hass, config) |
Member
There was a problem hiding this comment.
Let's inline this function here.
balloob
reviewed
Sep 25, 2019
| # Check if the integration has a custom config validator | ||
| config_validator = None | ||
| try: | ||
| config_validator = integration.get_platform("config") |
Member
There was a problem hiding this comment.
Note, we should add dev docs for this right away.
balloob
approved these changes
Sep 27, 2019
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description:
Improve validation of device trigger config.
This only includes trigger part from #26830
Improve both when loading at startup, and when an automation is modified through the automation editor UI.
Checklist:
tox. Your PR cannot be merged unless tests passIf the code does not interact with devices: