Drop GetAutomationsResult and GetAutomationCapabilitiesResult aliases (#72328)

This commit is contained in:
epenet 2022-05-23 12:18:17 +02:00 committed by GitHub
parent 31b53e7fc6
commit 421167c548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 61 deletions

View file

@ -7,10 +7,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
CONF_DEVICE_ID, CONF_DEVICE_ID,
@ -36,7 +33,7 @@ TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for Arcam FMJ Receiver control devices.""" """List device triggers for Arcam FMJ Receiver control devices."""
registry = entity_registry.async_get(hass) registry = entity_registry.async_get(hass)
triggers = [] triggers = []

View file

@ -44,9 +44,6 @@ 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"
DEVICE_TRIGGER_BASE_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( DEVICE_TRIGGER_BASE_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend(

View file

@ -10,12 +10,7 @@ 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 ( from . import DeviceAutomationType, async_get_device_automation_platform
DeviceAutomationType,
GetAutomationCapabilitiesResult,
GetAutomationsResult,
async_get_device_automation_platform,
)
from .exceptions import InvalidDeviceAutomationConfig from .exceptions import InvalidDeviceAutomationConfig
@ -43,12 +38,12 @@ class DeviceAutomationActionProtocol(Protocol):
def async_get_action_capabilities( def async_get_action_capabilities(
self, hass: HomeAssistant, config: ConfigType self, hass: HomeAssistant, config: ConfigType
) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]: ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]:
"""List action capabilities.""" """List action capabilities."""
def async_get_actions( def async_get_actions(
self, hass: HomeAssistant, device_id: str self, hass: HomeAssistant, device_id: str
) -> GetAutomationsResult | Awaitable[GetAutomationsResult]: ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]:
"""List actions.""" """List actions."""

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Awaitable from collections.abc import Awaitable
from typing import TYPE_CHECKING, Protocol, cast from typing import TYPE_CHECKING, Any, Protocol, cast
import voluptuous as vol import voluptuous as vol
@ -11,12 +11,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from . import ( from . import DeviceAutomationType, async_get_device_automation_platform
DeviceAutomationType,
GetAutomationCapabilitiesResult,
GetAutomationsResult,
async_get_device_automation_platform,
)
from .exceptions import InvalidDeviceAutomationConfig from .exceptions import InvalidDeviceAutomationConfig
if TYPE_CHECKING: if TYPE_CHECKING:
@ -43,12 +38,12 @@ class DeviceAutomationConditionProtocol(Protocol):
def async_get_condition_capabilities( def async_get_condition_capabilities(
self, hass: HomeAssistant, config: ConfigType self, hass: HomeAssistant, config: ConfigType
) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]: ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]:
"""List condition capabilities.""" """List condition capabilities."""
def async_get_conditions( def async_get_conditions(
self, hass: HomeAssistant, device_id: str self, hass: HomeAssistant, device_id: str
) -> GetAutomationsResult | Awaitable[GetAutomationsResult]: ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]:
"""List conditions.""" """List conditions."""

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Awaitable from collections.abc import Awaitable
from typing import Protocol, cast from typing import Any, Protocol, cast
import voluptuous as vol import voluptuous as vol
@ -17,8 +17,6 @@ from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
DEVICE_TRIGGER_BASE_SCHEMA, DEVICE_TRIGGER_BASE_SCHEMA,
DeviceAutomationType, DeviceAutomationType,
GetAutomationCapabilitiesResult,
GetAutomationsResult,
async_get_device_automation_platform, async_get_device_automation_platform,
) )
from .exceptions import InvalidDeviceAutomationConfig from .exceptions import InvalidDeviceAutomationConfig
@ -50,12 +48,12 @@ class DeviceAutomationTriggerProtocol(Protocol):
def async_get_trigger_capabilities( def async_get_trigger_capabilities(
self, hass: HomeAssistant, config: ConfigType self, hass: HomeAssistant, config: ConfigType
) -> GetAutomationCapabilitiesResult | Awaitable[GetAutomationCapabilitiesResult]: ) -> dict[str, vol.Schema] | Awaitable[dict[str, vol.Schema]]:
"""List trigger capabilities.""" """List trigger capabilities."""
def async_get_triggers( def async_get_triggers(
self, hass: HomeAssistant, device_id: str self, hass: HomeAssistant, device_id: str
) -> GetAutomationsResult | Awaitable[GetAutomationsResult]: ) -> list[dict[str, Any]] | Awaitable[list[dict[str, Any]]]:
"""List triggers.""" """List triggers."""

View file

@ -14,10 +14,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -244,7 +241,7 @@ def async_fire_triggers(conn: HKDevice, events: dict[tuple[int, int], Any]):
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for homekit devices.""" """List device triggers for homekit devices."""
if device_id not in hass.data.get(TRIGGERS, {}): if device_id not in hass.data.get(TRIGGERS, {}):

View file

@ -7,10 +7,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
@ -350,7 +347,7 @@ async def async_validate_trigger_config(
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for lutron caseta devices.""" """List device triggers for lutron caseta devices."""
triggers = [] triggers = []

View file

@ -8,10 +8,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
@ -66,7 +63,7 @@ def async_get_device_trigger_types(
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for a Nest device.""" """List device triggers for a Nest device."""
nest_device_id = async_get_nest_device_id(hass, device_id) nest_device_id = async_get_nest_device_id(hass, device_id)
if not nest_device_id: if not nest_device_id:

View file

@ -7,10 +7,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
@ -101,7 +98,7 @@ async def async_validate_trigger_config(
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for Netatmo devices.""" """List device triggers for Netatmo devices."""
registry = entity_registry.async_get(hass) registry = entity_registry.async_get(hass)
device_registry = dr.async_get(hass) device_registry = dr.async_get(hass)

View file

@ -9,10 +9,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
@ -111,9 +108,9 @@ async def async_validate_trigger_config(
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for Shelly devices.""" """List device triggers for Shelly devices."""
triggers: GetAutomationsResult = [] triggers: list[dict[str, str]] = []
if rpc_wrapper := get_rpc_device_wrapper(hass, device_id): if rpc_wrapper := get_rpc_device_wrapper(hass, device_id):
input_triggers = get_rpc_input_triggers(rpc_wrapper.device) input_triggers = get_rpc_input_triggers(rpc_wrapper.device)

View file

@ -7,10 +7,7 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import ( from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
@ -61,7 +58,7 @@ async def async_validate_trigger_config(
async def async_get_triggers( async def async_get_triggers(
_hass: HomeAssistant, device_id: str _hass: HomeAssistant, device_id: str
) -> GetAutomationsResult: ) -> list[dict[str, str]]:
"""List device triggers for device.""" """List device triggers for device."""
triggers = [] triggers = []
base_trigger = { base_trigger = {