Skip to content

Improve validation of device automation config#26830

Closed
emontnemery wants to merge 5 commits into
home-assistant:devfrom
emontnemery:device_automation_config_validation
Closed

Improve validation of device automation config#26830
emontnemery wants to merge 5 commits into
home-assistant:devfrom
emontnemery:device_automation_config_validation

Conversation

@emontnemery
Copy link
Copy Markdown
Contributor

@emontnemery emontnemery commented Sep 22, 2019

Description:

Improve validation of device automation config.

Improve both when loading at startup, and when an automation is modified through the automation editor UI.

Split in three PRs: #26910, #27029, #27131,

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

Comment thread homeassistant/components/automation/device.py Outdated
automations = []
for _, p_config in config_per_platform(config, DOMAIN):
try:
p_validated = await async_validate_config_item(hass, p_config)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use asyncio.gather to run in parallel.

)


async def async_trigger(hass, config, action, automation_info):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am renaming this in #26871 to async_attach_trigger

Script(hass, cv.SCRIPT_SCHEMA(config)).run(variables, context)


async def async_validate_action_config(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be async_validate_script_config

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also could be used inside the script integration.

Comment thread homeassistant/config.py
_LOGGER.error("Unable to import %s: %s", domain, ex)
return None

if hasattr(component, "async_validate_config"):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the test for this?

@balloob
Copy link
Copy Markdown
Member

balloob commented Sep 24, 2019

Any PR related to device automation should be broken up into 3 PRs. One for triggers, conditions and actions all separately.

@lock lock Bot locked and limited conversation to collaborators Sep 26, 2019
@emontnemery emontnemery deleted the device_automation_config_validation branch October 3, 2019 16:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants