Adjust device_automation type hints in shelly (#72196)

pull/72185/head^2
epenet 2022-05-19 21:33:50 +02:00 committed by GitHub
parent 7005526892
commit 7ce3e9ad7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -1,7 +1,7 @@
"""Provides device triggers for Shelly.""" """Provides device triggers for Shelly."""
from __future__ import annotations from __future__ import annotations
from typing import Any, Final from typing import Final
import voluptuous as vol import voluptuous as vol
@ -9,7 +9,10 @@ from homeassistant.components.automation import (
AutomationActionType, AutomationActionType,
AutomationTriggerInfo, AutomationTriggerInfo,
) )
from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA from homeassistant.components.device_automation import (
DEVICE_TRIGGER_BASE_SCHEMA,
GetAutomationsResult,
)
from homeassistant.components.device_automation.exceptions import ( from homeassistant.components.device_automation.exceptions import (
InvalidDeviceAutomationConfig, InvalidDeviceAutomationConfig,
) )
@ -72,8 +75,8 @@ def append_input_triggers(
async def async_validate_trigger_config( async def async_validate_trigger_config(
hass: HomeAssistant, config: dict[str, Any] hass: HomeAssistant, config: ConfigType
) -> dict[str, Any]: ) -> ConfigType:
"""Validate config.""" """Validate config."""
config = TRIGGER_SCHEMA(config) config = TRIGGER_SCHEMA(config)
@ -108,9 +111,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
) -> list[dict[str, str]]: ) -> GetAutomationsResult:
"""List device triggers for Shelly devices.""" """List device triggers for Shelly devices."""
triggers: list[dict[str, str]] = [] triggers: GetAutomationsResult = []
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)