Skip to content

Commit 57c3a5c

Browse files
authored
Move imports to top level in websocket_api commands (home-assistant#156004)
1 parent 07c4c58 commit 57c3a5c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

homeassistant/components/websocket_api/commands.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141
template,
4242
)
4343
from homeassistant.helpers.condition import (
44+
async_from_config as async_condition_from_config,
4445
async_get_all_descriptions as async_get_all_condition_descriptions,
4546
async_subscribe_platform_events as async_subscribe_condition_platform_events,
47+
async_validate_condition_config,
48+
async_validate_conditions_config,
4649
)
4750
from homeassistant.helpers.dispatcher import async_dispatcher_connect
4851
from homeassistant.helpers.entityfilter import (
@@ -66,7 +69,9 @@
6669
)
6770
from homeassistant.helpers.trigger import (
6871
async_get_all_descriptions as async_get_all_trigger_descriptions,
72+
async_initialize_triggers,
6973
async_subscribe_platform_events as async_subscribe_trigger_platform_events,
74+
async_validate_trigger_config,
7075
)
7176
from homeassistant.loader import (
7277
IntegrationNotFound,
@@ -885,10 +890,7 @@ async def handle_subscribe_trigger(
885890
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
886891
) -> None:
887892
"""Handle subscribe trigger command."""
888-
# Circular dep
889-
from homeassistant.helpers import trigger # noqa: PLC0415
890-
891-
trigger_config = await trigger.async_validate_trigger_config(hass, msg["trigger"])
893+
trigger_config = await async_validate_trigger_config(hass, msg["trigger"])
892894

893895
@callback
894896
def forward_triggers(
@@ -905,7 +907,7 @@ def forward_triggers(
905907
)
906908

907909
connection.subscriptions[msg["id"]] = (
908-
await trigger.async_initialize_triggers(
910+
await async_initialize_triggers(
909911
hass,
910912
trigger_config,
911913
forward_triggers,
@@ -935,13 +937,10 @@ async def handle_test_condition(
935937
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
936938
) -> None:
937939
"""Handle test condition command."""
938-
# Circular dep
939-
from homeassistant.helpers import condition # noqa: PLC0415
940-
941940
# Do static + dynamic validation of the condition
942-
config = await condition.async_validate_condition_config(hass, msg["condition"])
941+
config = await async_validate_condition_config(hass, msg["condition"])
943942
# Test the condition
944-
check_condition = await condition.async_from_config(hass, config)
943+
check_condition = await async_condition_from_config(hass, config)
945944
connection.send_result(
946945
msg["id"], {"result": check_condition(hass, msg.get("variables"))}
947946
)
@@ -1028,16 +1027,16 @@ async def handle_validate_config(
10281027
) -> None:
10291028
"""Handle validate config command."""
10301029
# Circular dep
1031-
from homeassistant.helpers import condition, script, trigger # noqa: PLC0415
1030+
from homeassistant.helpers import script # noqa: PLC0415
10321031

10331032
result = {}
10341033

10351034
for key, schema, validator in (
1036-
("triggers", cv.TRIGGER_SCHEMA, trigger.async_validate_trigger_config),
1035+
("triggers", cv.TRIGGER_SCHEMA, async_validate_trigger_config),
10371036
(
10381037
"conditions",
10391038
cv.CONDITIONS_SCHEMA,
1040-
condition.async_validate_conditions_config,
1039+
async_validate_conditions_config,
10411040
),
10421041
("actions", cv.SCRIPT_SCHEMA, script.async_validate_actions_config),
10431042
):

0 commit comments

Comments
 (0)