mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Add new methods to DeviceAutomationActionProtocol (#72163)
* Add composite type * Extend action protocol * Drop return/raise
This commit is contained in:
parent
3ece5965a8
commit
17bb503450
@ -44,6 +44,8 @@ if TYPE_CHECKING:
|
|||||||
]
|
]
|
||||||
|
|
||||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||||
|
GetAutomationsResult = list[dict[str, Any]]
|
||||||
|
GetAutomationCapabilitiesResult = dict[str, vol.Schema]
|
||||||
|
|
||||||
DOMAIN = "device_automation"
|
DOMAIN = "device_automation"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Device action validator."""
|
"""Device action validator."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Awaitable
|
||||||
from typing import Any, Protocol, cast
|
from typing import Any, Protocol, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -9,7 +10,12 @@ from homeassistant.const import CONF_DOMAIN
|
|||||||
from homeassistant.core import Context, HomeAssistant
|
from homeassistant.core import Context, HomeAssistant
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from . import DeviceAutomationType, async_get_device_automation_platform
|
from . import (
|
||||||
|
DeviceAutomationType,
|
||||||
|
GetAutomationCapabilitiesResult,
|
||||||
|
GetAutomationsResult,
|
||||||
|
async_get_device_automation_platform,
|
||||||
|
)
|
||||||
from .exceptions import InvalidDeviceAutomationConfig
|
from .exceptions import InvalidDeviceAutomationConfig
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +31,6 @@ class DeviceAutomationActionProtocol(Protocol):
|
|||||||
self, hass: HomeAssistant, config: ConfigType
|
self, hass: HomeAssistant, config: ConfigType
|
||||||
) -> ConfigType:
|
) -> ConfigType:
|
||||||
"""Validate config."""
|
"""Validate config."""
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
async def async_call_action_from_config(
|
async def async_call_action_from_config(
|
||||||
self,
|
self,
|
||||||
@ -35,7 +40,16 @@ class DeviceAutomationActionProtocol(Protocol):
|
|||||||
context: Context | None,
|
context: Context | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
raise NotImplementedError
|
|
||||||
|
def async_get_action_capabilities(
|
||||||
|
self, hass: HomeAssistant, config: ConfigType
|
||||||
|
) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]:
|
||||||
|
"""List action capabilities."""
|
||||||
|
|
||||||
|
def async_get_actions(
|
||||||
|
self, hass: HomeAssistant, device_id: str
|
||||||
|
) -> GetAutomationsResult | Awaitable[GetAutomationsResult]:
|
||||||
|
"""List actions."""
|
||||||
|
|
||||||
|
|
||||||
async def async_validate_action_config(
|
async def async_validate_action_config(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user