diff --git a/homeassistant/components/webostv/__init__.py b/homeassistant/components/webostv/__init__.py index 32161e6bad6..8b023990590 100644 --- a/homeassistant/components/webostv/__init__.py +++ b/homeassistant/components/webostv/__init__.py @@ -10,7 +10,6 @@ from aiowebostv import WebOsClient, WebOsTvPairError import voluptuous as vol from homeassistant.components import notify as hass_notify -from homeassistant.components.automation import AutomationActionType from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_COMMAND, @@ -30,6 +29,7 @@ from homeassistant.core import ( ) from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.dispatcher import async_dispatcher_send +from homeassistant.helpers.trigger import TriggerActionType from homeassistant.helpers.typing import ConfigType from .const import ( @@ -181,7 +181,7 @@ class PluggableAction: @callback def async_attach( - self, action: AutomationActionType, variables: dict[str, Any] + self, action: TriggerActionType, variables: dict[str, Any] ) -> Callable[[], None]: """Attach a device trigger for turn on.""" diff --git a/homeassistant/components/webostv/device_trigger.py b/homeassistant/components/webostv/device_trigger.py index 9ce49bbe79e..859accc86e6 100644 --- a/homeassistant/components/webostv/device_trigger.py +++ b/homeassistant/components/webostv/device_trigger.py @@ -3,10 +3,6 @@ from __future__ import annotations import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, @@ -14,6 +10,7 @@ from homeassistant.components.device_automation.exceptions import ( from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.exceptions import HomeAssistantError +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import trigger @@ -75,8 +72,8 @@ async def async_get_triggers( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Attach a trigger.""" if (trigger_type := config[CONF_TYPE]) == TURN_ON_PLATFORM_TYPE: @@ -88,7 +85,7 @@ async def async_attach_trigger( hass, trigger_config ) return await trigger.async_attach_trigger( - hass, trigger_config, action, automation_info + hass, trigger_config, action, trigger_info ) raise HomeAssistantError(f"Unhandled trigger type {trigger_type}") diff --git a/homeassistant/components/webostv/trigger.py b/homeassistant/components/webostv/trigger.py index 1ad7058e1de..5441917cc31 100644 --- a/homeassistant/components/webostv/trigger.py +++ b/homeassistant/components/webostv/trigger.py @@ -3,12 +3,9 @@ from __future__ import annotations from typing import cast -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.const import CONF_PLATFORM from homeassistant.core import CALLBACK_TYPE, HomeAssistant +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .triggers import TriggersPlatformModule, turn_on @@ -39,8 +36,8 @@ async def async_validate_trigger_config( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Attach trigger of specified platform.""" platform = _get_trigger_platform(config) @@ -48,6 +45,6 @@ async def async_attach_trigger( return cast( CALLBACK_TYPE, await getattr(platform, "async_attach_trigger")( - hass, config, action, automation_info + hass, config, action, trigger_info ), ) diff --git a/homeassistant/components/webostv/triggers/turn_on.py b/homeassistant/components/webostv/triggers/turn_on.py index 71949ce58ce..806b0b4b964 100644 --- a/homeassistant/components/webostv/triggers/turn_on.py +++ b/homeassistant/components/webostv/triggers/turn_on.py @@ -3,13 +3,10 @@ from __future__ import annotations import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.const import ATTR_DEVICE_ID, ATTR_ENTITY_ID, CONF_PLATFORM from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from ..const import DOMAIN @@ -39,8 +36,8 @@ TRIGGER_SCHEMA = vol.All( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, *, platform_type: str = PLATFORM_TYPE, ) -> CALLBACK_TYPE | None: @@ -57,7 +54,7 @@ async def async_attach_trigger( } ) - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] unsubs = [] diff --git a/homeassistant/components/wemo/device_trigger.py b/homeassistant/components/wemo/device_trigger.py index 973a3358b1b..077c32fb1ad 100644 --- a/homeassistant/components/wemo/device_trigger.py +++ b/homeassistant/components/wemo/device_trigger.py @@ -4,14 +4,11 @@ from __future__ import annotations from pywemo.subscribe import EVENT_TYPE_LONG_PRESS import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.homeassistant.triggers import event as event_trigger from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE from homeassistant.core import CALLBACK_TYPE, HomeAssistant +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .const import DOMAIN as WEMO_DOMAIN, WEMO_SUBSCRIPTION_EVENT @@ -57,8 +54,8 @@ async def async_get_triggers( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Attach a trigger.""" event_config = event_trigger.TRIGGER_SCHEMA( @@ -72,5 +69,5 @@ async def async_attach_trigger( } ) return await event_trigger.async_attach_trigger( - hass, event_config, action, automation_info, platform_type="device" + hass, event_config, action, trigger_info, platform_type="device" ) diff --git a/homeassistant/components/zha/device_trigger.py b/homeassistant/components/zha/device_trigger.py index 4ad8eccea1d..94b94b89e40 100644 --- a/homeassistant/components/zha/device_trigger.py +++ b/homeassistant/components/zha/device_trigger.py @@ -2,10 +2,6 @@ import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, @@ -14,6 +10,7 @@ from homeassistant.components.homeassistant.triggers import event as event_trigg from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.exceptions import HomeAssistantError, IntegrationError +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import DOMAIN as ZHA_DOMAIN @@ -54,8 +51,8 @@ async def async_validate_trigger_config( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" trigger_key: tuple[str, str] = (config[CONF_TYPE], config[CONF_SUBTYPE]) @@ -79,7 +76,7 @@ async def async_attach_trigger( event_config = event_trigger.TRIGGER_SCHEMA(event_config) return await event_trigger.async_attach_trigger( - hass, event_config, action, automation_info, platform_type="device" + hass, event_config, action, trigger_info, platform_type="device" ) diff --git a/homeassistant/components/zwave_js/device_trigger.py b/homeassistant/components/zwave_js/device_trigger.py index dfca2eb4b27..76a7f134d17 100644 --- a/homeassistant/components/zwave_js/device_trigger.py +++ b/homeassistant/components/zwave_js/device_trigger.py @@ -6,10 +6,6 @@ from typing import Any import voluptuous as vol from zwave_js_server.const import CommandClass -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, @@ -29,6 +25,7 @@ from homeassistant.helpers import ( device_registry, entity_registry, ) +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import trigger @@ -366,8 +363,8 @@ async def async_get_triggers( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Attach a trigger.""" trigger_type = config[CONF_TYPE] @@ -411,7 +408,7 @@ async def async_attach_trigger( event_config = event.TRIGGER_SCHEMA(event_config) return await event.async_attach_trigger( - hass, event_config, action, automation_info, platform_type="device" + hass, event_config, action, trigger_info, platform_type="device" ) if trigger_platform == "state": @@ -427,7 +424,7 @@ async def async_attach_trigger( state_config = await state.async_validate_trigger_config(hass, state_config) return await state.async_attach_trigger( - hass, state_config, action, automation_info, platform_type="device" + hass, state_config, action, trigger_info, platform_type="device" ) if trigger_platform == VALUE_UPDATED_PLATFORM_TYPE: @@ -451,7 +448,7 @@ async def async_attach_trigger( hass, zwave_js_config ) return await trigger.async_attach_trigger( - hass, zwave_js_config, action, automation_info + hass, zwave_js_config, action, trigger_info ) raise HomeAssistantError(f"Unhandled trigger type {trigger_type}") diff --git a/homeassistant/components/zwave_js/trigger.py b/homeassistant/components/zwave_js/trigger.py index 07f89388e67..d1751dc4f4f 100644 --- a/homeassistant/components/zwave_js/trigger.py +++ b/homeassistant/components/zwave_js/trigger.py @@ -4,12 +4,9 @@ from __future__ import annotations from types import ModuleType from typing import cast -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.const import CONF_PLATFORM from homeassistant.core import CALLBACK_TYPE, HomeAssistant +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .triggers import event, value_updated @@ -45,8 +42,8 @@ async def async_validate_trigger_config( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Attach trigger of specified platform.""" platform = _get_trigger_platform(config) @@ -54,6 +51,6 @@ async def async_attach_trigger( return cast( CALLBACK_TYPE, await getattr(platform, "async_attach_trigger")( - hass, config, action, automation_info + hass, config, action, trigger_info ), ) diff --git a/homeassistant/components/zwave_js/triggers/event.py b/homeassistant/components/zwave_js/triggers/event.py index 784ae74777b..eecd685cc1b 100644 --- a/homeassistant/components/zwave_js/triggers/event.py +++ b/homeassistant/components/zwave_js/triggers/event.py @@ -10,10 +10,6 @@ from zwave_js_server.model.controller import CONTROLLER_EVENT_MODEL_MAP from zwave_js_server.model.driver import DRIVER_EVENT_MODEL_MAP from zwave_js_server.model.node import NODE_EVENT_MODEL_MAP -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.zwave_js.const import ( ATTR_CONFIG_ENTRY_ID, ATTR_EVENT, @@ -32,6 +28,7 @@ from homeassistant.components.zwave_js.helpers import ( from homeassistant.const import ATTR_DEVICE_ID, ATTR_ENTITY_ID, CONF_PLATFORM from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback from homeassistant.helpers import config_validation as cv, device_registry as dr +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .helpers import async_bypass_dynamic_config_validation @@ -136,8 +133,8 @@ async def async_validate_trigger_config( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, *, platform_type: str = PLATFORM_TYPE, ) -> CALLBACK_TYPE: @@ -156,7 +153,7 @@ async def async_attach_trigger( unsubs = [] job = HassJob(action) - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] @callback def async_on_event(event_data: dict, device: dr.DeviceEntry | None = None) -> None: diff --git a/homeassistant/components/zwave_js/triggers/value_updated.py b/homeassistant/components/zwave_js/triggers/value_updated.py index 29b4b4d06d6..6a94ab0577b 100644 --- a/homeassistant/components/zwave_js/triggers/value_updated.py +++ b/homeassistant/components/zwave_js/triggers/value_updated.py @@ -7,10 +7,6 @@ import voluptuous as vol from zwave_js_server.const import CommandClass from zwave_js_server.model.value import Value, get_value_id -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.zwave_js.config_validation import VALUE_SCHEMA from homeassistant.components.zwave_js.const import ( ATTR_COMMAND_CLASS, @@ -34,6 +30,7 @@ from homeassistant.components.zwave_js.helpers import ( from homeassistant.const import ATTR_DEVICE_ID, ATTR_ENTITY_ID, CONF_PLATFORM, MATCH_ALL from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback from homeassistant.helpers import config_validation as cv, device_registry as dr +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .helpers import async_bypass_dynamic_config_validation @@ -87,8 +84,8 @@ async def async_validate_trigger_config( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, *, platform_type: str = PLATFORM_TYPE, ) -> CALLBACK_TYPE: @@ -108,7 +105,7 @@ async def async_attach_trigger( unsubs = [] job = HassJob(action) - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] @callback def async_on_value_updated(