Improve device trigger type hinting (#54907)

This commit is contained in:
Ville Skyttä 2021-08-22 21:32:50 +03:00 committed by GitHub
parent bfb6eaf6f3
commit 0095c6baeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 153 additions and 43 deletions

View File

@ -1,7 +1,7 @@
"""Provides device automations for Alarm control panel.""" """Provides device automations for Alarm control panel."""
from __future__ import annotations from __future__ import annotations
from typing import Final from typing import Any, Final
import voluptuous as vol import voluptuous as vol
@ -55,7 +55,7 @@ TRIGGER_SCHEMA: Final = 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
) -> list[dict[str, str]]: ) -> list[dict[str, Any]]:
"""List device triggers for Alarm control panel devices.""" """List device triggers for Alarm control panel devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers: list[dict[str, str]] = [] triggers: list[dict[str, str]] = []

View File

@ -1,6 +1,8 @@
"""Provides device automations for Arcam FMJ Receiver control.""" """Provides device automations for Arcam FMJ Receiver control."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -28,7 +30,9 @@ 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, Any]]:
"""List device triggers for Arcam FMJ Receiver control devices.""" """List device triggers for Arcam FMJ Receiver control devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []

View File

@ -1,6 +1,8 @@
"""Provides device automations for Climate.""" """Provides device automations for Climate."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -58,7 +60,9 @@ CURRENT_TRIGGER_SCHEMA = vol.All(
TRIGGER_SCHEMA = vol.Any(HVAC_MODE_TRIGGER_SCHEMA, CURRENT_TRIGGER_SCHEMA) TRIGGER_SCHEMA = vol.Any(HVAC_MODE_TRIGGER_SCHEMA, CURRENT_TRIGGER_SCHEMA)
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, Any]]:
"""List device triggers for Climate devices.""" """List device triggers for Climate devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []
@ -158,12 +162,14 @@ async def async_attach_trigger(
) )
async def async_get_trigger_capabilities(hass: HomeAssistant, config): async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
trigger_type = config[CONF_TYPE] trigger_type = config[CONF_TYPE]
if trigger_type == "hvac_action_changed": if trigger_type == "hvac_action_changed":
return None return {}
if trigger_type == "hvac_mode_changed": if trigger_type == "hvac_mode_changed":
return { return {

View File

@ -1,6 +1,8 @@
"""Provides device automations for Cover.""" """Provides device automations for Cover."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -67,7 +69,9 @@ STATE_TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
TRIGGER_SCHEMA = vol.Any(POSITION_TRIGGER_SCHEMA, STATE_TRIGGER_SCHEMA) TRIGGER_SCHEMA = vol.Any(POSITION_TRIGGER_SCHEMA, STATE_TRIGGER_SCHEMA)
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, Any]]:
"""List device triggers for Cover devices.""" """List device triggers for Cover devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []
@ -114,7 +118,9 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
return triggers return triggers
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
if config[CONF_TYPE] not in POSITION_TRIGGER_TYPES: if config[CONF_TYPE] not in POSITION_TRIGGER_TYPES:
return { return {

View File

@ -1,6 +1,8 @@
"""Device automation helpers for toggle entity.""" """Device automation helpers for toggle entity."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -212,7 +214,7 @@ async def async_get_conditions(
async def async_get_triggers( async def async_get_triggers(
hass: HomeAssistant, device_id: str, domain: str hass: HomeAssistant, device_id: str, domain: str
) -> list[dict]: ) -> list[dict[str, Any]]:
"""List device triggers.""" """List device triggers."""
return await _async_get_automations(hass, device_id, ENTITY_TRIGGERS, domain) return await _async_get_automations(hass, device_id, ENTITY_TRIGGERS, domain)
@ -228,7 +230,9 @@ async def async_get_condition_capabilities(
} }
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return { return {
"extra_fields": vol.Schema( "extra_fields": vol.Schema(

View File

@ -1,7 +1,7 @@
"""Provides device automations for Device Tracker.""" """Provides device automations for Device Tracker."""
from __future__ import annotations from __future__ import annotations
from typing import Final from typing import Any, Final
import voluptuous as vol import voluptuous as vol
@ -34,7 +34,9 @@ TRIGGER_SCHEMA: Final = 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, Any]]:
"""List device triggers for Device Tracker devices.""" """List device triggers for Device Tracker devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []

View File

@ -1,6 +1,8 @@
"""Provides device automations for Fan.""" """Provides device automations for Fan."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -16,12 +18,16 @@ TRIGGER_SCHEMA = toggle_entity.TRIGGER_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, Any]]:
"""List device triggers for Fan devices.""" """List device triggers for Fan devices."""
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return await toggle_entity.async_get_trigger_capabilities(hass, config) return await toggle_entity.async_get_trigger_capabilities(hass, config)

View File

@ -1,6 +1,8 @@
"""Provides device automations for homekit devices.""" """Provides device automations for homekit devices."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from aiohomekit.model.characteristics import CharacteristicsTypes from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.characteristics.const import InputEventValues from aiohomekit.model.characteristics.const import InputEventValues
from aiohomekit.model.services import ServicesTypes from aiohomekit.model.services import ServicesTypes
@ -232,7 +234,9 @@ def async_fire_triggers(conn, events):
source.fire(iid, ev) source.fire(iid, ev)
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, Any]]:
"""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

@ -1,6 +1,8 @@
"""Provides device automations for Climate.""" """Provides device automations for Climate."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -28,6 +30,8 @@ from homeassistant.helpers.typing import ConfigType
from . import DOMAIN from . import DOMAIN
# mypy: disallow-any-generics
TARGET_TRIGGER_SCHEMA = vol.All( TARGET_TRIGGER_SCHEMA = vol.All(
DEVICE_TRIGGER_BASE_SCHEMA.extend( DEVICE_TRIGGER_BASE_SCHEMA.extend(
{ {
@ -48,7 +52,9 @@ TOGGLE_TRIGGER_SCHEMA = toggle_entity.TRIGGER_SCHEMA.extend(
TRIGGER_SCHEMA = vol.Any(TARGET_TRIGGER_SCHEMA, TOGGLE_TRIGGER_SCHEMA) TRIGGER_SCHEMA = vol.Any(TARGET_TRIGGER_SCHEMA, TOGGLE_TRIGGER_SCHEMA)
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, Any]]:
"""List device triggers for Humidifier devices.""" """List device triggers for Humidifier devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
@ -105,7 +111,9 @@ async def async_attach_trigger(
) )
async def async_get_trigger_capabilities(hass: HomeAssistant, config): async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
trigger_type = config[CONF_TYPE] trigger_type = config[CONF_TYPE]

View File

@ -1,6 +1,8 @@
"""Provides device automations for Kodi.""" """Provides device automations for Kodi."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -29,7 +31,9 @@ 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, Any]]:
"""List device triggers for Kodi devices.""" """List device triggers for Kodi devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []

View File

@ -1,6 +1,8 @@
"""Provides device trigger for lights.""" """Provides device trigger for lights."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -28,11 +30,15 @@ async def async_attach_trigger(
) )
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, Any]]:
"""List device triggers.""" """List device triggers."""
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return await toggle_entity.async_get_trigger_capabilities(hass, config) return await toggle_entity.async_get_trigger_capabilities(hass, config)

View File

@ -1,6 +1,8 @@
"""Provides device automations for Lock.""" """Provides device automations for Lock."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -36,7 +38,9 @@ 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, Any]]:
"""List device triggers for Lock devices.""" """List device triggers for Lock devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []
@ -61,7 +65,9 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
return triggers return triggers
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return { return {
"extra_fields": vol.Schema( "extra_fields": vol.Schema(

View File

@ -1,6 +1,8 @@
"""Provides device triggers for lutron caseta.""" """Provides device triggers for lutron caseta."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -225,7 +227,9 @@ async def async_validate_trigger_config(hass: HomeAssistant, config: ConfigType)
return schema(config) return schema(config)
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, Any]]:
"""List device triggers for lutron caseta devices.""" """List device triggers for lutron caseta devices."""
triggers = [] triggers = []

