diff --git a/homeassistant/components/climate/device_action.py b/homeassistant/components/climate/device_action.py index 6afc4d294cb519fa6e220ba0bd51d4cb262ee213..34217e8872de692978e134644a520843d8842f96 100644 --- a/homeassistant/components/climate/device_action.py +++ b/homeassistant/components/climate/device_action.py @@ -38,7 +38,9 @@ SET_PRESET_MODE_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend( ACTION_SCHEMA = vol.Any(SET_HVAC_MODE_SCHEMA, SET_PRESET_MODE_SCHEMA) -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 Climate devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] diff --git a/homeassistant/components/cover/device_action.py b/homeassistant/components/cover/device_action.py index 13ef4523f5b7a43c8525015dbb632baa3f3b3117..debb2368cf2526e1c99828c89915338dbfd1a411 100644 --- a/homeassistant/components/cover/device_action.py +++ b/homeassistant/components/cover/device_action.py @@ -21,6 +21,7 @@ from homeassistant.core import Context, HomeAssistant from homeassistant.helpers import entity_registry import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import get_supported_features +from homeassistant.helpers.typing import ConfigType from . import ( ATTR_POSITION, @@ -58,7 +59,9 @@ POSITION_ACTION_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend( ACTION_SCHEMA = vol.Any(CMD_ACTION_SCHEMA, POSITION_ACTION_SCHEMA) -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 Cover devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] @@ -98,7 +101,9 @@ async def async_get_actions(hass: HomeAssistant, device_id: str) -> list[dict]: return actions -async def async_get_action_capabilities(hass: HomeAssistant, config: dict) -> dict: +async def async_get_action_capabilities( + hass: HomeAssistant, config: ConfigType +) -> dict[str, vol.Schema]: """List action capabilities.""" if config[CONF_TYPE] not in POSITION_ACTION_TYPES: return {} diff --git a/homeassistant/components/device_automation/toggle_entity.py b/homeassistant/components/device_automation/toggle_entity.py index cf41fc93d83f737971a61959ca528ec882b59b05..6ad2264b516c609994964aeb3e0bfb98d63a2f96 100644 --- a/homeassistant/components/device_automation/toggle_entity.py +++ b/homeassistant/components/device_automation/toggle_entity.py @@ -1,8 +1,6 @@ """Device automation helpers for toggle entity.""" from __future__ import annotations -from typing import Any - import voluptuous as vol from homeassistant.components.automation import AutomationActionType @@ -169,10 +167,13 @@ async def async_attach_trigger( async def _async_get_automations( - hass: HomeAssistant, device_id: str, automation_templates: list[dict], domain: str -) -> list[dict]: + hass: HomeAssistant, + device_id: str, + automation_templates: list[dict[str, str]], + domain: str, +) -> list[dict[str, str]]: """List device automations.""" - automations: list[dict[str, Any]] = [] + automations: list[dict[str, str]] = [] entity_registry = await hass.helpers.entity_registry.async_get_registry() entries = [ @@ -197,7 +198,7 @@ async def _async_get_automations( async def async_get_actions( hass: HomeAssistant, device_id: str, domain: str -) -> list[dict]: +) -> list[dict[str, str]]: """List device actions.""" return await _async_get_automations(hass, device_id, ENTITY_ACTIONS, domain) diff --git a/homeassistant/components/fan/device_action.py b/homeassistant/components/fan/device_action.py index ddf6a76d3c802372ad270be5f68d04c3bc0514de..0482c31b9291e537e5fd24ecd9ebf6b1125a0a66 100644 --- a/homeassistant/components/fan/device_action.py +++ b/homeassistant/components/fan/device_action.py @@ -28,7 +28,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 Fan devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] diff --git a/homeassistant/components/humidifier/device_action.py b/homeassistant/components/humidifier/device_action.py index 81df69382360b542acf447f7792b90183c4f847a..3ad4b22dcec2b1d4d92131f5f7df87b2b878f4c7 100644 --- a/homeassistant/components/humidifier/device_action.py +++ b/homeassistant/components/humidifier/device_action.py @@ -19,6 +19,8 @@ from homeassistant.helpers.entity import get_capability, get_supported_features from . import DOMAIN, const +# mypy: disallow-any-generics + SET_HUMIDITY_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend( { vol.Required(CONF_TYPE): "set_humidity", @@ -40,7 +42,9 @@ ONOFF_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DO ACTION_SCHEMA = vol.Any(SET_HUMIDITY_SCHEMA, SET_MODE_SCHEMA, ONOFF_SCHEMA) -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 Humidifier devices.""" registry = await entity_registry.async_get_registry(hass) actions = await toggle_entity.async_get_actions(hass, device_id, DOMAIN) diff --git a/homeassistant/components/light/device_action.py b/homeassistant/components/light/device_action.py index 2180bdd30943e4753386dd8b6f1cd002d18f7489..a933d04066e0a57488e1193a33eb64f724d55cde 100644 --- a/homeassistant/components/light/device_action.py +++ b/homeassistant/components/light/device_action.py @@ -32,6 +32,8 @@ from . import ( get_supported_color_modes, ) +# mypy: disallow-any-generics + TYPE_BRIGHTNESS_INCREASE = "brightness_increase" TYPE_BRIGHTNESS_DECREASE = "brightness_decrease" TYPE_FLASH = "flash" @@ -86,7 +88,9 @@ async def async_call_action_from_config( ) -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.""" actions = await toggle_entity.async_get_actions(hass, device_id, DOMAIN) @@ -119,7 +123,9 @@ async def async_get_actions(hass: HomeAssistant, device_id: str) -> list[dict]: return actions -async def async_get_action_capabilities(hass: HomeAssistant, config: dict) -> dict: +async def async_get_action_capabilities( + hass: HomeAssistant, config: ConfigType +) -> dict[str, vol.Schema]: """List action capabilities.""" if config[CONF_TYPE] != toggle_entity.CONF_TURN_ON: return {} diff --git a/homeassistant/components/lock/device_action.py b/homeassistant/components/lock/device_action.py index 6c0eb2a41d4085dea2a615fbe4732f9376c70756..50c205d113ade7df581a770b310ad155b2173594 100644 --- a/homeassistant/components/lock/device_action.py +++ b/homeassistant/components/lock/device_action.py @@ -30,7 +30,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 Lock devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] diff --git a/homeassistant/components/mobile_app/device_action.py b/homeassistant/components/mobile_app/device_action.py index 33a7510da2149af003ae6b3dbb1808f07d2c8902..193c25e482c3d30ef9618e80b0a2f8c4e90b19ed 100644 --- a/homeassistant/components/mobile_app/device_action.py +++ b/homeassistant/components/mobile_app/device_action.py @@ -22,7 +22,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 Mobile App devices.""" webhook_id = webhook_id_from_device_id(hass, device_id) diff --git a/homeassistant/components/number/device_action.py b/homeassistant/components/number/device_action.py index 77b36b49f20a79c1db7e7657fab2cd8b8fe789e6..77ca633d947bec1b9fef43f0706d065cf41bfedf 100644 --- a/homeassistant/components/number/device_action.py +++ b/homeassistant/components/number/device_action.py @@ -1,8 +1,6 @@ """Provides device actions for Number.""" from __future__ import annotations -from typing import Any - import voluptuous as vol from homeassistant.const import ( @@ -15,6 +13,7 @@ from homeassistant.const import ( from homeassistant.core import Context, HomeAssistant from homeassistant.helpers import entity_registry import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import ConfigType from . import DOMAIN, const @@ -29,10 +28,12 @@ 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 Number.""" registry = await entity_registry.async_get_registry(hass) - actions: list[dict[str, Any]] = [] + actions: list[dict[str, str]] = [] # Get all the integrations entities for this device for entry in entity_registry.async_entries_for_device(registry, device_id): @@ -67,7 +68,9 @@ async def async_call_action_from_config( ) -async def async_get_action_capabilities(hass: HomeAssistant, config: dict) -> dict: +async def async_get_action_capabilities( + hass: HomeAssistant, config: ConfigType +) -> dict[str, vol.Schema]: """List action capabilities.""" fields = {vol.Required(const.ATTR_VALUE): vol.Coerce(float)} diff --git a/homeassistant/components/remote/device_action.py b/homeassistant/components/remote/device_action.py index aa34eb33224c201c321278b98444a8d464e0eb4d..a337f3275eb7bd3c3602422593176dd5e882888c 100644 --- a/homeassistant/components/remote/device_action.py +++ b/homeassistant/components/remote/device_action.py @@ -10,6 +10,8 @@ from homeassistant.helpers.typing import ConfigType, TemplateVarsType from . import DOMAIN +# mypy: disallow-any-generics + ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN}) @@ -25,6 +27,8 @@ async def async_call_action_from_config( ) -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.""" return await toggle_entity.async_get_actions(hass, device_id, DOMAIN) diff --git a/homeassistant/components/select/device_action.py b/homeassistant/components/select/device_action.py index ece3c981690422477ecc731f1b4e33f815cab330..ca9c1963782b16ab7f991e22ad5c56fc070e358c 100644 --- a/homeassistant/components/select/device_action.py +++ b/homeassistant/components/select/device_action.py @@ -1,8 +1,6 @@ """Provides device actions for Select.""" from __future__ import annotations -from typing import Any - import voluptuous as vol from homeassistant.const import ( @@ -31,7 +29,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 Select devices.""" registry = await entity_registry.async_get_registry(hass) return [ @@ -64,7 +64,7 @@ async def async_call_action_from_config( async def async_get_action_capabilities( hass: HomeAssistant, config: ConfigType -) -> dict[str, Any]: +) -> dict[str, vol.Schema]: """List action capabilities.""" try: options = get_capability(hass, config[CONF_ENTITY_ID], ATTR_OPTIONS) or [] diff --git a/homeassistant/components/switch/device_action.py b/homeassistant/components/switch/device_action.py index 0f3890d329ff3a4dba5092f183032195a133291c..6947656406b516db47782b5a3ced558eb56e8c40 100644 --- a/homeassistant/components/switch/device_action.py +++ b/homeassistant/components/switch/device_action.py @@ -10,6 +10,8 @@ from homeassistant.helpers.typing import ConfigType, TemplateVarsType from . import DOMAIN +# mypy: disallow-any-generics + ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN}) @@ -25,6 +27,8 @@ async def async_call_action_from_config( ) -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.""" return await toggle_entity.async_get_actions(hass, device_id, DOMAIN) diff --git a/homeassistant/components/vacuum/device_action.py b/homeassistant/components/vacuum/device_action.py index a4df68c3b936b6de5ef104898529f8345759f7b8..702f3fe7439679d8d53000a16f791f46d496fa6b 100644 --- a/homeassistant/components/vacuum/device_action.py +++ b/homeassistant/components/vacuum/device_action.py @@ -26,7 +26,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 Vacuum devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] diff --git a/homeassistant/components/water_heater/device_action.py b/homeassistant/components/water_heater/device_action.py index 3662dee9a5edbbd3f2449ef08ec6b8467816393b..dae9e4d579be477fd815690fdc2dc3268013dd2e 100644 --- a/homeassistant/components/water_heater/device_action.py +++ b/homeassistant/components/water_heater/device_action.py @@ -28,7 +28,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 Water Heater devices.""" registry = await entity_registry.async_get_registry(hass) actions = [] diff --git a/homeassistant/components/zha/device_action.py b/homeassistant/components/zha/device_action.py index de39ff50511fe7d2b521f45565cfa0d540ca38e3..36696517eb6ae71680e0963c8324c7a1dfefaecf 100644 --- a/homeassistant/components/zha/device_action.py +++ b/homeassistant/components/zha/device_action.py @@ -13,6 +13,8 @@ from .api import SERVICE_WARNING_DEVICE_SQUAWK, SERVICE_WARNING_DEVICE_WARN from .core.const import CHANNEL_IAS_WD from .core.helpers import async_get_zha_device +# mypy: disallow-any-generics + ACTION_SQUAWK = "squawk" ACTION_WARN = "warn" ATTR_DATA = "data" @@ -54,7 +56,9 @@ async def async_call_action_from_config( ) -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.""" try: zha_device = await async_get_zha_device(hass, device_id) diff --git a/script/scaffold/templates/device_action/integration/device_action.py b/script/scaffold/templates/device_action/integration/device_action.py index 720e472851c24b58038cdfbb32b3d8815e2f671c..5eb5249211b8200285d2cf0a850d7efd0b24b91c 100644 --- a/script/scaffold/templates/device_action/integration/device_action.py +++ b/script/scaffold/templates/device_action/integration/device_action.py @@ -29,7 +29,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 NEW_NAME devices.""" registry = await entity_registry.async_get_registry(hass) actions = []