diff --git a/homeassistant/components/arcam_fmj/device_trigger.py b/homeassistant/components/arcam_fmj/device_trigger.py index 593250e4983..13f1acc7244 100644 --- a/homeassistant/components/arcam_fmj/device_trigger.py +++ b/homeassistant/components/arcam_fmj/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.const import ( ATTR_ENTITY_ID, @@ -18,6 +14,7 @@ from homeassistant.const import ( ) from homeassistant.core import CALLBACK_TYPE, Event, HassJob, HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_registry +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, EVENT_TURN_ON @@ -57,11 +54,11 @@ 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_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] job = HassJob(action) if config[CONF_TYPE] == "turn_on": diff --git a/homeassistant/components/deconz/device_trigger.py b/homeassistant/components/deconz/device_trigger.py index e15513bddbf..601fe95616b 100644 --- a/homeassistant/components/deconz/device_trigger.py +++ b/homeassistant/components/deconz/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, @@ -22,6 +18,7 @@ from homeassistant.const import ( ) from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.helpers import device_registry as dr +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import DOMAIN @@ -668,8 +665,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.""" event_data: dict[str, int | str] = {} @@ -693,7 +690,7 @@ async def async_attach_trigger( event_config = event_trigger.TRIGGER_SCHEMA(raw_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/homekit_controller/device_trigger.py b/homeassistant/components/homekit_controller/device_trigger.py index 700ab60c47f..ecffb902928 100644 --- a/homeassistant/components/homekit_controller/device_trigger.py +++ b/homeassistant/components/homekit_controller/device_trigger.py @@ -10,14 +10,11 @@ from aiohomekit.model.services import ServicesTypes from aiohomekit.utils import clamp_enum_to_char import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, KNOWN_DEVICES, TRIGGERS @@ -84,11 +81,11 @@ class TriggerSource: async def async_attach_trigger( self, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Attach a trigger.""" - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] job = HassJob(action) @callback @@ -269,10 +266,10 @@ 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.""" device_id = config[CONF_DEVICE_ID] device = hass.data[TRIGGERS][device_id] - return await device.async_attach_trigger(config, action, automation_info) + return await device.async_attach_trigger(config, action, trigger_info) diff --git a/homeassistant/components/hue/device_trigger.py b/homeassistant/components/hue/device_trigger.py index e8eb7695ed9..069f0d42d8d 100644 --- a/homeassistant/components/hue/device_trigger.py +++ b/homeassistant/components/hue/device_trigger.py @@ -24,11 +24,8 @@ from .v2.device_trigger import ( ) if TYPE_CHECKING: - from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, - ) from homeassistant.core import HomeAssistant + from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from .bridge import HueBridge @@ -59,8 +56,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.""" device_id = config[CONF_DEVICE_ID] @@ -75,10 +72,10 @@ async def async_attach_trigger( bridge: HueBridge = hass.data[DOMAIN][conf_entry_id] if bridge.api_version == 1: return await async_attach_trigger_v1( - bridge, device_entry, config, action, automation_info + bridge, device_entry, config, action, trigger_info ) return await async_attach_trigger_v2( - bridge, device_entry, config, action, automation_info + bridge, device_entry, config, action, trigger_info ) raise InvalidDeviceAutomationConfig( f"Device ID {device_id} is not found on any Hue bridge" diff --git a/homeassistant/components/hue/v1/device_trigger.py b/homeassistant/components/hue/v1/device_trigger.py index 579f4b71efb..4316ea65406 100644 --- a/homeassistant/components/hue/v1/device_trigger.py +++ b/homeassistant/components/hue/v1/device_trigger.py @@ -3,10 +3,6 @@ from typing import TYPE_CHECKING 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, @@ -22,6 +18,7 @@ from homeassistant.const import ( ) from homeassistant.core import CALLBACK_TYPE, callback from homeassistant.helpers.device_registry import DeviceEntry +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from ..const import ATTR_HUE_EVENT, CONF_SUBTYPE, DOMAIN @@ -148,8 +145,8 @@ async def async_attach_trigger( bridge: "HueBridge", device_entry: DeviceEntry, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" hass = bridge.hass @@ -171,7 +168,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/hue/v2/device_trigger.py b/homeassistant/components/hue/v2/device_trigger.py index 0fa9e37569d..62ce0ec1edf 100644 --- a/homeassistant/components/hue/v2/device_trigger.py +++ b/homeassistant/components/hue/v2/device_trigger.py @@ -29,10 +29,7 @@ from ..const import ATTR_HUE_EVENT, CONF_SUBTYPE, DOMAIN if TYPE_CHECKING: from aiohue.v2 import HueBridgeV2 - from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, - ) + from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from ..bridge import HueBridge @@ -77,8 +74,8 @@ async def async_attach_trigger( bridge: "HueBridge", device_entry: DeviceEntry, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" hass = bridge.hass @@ -94,7 +91,7 @@ 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/kodi/device_trigger.py b/homeassistant/components/kodi/device_trigger.py index 11d0b1567f9..07fcf11c077 100644 --- a/homeassistant/components/kodi/device_trigger.py +++ b/homeassistant/components/kodi/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.const import ( ATTR_ENTITY_ID, @@ -18,6 +14,7 @@ from homeassistant.const import ( ) from homeassistant.core import CALLBACK_TYPE, Event, HassJob, HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_registry +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, EVENT_TURN_OFF, EVENT_TURN_ON @@ -68,11 +65,11 @@ async def async_get_triggers( def _attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, + action: TriggerActionType, event_type, - automation_info: AutomationTriggerInfo, + trigger_info: TriggerInfo, ): - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] job = HassJob(action) @callback @@ -90,14 +87,14 @@ def _attach_trigger( 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 config[CONF_TYPE] == "turn_on": - return _attach_trigger(hass, config, action, EVENT_TURN_ON, automation_info) + return _attach_trigger(hass, config, action, EVENT_TURN_ON, trigger_info) if config[CONF_TYPE] == "turn_off": - return _attach_trigger(hass, config, action, EVENT_TURN_OFF, automation_info) + return _attach_trigger(hass, config, action, EVENT_TURN_OFF, trigger_info) return lambda: None