Adjust device_automation type hints in lutron_caseta (#72133)

This commit is contained in:
epenet 2022-05-19 22:21:43 +02:00 committed by GitHub
parent 7ce3e9ad7b
commit 3604bb4c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,16 @@
"""Provides device triggers for lutron caseta."""
from __future__ import annotations
from typing import Any
import voluptuous as vol
from homeassistant.components.automation import (
AutomationActionType,
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 (
InvalidDeviceAutomationConfig,
)
@ -329,7 +330,9 @@ TRIGGER_SCHEMA = vol.Any(
)
async def async_validate_trigger_config(hass: HomeAssistant, config: ConfigType):
async def async_validate_trigger_config(
hass: HomeAssistant, config: ConfigType
) -> ConfigType:
"""Validate config."""
# if device is available verify parameters against device capabilities
device = get_button_device_by_dr_id(hass, config[CONF_DEVICE_ID])
@ -347,14 +350,14 @@ async def async_validate_trigger_config(hass: HomeAssistant, config: ConfigType)
async def async_get_triggers(
hass: HomeAssistant, device_id: str
) -> list[dict[str, Any]]:
) -> GetAutomationsResult:
"""List device triggers for lutron caseta devices."""
triggers = []
if not (device := get_button_device_by_dr_id(hass, device_id)):
raise InvalidDeviceAutomationConfig(f"Device not found: {device_id}")
valid_buttons = DEVICE_TYPE_SUBTYPE_MAP_TO_LIP.get(device["type"], [])
valid_buttons = DEVICE_TYPE_SUBTYPE_MAP_TO_LIP.get(device["type"], {})
for trigger in SUPPORTED_INPUTS_EVENTS_TYPES:
for subtype in valid_buttons: