Adjust device_automation type hints in core platforms 2/3 (#72210)
parent
b10ee779f9
commit
3a0e816f1b
|
@ -6,6 +6,7 @@ import voluptuous as vol
|
|||
from homeassistant.components.device_automation import toggle_entity
|
||||
from homeassistant.const import CONF_DOMAIN
|
||||
from homeassistant.core import Context, HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
|
@ -20,7 +21,10 @@ async def async_get_actions(
|
|||
|
||||
|
||||
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."""
|
||||
await toggle_entity.async_call_action_from_config(
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Provides device automations for Fan."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.automation import (
|
||||
|
@ -24,7 +22,7 @@ TRIGGER_SCHEMA = vol.All(
|
|||
|
||||
async def async_get_triggers(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, Any]]:
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers for Fan devices."""
|
||||
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Provides device actions for Humidifier."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_automation import toggle_entity
|
||||
|
@ -19,6 +17,7 @@ from homeassistant.exceptions import HomeAssistantError
|
|||
from homeassistant.helpers import entity_registry
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import get_capability, get_supported_features
|
||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
|
||||
from . import DOMAIN, const
|
||||
|
||||
|
@ -74,8 +73,8 @@ async def async_get_actions(
|
|||
|
||||
async def async_call_action_from_config(
|
||||
hass: HomeAssistant,
|
||||
config: dict[str, Any],
|
||||
variables: dict[str, Any],
|
||||
config: ConfigType,
|
||||
variables: TemplateVarsType,
|
||||
context: Context | None,
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
|
@ -97,7 +96,9 @@ async def async_call_action_from_config(
|
|||
)
|
||||
|
||||
|
||||
async def async_get_action_capabilities(hass, config):
|
||||
async def async_get_action_capabilities(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> dict[str, vol.Schema]:
|
||||
"""List action capabilities."""
|
||||
action_type = config[CONF_TYPE]
|
||||
|
||||
|
|
|
@ -85,7 +85,9 @@ def async_condition_from_config(
|
|||
return test_is_state
|
||||
|
||||
|
||||
async def async_get_condition_capabilities(hass, config):
|
||||
async def async_get_condition_capabilities(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> dict[str, vol.Schema]:
|
||||
"""List condition capabilities."""
|
||||
condition_type = config[CONF_TYPE]
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Provides device automations for Climate."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.automation import (
|
||||
|
@ -59,7 +57,7 @@ TRIGGER_SCHEMA = vol.All(
|
|||
|
||||
async def async_get_triggers(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, Any]]:
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers for Humidifier devices."""
|
||||
registry = entity_registry.async_get(hass)
|
||||
triggers = await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
|
||||
|
|
|
@ -55,7 +55,7 @@ async def async_call_action_from_config(
|
|||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
variables: TemplateVarsType,
|
||||
context: Context,
|
||||
context: Context | None,
|
||||
) -> None:
|
||||
"""Change state based on configuration."""
|
||||
if (
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Provides device trigger for lights."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.automation import (
|
||||
|
@ -36,7 +34,7 @@ async def async_attach_trigger(
|
|||
|
||||
async def async_get_triggers(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, Any]]:
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers."""
|
||||
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
|
||||
|
||||
|
|
|
@ -17,6 +17,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, TemplateVarsType
|
||||
|
||||
from . import DOMAIN, LockEntityFeature
|
||||
|
||||
|
@ -61,7 +62,10 @@ async def async_get_actions(
|
|||
|
||||
|
||||
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."""
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Provides device automations for Lock."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.automation import (
|
||||
|
@ -43,7 +41,7 @@ TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
|
|||
|
||||
async def async_get_triggers(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, Any]]:
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers for Lock devices."""
|
||||
registry = entity_registry.async_get(hass)
|
||||
triggers = []
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Provides device automations for Media player."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.automation import (
|
||||
|
@ -55,7 +53,7 @@ TRIGGER_SCHEMA = vol.All(
|
|||
|
||||
async def async_get_triggers(
|
||||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, Any]]:
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers for Media player entities."""
|
||||
registry = entity_registry.async_get(hass)
|
||||
triggers = await entity.async_get_triggers(hass, device_id, DOMAIN)
|
||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_TYPE
|
|||
from homeassistant.core import Context, HomeAssistant
|
||||
from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.helpers import config_validation as cv, template
|
||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
|
||||
from .const import DOMAIN
|
||||
from .util import get_notify_service, supports_push, webhook_id_from_device_id
|
||||
|
@ -36,7 +37,10 @@ async def async_get_actions(
|
|||
|
||||
|
||||
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."""
|
||||
webhook_id = webhook_id_from_device_id(hass, config[CONF_DEVICE_ID])
|
||||
|
@ -73,7 +77,9 @@ async def async_call_action_from_config(
|
|||
)
|
||||
|
||||
|
||||
async def async_get_action_capabilities(hass, config):
|
||||
async def async_get_action_capabilities(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> dict[str, vol.Schema]:
|
||||
"""List action capabilities."""
|
||||
if config[CONF_TYPE] != "notify":
|
||||
return {}
|
||||
|
|
|
@ -13,7 +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 homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
|
||||
from .const import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE
|
||||
|
||||
|
@ -53,7 +53,10 @@ async def async_get_actions(
|
|||
|
||||
|
||||
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."""
|
||||
await hass.services.async_call(
|
||||
|
|
Loading…
Reference in New Issue