Adjust device_automation type hints in rfxtrx (#72138)
This commit is contained in:
parent
6ec755a79d
commit
dfc8dee2d6
2 changed files with 20 additions and 8 deletions
|
@ -9,6 +9,7 @@ from homeassistant.components.device_automation.exceptions import (
|
|||
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_TYPE
|
||||
from homeassistant.core import Context, HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
|
||||
from . import DATA_RFXOBJECT, DOMAIN
|
||||
from .helpers import async_get_device_object
|
||||
|
@ -37,7 +38,9 @@ ACTION_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
async def async_get_actions(hass: HomeAssistant, device_id: str) -> list[dict]:
|
||||
async def async_get_actions(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device actions for RFXCOM RFXtrx devices."""
|
||||
|
||||
try:
|
||||
|
@ -48,8 +51,8 @@ async def async_get_actions(hass: HomeAssistant, device_id: str) -> list[dict]:
|
|||
actions = []
|
||||
for action_type in ACTION_TYPES:
|
||||
if hasattr(device, action_type):
|
||||
values = getattr(device, ACTION_SELECTION[action_type], {})
|
||||
for value in values.values():
|
||||
data: dict[int, str] = getattr(device, ACTION_SELECTION[action_type], {})
|
||||
for value in data.values():
|
||||
actions.append(
|
||||
{
|
||||
CONF_DEVICE_ID: device_id,
|
||||
|
@ -69,7 +72,9 @@ def _get_commands(hass, device_id, action_type):
|
|||
return commands, send_fun
|
||||
|
||||
|
||||
async def async_validate_action_config(hass, config):
|
||||
async def async_validate_action_config(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> ConfigType:
|
||||
"""Validate config."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
commands, _ = _get_commands(hass, config[CONF_DEVICE_ID], config[CONF_TYPE])
|
||||
|
@ -84,7 +89,10 @@ async def async_validate_action_config(hass, config):
|
|||
|
||||
|
||||
async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
variables: TemplateVarsType,
|
||||
context: Context | None,
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
|
|
@ -47,13 +47,15 @@ TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
|
|||
)
|
||||
|
||||
|
||||
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
|
||||
async def async_get_triggers(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers for RFXCOM RFXtrx devices."""
|
||||
device = async_get_device_object(hass, device_id)
|
||||
|
||||
triggers = []
|
||||
for conf_type in TRIGGER_TYPES:
|
||||
data = getattr(device, TRIGGER_SELECTION[conf_type], {})
|
||||
data: dict[int, str] = getattr(device, TRIGGER_SELECTION[conf_type], {})
|
||||
for command in data.values():
|
||||
triggers.append(
|
||||
{
|
||||
|
@ -67,7 +69,9 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
|
|||
return triggers
|
||||
|
||||
|
||||
async def async_validate_trigger_config(hass, config):
|
||||
async def async_validate_trigger_config(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> ConfigType:
|
||||
"""Validate config."""
|
||||
config = TRIGGER_SCHEMA(config)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue