diff --git a/homeassistant/components/device_automation/__init__.py b/homeassistant/components/device_automation/__init__.py index 99629f3dd23..0a1ec495e70 100644 --- a/homeassistant/components/device_automation/__init__.py +++ b/homeassistant/components/device_automation/__init__.py @@ -189,22 +189,6 @@ def _async_set_entity_device_automation_metadata( automation["metadata"]["secondary"] = bool(entry.entity_category or entry.hidden_by) -async def _async_get_automation_for_device( - hass: HomeAssistant, - platform: DeviceAutomationPlatformType, - function_name: str, - device_id: str, -) -> list[dict[str, Any]]: - """List device automations.""" - automations = getattr(platform, function_name)(hass, device_id) - if asyncio.iscoroutine(automations): - # Using a coroutine to get device automations is deprecated - # enable warning when core is fully migrated - # then remove in Home Assistant Core xxxx.xx - return await automations # type: ignore[no-any-return] - return automations # type: ignore[no-any-return] - - async def _async_get_device_automations_from_domain( hass: HomeAssistant, domain: str, @@ -224,7 +208,7 @@ async def _async_get_device_automations_from_domain( return await asyncio.gather( # type: ignore[no-any-return] *( - _async_get_automation_for_device(hass, platform, function_name, device_id) + getattr(platform, function_name)(hass, device_id) for device_id in device_ids ), return_exceptions=return_exceptions, @@ -310,12 +294,7 @@ async def _async_get_device_automation_capabilities( return {} try: - capabilities = getattr(platform, function_name)(hass, automation) - if asyncio.iscoroutine(capabilities): - # Using a coroutine to get device automation capabitilites is deprecated - # enable warning when core is fully migrated - # then remove in Home Assistant Core xxxx.xx - capabilities = await capabilities + capabilities = await getattr(platform, function_name)(hass, automation) except InvalidDeviceAutomationConfig: return {} diff --git a/homeassistant/components/device_automation/action.py b/homeassistant/components/device_automation/action.py index 5737fbc5bf3..081b6bb283a 100644 --- a/homeassistant/components/device_automation/action.py +++ b/homeassistant/components/device_automation/action.py @@ -1,7 +1,6 @@ """Device action validator.""" from __future__ import annotations -from collections.abc import Awaitable from typing import Any, Protocol, cast import voluptuous as vol @@ -36,14 +35,14 @@ class DeviceAutomationActionProtocol(Protocol): ) -> None: """Execute a device action.""" - def async_get_action_capabilities( + async def async_get_action_capabilities( self, hass: HomeAssistant, config: ConfigType - ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]: + ) -> dict[str, vol.Schema]: """List action capabilities.""" - def async_get_actions( + async def async_get_actions( self, hass: HomeAssistant, device_id: str - ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]: + ) -> list[dict[str, Any]]: """List actions.""" diff --git a/homeassistant/components/device_automation/condition.py b/homeassistant/components/device_automation/condition.py index 1f1f8e94832..d656908f4be 100644 --- a/homeassistant/components/device_automation/condition.py +++ b/homeassistant/components/device_automation/condition.py @@ -1,7 +1,6 @@ """Validate device conditions.""" from __future__ import annotations -from collections.abc import Awaitable from typing import TYPE_CHECKING, Any, Protocol, cast import voluptuous as vol @@ -36,14 +35,14 @@ class DeviceAutomationConditionProtocol(Protocol): ) -> condition.ConditionCheckerType: """Evaluate state based on configuration.""" - def async_get_condition_capabilities( + async def async_get_condition_capabilities( self, hass: HomeAssistant, config: ConfigType - ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]: + ) -> dict[str, vol.Schema]: """List condition capabilities.""" - def async_get_conditions( + async def async_get_conditions( self, hass: HomeAssistant, device_id: str - ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]: + ) -> list[dict[str, Any]]: """List conditions.""" diff --git a/homeassistant/components/device_automation/trigger.py b/homeassistant/components/device_automation/trigger.py index c5f42b3e813..eb39ec383af 100644 --- a/homeassistant/components/device_automation/trigger.py +++ b/homeassistant/components/device_automation/trigger.py @@ -1,7 +1,6 @@ """Offer device oriented automation.""" from __future__ import annotations -from collections.abc import Awaitable from typing import Any, Protocol, cast import voluptuous as vol @@ -46,14 +45,14 @@ class DeviceAutomationTriggerProtocol(Protocol): ) -> CALLBACK_TYPE: """Attach a trigger.""" - def async_get_trigger_capabilities( + async def async_get_trigger_capabilities( self, hass: HomeAssistant, config: ConfigType - ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]: + ) -> dict[str, vol.Schema]: """List trigger capabilities.""" - def async_get_triggers( + async def async_get_triggers( self, hass: HomeAssistant, device_id: str - ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]: + ) -> list[dict[str, Any]]: """List triggers."""