mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 17:18:23 +00:00
Revert "Adjust"
This reverts commit 17b3d16a267d54c082b12f07550faa8ac4ac3a49.
This commit is contained in:
parent
17b3d16a26
commit
a61e0577b1
@ -256,11 +256,6 @@ async def async_attach_trigger(
|
|||||||
class EventTrigger(Trigger):
|
class EventTrigger(Trigger):
|
||||||
"""Z-Wave JS event trigger."""
|
"""Z-Wave JS event trigger."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
|
|
||||||
"""Initialize trigger."""
|
|
||||||
self._config = config
|
|
||||||
self._hass = hass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def async_validate_trigger_config(
|
async def async_validate_trigger_config(
|
||||||
cls, hass: HomeAssistant, config: ConfigType
|
cls, hass: HomeAssistant, config: ConfigType
|
||||||
@ -268,12 +263,13 @@ class EventTrigger(Trigger):
|
|||||||
"""Validate config."""
|
"""Validate config."""
|
||||||
return await async_validate_trigger_config(hass, config)
|
return await async_validate_trigger_config(hass, config)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
async def async_attach_trigger(
|
async def async_attach_trigger(
|
||||||
self,
|
cls,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
action: TriggerActionType,
|
action: TriggerActionType,
|
||||||
trigger_info: TriggerInfo,
|
trigger_info: TriggerInfo,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
return await async_attach_trigger(
|
return await async_attach_trigger(hass, config, action, trigger_info)
|
||||||
self._hass, self._config, action, trigger_info
|
|
||||||
)
|
|
||||||
|
@ -207,11 +207,6 @@ async def async_attach_trigger(
|
|||||||
class ValueUpdatedTrigger(Trigger):
|
class ValueUpdatedTrigger(Trigger):
|
||||||
"""Z-Wave JS value updated trigger."""
|
"""Z-Wave JS value updated trigger."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
|
|
||||||
"""Initialize trigger."""
|
|
||||||
self._config = config
|
|
||||||
self._hass = hass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def async_validate_trigger_config(
|
async def async_validate_trigger_config(
|
||||||
cls, hass: HomeAssistant, config: ConfigType
|
cls, hass: HomeAssistant, config: ConfigType
|
||||||
@ -219,12 +214,13 @@ class ValueUpdatedTrigger(Trigger):
|
|||||||
"""Validate config."""
|
"""Validate config."""
|
||||||
return await async_validate_trigger_config(hass, config)
|
return await async_validate_trigger_config(hass, config)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
async def async_attach_trigger(
|
async def async_attach_trigger(
|
||||||
self,
|
cls,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
action: TriggerActionType,
|
action: TriggerActionType,
|
||||||
trigger_info: TriggerInfo,
|
trigger_info: TriggerInfo,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
return await async_attach_trigger(
|
return await async_attach_trigger(hass, config, action, trigger_info)
|
||||||
self._hass, self._config, action, trigger_info
|
|
||||||
)
|
|
||||||
|
@ -53,9 +53,6 @@ DATA_PLUGGABLE_ACTIONS: HassKey[defaultdict[tuple, PluggableActionsEntry]] = Has
|
|||||||
class Trigger(abc.ABC):
|
class Trigger(abc.ABC):
|
||||||
"""Trigger class."""
|
"""Trigger class."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
|
|
||||||
"""Initialize trigger."""
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
async def async_validate_trigger_config(
|
async def async_validate_trigger_config(
|
||||||
@ -63,9 +60,12 @@ class Trigger(abc.ABC):
|
|||||||
) -> ConfigType:
|
) -> ConfigType:
|
||||||
"""Validate config."""
|
"""Validate config."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
async def async_attach_trigger(
|
async def async_attach_trigger(
|
||||||
self,
|
cls,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
action: TriggerActionType,
|
action: TriggerActionType,
|
||||||
trigger_info: TriggerInfo,
|
trigger_info: TriggerInfo,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
@ -370,15 +370,17 @@ async def async_initialize_triggers(
|
|||||||
trigger_data=trigger_data,
|
trigger_data=trigger_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
action_wrapper = _trigger_action_wrapper(hass, action, conf)
|
|
||||||
if hasattr(platform, "async_get_triggers"):
|
if hasattr(platform, "async_get_triggers"):
|
||||||
trigger_descriptors = await platform.async_get_triggers(hass)
|
trigger_descriptors = await platform.async_get_triggers(hass)
|
||||||
trigger = trigger_descriptors[conf[CONF_PLATFORM]](hass, conf)
|
attach_fn = trigger_descriptors[conf[CONF_PLATFORM]].async_attach_trigger
|
||||||
coro = trigger.async_attach_trigger(action_wrapper, info)
|
|
||||||
else:
|
else:
|
||||||
coro = platform.async_attach_trigger(hass, conf, action_wrapper, info)
|
attach_fn = platform.async_attach_trigger
|
||||||
|
|
||||||
triggers.append(create_eager_task(coro))
|
triggers.append(
|
||||||
|
create_eager_task(
|
||||||
|
attach_fn(hass, conf, _trigger_action_wrapper(hass, action, conf), info)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
attach_results = await asyncio.gather(*triggers, return_exceptions=True)
|
attach_results = await asyncio.gather(*triggers, return_exceptions=True)
|
||||||
removes: list[Callable[[], None]] = []
|
removes: list[Callable[[], None]] = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user