mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
This commit is contained in:
parent
3a8a816584
commit
fe1c3d3be8
@ -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 {}
|
||||
|
||||
|
@ -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."""
|
||||
|
||||
|
||||
|
@ -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."""
|
||||
|
||||
|
||||
|
@ -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."""
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user