diff --git a/homeassistant/components/remote/device_trigger.py b/homeassistant/components/remote/device_trigger.py index 127f07827e2..f2d5c54e3c3 100644 --- a/homeassistant/components/remote/device_trigger.py +++ b/homeassistant/components/remote/device_trigger.py @@ -3,13 +3,10 @@ from __future__ import annotations import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import toggle_entity from homeassistant.const import CONF_DOMAIN from homeassistant.core import CALLBACK_TYPE, HomeAssistant +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import DOMAIN @@ -23,13 +20,11 @@ TRIGGER_SCHEMA = vol.All( 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.""" - return await toggle_entity.async_attach_trigger( - hass, config, action, automation_info - ) + return await toggle_entity.async_attach_trigger(hass, config, action, trigger_info) async def async_get_triggers( diff --git a/homeassistant/components/select/device_trigger.py b/homeassistant/components/select/device_trigger.py index 574acfc6893..897ed855a5e 100644 --- a/homeassistant/components/select/device_trigger.py +++ b/homeassistant/components/select/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.homeassistant.triggers.state import ( CONF_FOR, @@ -26,6 +22,7 @@ from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv, entity_registry from homeassistant.helpers.entity import get_capability +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .const import ATTR_OPTIONS, DOMAIN @@ -64,8 +61,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.""" state_config = { @@ -84,7 +81,7 @@ async def async_attach_trigger( state_config = await async_validate_state_trigger_config(hass, state_config) return await async_attach_state_trigger( - hass, state_config, action, automation_info, platform_type="device" + hass, state_config, action, trigger_info, platform_type="device" ) diff --git a/homeassistant/components/sensor/device_trigger.py b/homeassistant/components/sensor/device_trigger.py index 741c0281e0d..5c815d3c546 100644 --- a/homeassistant/components/sensor/device_trigger.py +++ b/homeassistant/components/sensor/device_trigger.py @@ -1,10 +1,6 @@ """Provides device triggers for sensors.""" 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, @@ -27,6 +23,7 @@ from homeassistant.helpers.entity import ( get_device_class, get_unit_of_measurement, ) +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import ATTR_STATE_CLASS, DOMAIN, SensorDeviceClass @@ -143,8 +140,8 @@ TRIGGER_SCHEMA = vol.All( 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.""" numeric_state_config = { @@ -162,7 +159,7 @@ async def async_attach_trigger( hass, numeric_state_config ) return await numeric_state_trigger.async_attach_trigger( - hass, numeric_state_config, action, automation_info, platform_type="device" + hass, numeric_state_config, action, trigger_info, platform_type="device" ) diff --git a/homeassistant/components/sun/trigger.py b/homeassistant/components/sun/trigger.py index 75f5b36f8f5..86af51f0283 100644 --- a/homeassistant/components/sun/trigger.py +++ b/homeassistant/components/sun/trigger.py @@ -3,10 +3,6 @@ from datetime import timedelta import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.const import ( CONF_EVENT, CONF_OFFSET, @@ -16,6 +12,7 @@ from homeassistant.const import ( from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import async_track_sunrise, async_track_sunset +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType # mypy: allow-untyped-defs, no-check-untyped-defs @@ -32,11 +29,11 @@ TRIGGER_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Listen for events based on configuration.""" - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] event = config.get(CONF_EVENT) offset = config.get(CONF_OFFSET) description = event diff --git a/homeassistant/components/switch/device_trigger.py b/homeassistant/components/switch/device_trigger.py index 9f56d7a09d2..499b04bbaf3 100644 --- a/homeassistant/components/switch/device_trigger.py +++ b/homeassistant/components/switch/device_trigger.py @@ -3,13 +3,10 @@ from __future__ import annotations import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.components.device_automation import toggle_entity from homeassistant.const import CONF_DOMAIN from homeassistant.core import CALLBACK_TYPE, HomeAssistant +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from . import DOMAIN @@ -23,13 +20,11 @@ TRIGGER_SCHEMA = vol.All( 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.""" - return await toggle_entity.async_attach_trigger( - hass, config, action, automation_info - ) + return await toggle_entity.async_attach_trigger(hass, config, action, trigger_info) async def async_get_triggers( diff --git a/homeassistant/components/tag/trigger.py b/homeassistant/components/tag/trigger.py index b844ee260a2..146521dfba9 100644 --- a/homeassistant/components/tag/trigger.py +++ b/homeassistant/components/tag/trigger.py @@ -1,13 +1,10 @@ """Support for tag triggers.""" import voluptuous as vol -from homeassistant.components.automation import ( - AutomationActionType, - AutomationTriggerInfo, -) from homeassistant.const import CONF_PLATFORM from homeassistant.core import CALLBACK_TYPE, Event, HassJob, HomeAssistant from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo from homeassistant.helpers.typing import ConfigType from .const import DEVICE_ID, DOMAIN, EVENT_TAG_SCANNED, TAG_ID @@ -24,11 +21,11 @@ TRIGGER_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, - action: AutomationActionType, - automation_info: AutomationTriggerInfo, + action: TriggerActionType, + trigger_info: TriggerInfo, ) -> CALLBACK_TYPE: """Listen for tag_scanned events based on configuration.""" - trigger_data = automation_info["trigger_data"] + trigger_data = trigger_info["trigger_data"] tag_ids = set(config[TAG_ID]) device_ids = set(config[DEVICE_ID]) if DEVICE_ID in config else None