Add new methods to DeviceAutomationActionProtocol (#72163)
* Add composite type * Extend action protocol * Drop return/raisepull/72127/head
parent
3ece5965a8
commit
17bb503450
|
@ -44,6 +44,8 @@ if TYPE_CHECKING:
|
|||
]
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
GetAutomationsResult = list[dict[str, Any]]
|
||||
GetAutomationCapabilitiesResult = dict[str, vol.Schema]
|
||||
|
||||
DOMAIN = "device_automation"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Device action validator."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable
|
||||
from typing import Any, Protocol, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
@ -9,7 +10,12 @@ from homeassistant.const import CONF_DOMAIN
|
|||
from homeassistant.core import Context, HomeAssistant
|
||||
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
|
||||
|
||||
|
||||
|
@ -25,7 +31,6 @@ class DeviceAutomationActionProtocol(Protocol):
|
|||
self, hass: HomeAssistant, config: ConfigType
|
||||
) -> ConfigType:
|
||||
"""Validate config."""
|
||||
raise NotImplementedError
|
||||
|
||||
async def async_call_action_from_config(
|
||||
self,
|
||||
|
@ -35,7 +40,16 @@ class DeviceAutomationActionProtocol(Protocol):
|
|||
context: Context | None,
|
||||
) -> None:
|
||||
"""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(
|
||||
|
|
Loading…
Reference in New Issue