View File

@ -1,6 +1,8 @@
"""Provides device automations for Media player.""" """Provides device automations for Media player."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -36,7 +38,9 @@ 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, Any]]:
"""List device triggers for Media player entities.""" """List device triggers for Media player entities."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []
@ -61,7 +65,9 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
return triggers return triggers
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return { return {
"extra_fields": vol.Schema( "extra_fields": vol.Schema(

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Callable from typing import Any, Callable
import attr import attr
import voluptuous as vol import voluptuous as vol
@ -287,7 +287,9 @@ async def async_device_removed(hass: HomeAssistant, device_id: str):
) )
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, Any]]:
"""List device triggers for MQTT devices.""" """List device triggers for MQTT devices."""
triggers: list[dict] = [] triggers: list[dict] = []

View File

@ -1,6 +1,8 @@
"""Provides device automations for Nest.""" """Provides device automations for Nest."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -62,7 +64,9 @@ async def async_get_device_trigger_types(
return trigger_types return trigger_types
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, Any]]:
"""List device triggers for a Nest device.""" """List device triggers for a Nest device."""
nest_device_id = await async_get_nest_device_id(hass, device_id) nest_device_id = await async_get_nest_device_id(hass, device_id)
if not nest_device_id: if not nest_device_id:

View File

@ -1,6 +1,8 @@
"""Provides device automations for Netatmo.""" """Provides device automations for Netatmo."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -84,7 +86,9 @@ async def async_validate_trigger_config(
return config return config
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, Any]]:
"""List device triggers for Netatmo devices.""" """List device triggers for Netatmo devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
device_registry = await hass.helpers.device_registry.async_get_registry() device_registry = await hass.helpers.device_registry.async_get_registry()

View File

@ -1,6 +1,8 @@
"""Provides device automations for control of device.""" """Provides device automations for control of device."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -23,7 +25,9 @@ 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, Any]]:
"""List device triggers for device.""" """List device triggers for device."""
triggers = [] triggers = []
triggers.append( triggers.append(

View File

@ -1,6 +1,8 @@
"""Provides device triggers for remotes.""" """Provides device triggers for remotes."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -28,11 +30,15 @@ async def async_attach_trigger(
) )
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, Any]]:
"""List device triggers.""" """List device triggers."""
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return await toggle_entity.async_get_trigger_capabilities(hass, config) return await toggle_entity.async_get_trigger_capabilities(hass, config)

View File

@ -42,7 +42,9 @@ 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, Any]]:
"""List device triggers for Select devices.""" """List device triggers for Select devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
return [ return [
@ -87,7 +89,7 @@ async def async_attach_trigger(
async def async_get_trigger_capabilities( async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType hass: HomeAssistant, config: ConfigType
) -> dict[str, Any]: ) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
try: try:
options = get_capability(hass, config[CONF_ENTITY_ID], ATTR_OPTIONS) or [] options = get_capability(hass, config[CONF_ENTITY_ID], ATTR_OPTIONS) or []

View File

@ -69,7 +69,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
) -> list[dict[str, str]]: ) -> list[dict[str, Any]]:
"""List device triggers for Shelly devices.""" """List device triggers for Shelly devices."""
triggers = [] triggers = []

View File

@ -1,6 +1,8 @@
"""Provides device triggers for switches.""" """Provides device triggers for switches."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -28,11 +30,15 @@ async def async_attach_trigger(
) )
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, Any]]:
"""List device triggers.""" """List device triggers."""
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return await toggle_entity.async_get_trigger_capabilities(hass, config) return await toggle_entity.async_get_trigger_capabilities(hass, config)

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Callable from typing import Any, Callable
import attr import attr
from hatasmota.models import DiscoveryHashType from hatasmota.models import DiscoveryHashType
@ -259,7 +259,9 @@ async def async_remove_triggers(hass: HomeAssistant, device_id: str) -> None:
device_trigger.remove_update_signal() device_trigger.remove_update_signal()
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, Any]]:
"""List device triggers for a Tasmota device.""" """List device triggers for a Tasmota device."""
triggers: list[dict[str, str]] = [] triggers: list[dict[str, str]] = []

View File

@ -1,6 +1,8 @@
"""Provides device automations for Vacuum.""" """Provides device automations for Vacuum."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -31,7 +33,9 @@ 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, Any]]:
"""List device triggers for Vacuum devices.""" """List device triggers for Vacuum devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []
@ -55,7 +59,9 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
return triggers return triggers
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: async def async_get_trigger_capabilities(
hass: HomeAssistant, config: ConfigType
) -> dict[str, vol.Schema]:
"""List trigger capabilities.""" """List trigger capabilities."""
return { return {
"extra_fields": vol.Schema( "extra_fields": vol.Schema(

View File

@ -1,6 +1,8 @@
"""Provides device triggers for Z-Wave JS.""" """Provides device triggers for Z-Wave JS."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from zwave_js_server.const import CommandClass, ConfigurationValueType from zwave_js_server.const import CommandClass, ConfigurationValueType
@ -184,7 +186,9 @@ TRIGGER_SCHEMA = vol.Any(
) )
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, Any]]:
"""List device triggers for Z-Wave JS devices.""" """List device triggers for Z-Wave JS devices."""
dev_reg = device_registry.async_get(hass) dev_reg = device_registry.async_get(hass)
node = async_get_node_from_device_id(hass, device_id, dev_reg) node = async_get_node_from_device_id(hass, device_id, dev_reg)

View File

@ -1,6 +1,8 @@
"""Provides device triggers for NEW_NAME.""" """Provides device triggers for NEW_NAME."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.automation import AutomationActionType from homeassistant.components.automation import AutomationActionType
@ -32,7 +34,9 @@ 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, Any]]:
"""List device triggers for NEW_NAME devices.""" """List device triggers for NEW_NAME devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
triggers = [] triggers = []