mirror of
https://github.com/home-assistant/core.git
synced 2026-09-03 18:24:49 -05:00
Set up condition and trigger helpers in check config script (#167589)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -31,7 +31,7 @@ from homeassistant.requirements import (
|
||||
async_get_integration_with_requirements,
|
||||
)
|
||||
|
||||
from . import config_validation as cv
|
||||
from . import condition, config_validation as cv, trigger
|
||||
from .typing import ConfigType
|
||||
|
||||
|
||||
@@ -93,6 +93,12 @@ async def async_check_ha_config_file( # noqa: C901
|
||||
result = HomeAssistantConfig()
|
||||
async_clear_install_history(hass)
|
||||
|
||||
# Set up condition and trigger helpers needed for config validation.
|
||||
if condition.CONDITIONS not in hass.data:
|
||||
await condition.async_setup(hass)
|
||||
if trigger.TRIGGERS not in hass.data:
|
||||
await trigger.async_setup(hass)
|
||||
|
||||
def _pack_error(
|
||||
hass: HomeAssistant,
|
||||
package: str,
|
||||
|
||||
@@ -15,6 +15,8 @@ from homeassistant.helpers.check_config import (
|
||||
HomeAssistantConfig,
|
||||
async_check_ha_config_file,
|
||||
)
|
||||
from homeassistant.helpers.condition import CONDITIONS
|
||||
from homeassistant.helpers.trigger import TRIGGERS
|
||||
from homeassistant.requirements import RequirementsNotFound
|
||||
|
||||
from tests.common import (
|
||||
@@ -493,6 +495,11 @@ async def test_missing_included_file(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_automation_config_platform(hass: HomeAssistant) -> None:
|
||||
"""Test automation async config."""
|
||||
# Remove keys pre-populated by the test fixture to simulate
|
||||
# the check_config script which doesn't run bootstrap.
|
||||
del hass.data[TRIGGERS]
|
||||
del hass.data[CONDITIONS]
|
||||
|
||||
files = {
|
||||
YAML_CONFIG_FILE: BASE_CONFIG
|
||||
+ """
|
||||
@@ -514,6 +521,9 @@ blueprint:
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: !input trigger_event
|
||||
condition:
|
||||
condition: template
|
||||
value_template: "{{ true }}"
|
||||
action:
|
||||
service: !input service_to_call
|
||||
""",
|
||||
|
||||
Reference in New Issue
Block a user