Adjust device_automation type hints in core platforms 3/3 (#72211)
This commit is contained in:
parent
571c90b8cf
commit
b10ee779f9
12 changed files with 44 additions and 26 deletions
|
@ -19,7 +19,7 @@ async def async_call_action_from_config(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
variables: TemplateVarsType,
|
variables: TemplateVarsType,
|
||||||
context: Context,
|
context: Context | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Change state based on configuration."""
|
"""Change state based on configuration."""
|
||||||
await toggle_entity.async_call_action_from_config(
|
await toggle_entity.async_call_action_from_config(
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""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 (
|
from homeassistant.components.automation import (
|
||||||
|
@ -36,7 +34,7 @@ async def async_attach_trigger(
|
||||||
|
|
||||||
async def async_get_triggers(
|
async def async_get_triggers(
|
||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, str]]:
|
||||||
"""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)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import get_capability
|
from homeassistant.helpers.entity import get_capability
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||||
|
|
||||||
from .const import ATTR_OPTION, ATTR_OPTIONS, CONF_OPTION, DOMAIN, SERVICE_SELECT_OPTION
|
from .const import ATTR_OPTION, ATTR_OPTIONS, CONF_OPTION, DOMAIN, SERVICE_SELECT_OPTION
|
||||||
|
|
||||||
|
@ -48,7 +48,10 @@ async def async_get_actions(
|
||||||
|
|
||||||
|
|
||||||
async def async_call_action_from_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:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Provides device triggers for Select."""
|
"""Provides device triggers for Select."""
|
||||||
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 (
|
from homeassistant.components.automation import (
|
||||||
|
@ -47,7 +45,7 @@ TRIGGER_SCHEMA = 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, Any]]:
|
) -> list[dict[str, str]]:
|
||||||
"""List device triggers for Select devices."""
|
"""List device triggers for Select devices."""
|
||||||
registry = entity_registry.async_get(hass)
|
registry = entity_registry.async_get(hass)
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -195,7 +195,9 @@ def async_condition_from_config(
|
||||||
return condition.async_numeric_state_from_config(numeric_state_config)
|
return condition.async_numeric_state_from_config(numeric_state_config)
|
||||||
|
|
||||||
|
|
||||||
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."""
|
"""List condition capabilities."""
|
||||||
try:
|
try:
|
||||||
unit_of_measurement = get_unit_of_measurement(hass, config[CONF_ENTITY_ID])
|
unit_of_measurement = get_unit_of_measurement(hass, config[CONF_ENTITY_ID])
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
"""Provides device triggers for sensors."""
|
"""Provides device triggers for sensors."""
|
||||||
import voluptuous as vol
|
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
|
||||||
from homeassistant.components.device_automation.exceptions import (
|
from homeassistant.components.device_automation.exceptions import (
|
||||||
InvalidDeviceAutomationConfig,
|
InvalidDeviceAutomationConfig,
|
||||||
|
@ -15,6 +19,7 @@ from homeassistant.const import (
|
||||||
CONF_FOR,
|
CONF_FOR,
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||||
from homeassistant.helpers.entity import (
|
from homeassistant.helpers.entity import (
|
||||||
|
@ -22,6 +27,7 @@ from homeassistant.helpers.entity import (
|
||||||
get_device_class,
|
get_device_class,
|
||||||
get_unit_of_measurement,
|
get_unit_of_measurement,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from . import ATTR_STATE_CLASS, DOMAIN, SensorDeviceClass
|
from . import ATTR_STATE_CLASS, DOMAIN, SensorDeviceClass
|
||||||
|
|
||||||
|
@ -134,7 +140,12 @@ TRIGGER_SCHEMA = vol.All(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_attach_trigger(hass, config, action, automation_info):
|
async def async_attach_trigger(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
action: AutomationActionType,
|
||||||
|
automation_info: AutomationTriggerInfo,
|
||||||
|
) -> CALLBACK_TYPE:
|
||||||
"""Listen for state changes based on configuration."""
|
"""Listen for state changes based on configuration."""
|
||||||
numeric_state_config = {
|
numeric_state_config = {
|
||||||
numeric_state_trigger.CONF_PLATFORM: "numeric_state",
|
numeric_state_trigger.CONF_PLATFORM: "numeric_state",
|
||||||
|
@ -155,9 +166,11 @@ async def async_attach_trigger(hass, config, action, automation_info):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_get_triggers(hass, device_id):
|
async def async_get_triggers(
|
||||||
|
hass: HomeAssistant, device_id: str
|
||||||
|
) -> list[dict[str, str]]:
|
||||||
"""List device triggers."""
|
"""List device triggers."""
|
||||||
triggers = []
|
triggers: list[dict[str, str]] = []
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
entries = [
|
entries = [
|
||||||
|
@ -192,7 +205,9 @@ async def async_get_triggers(hass, device_id):
|
||||||
return triggers
|
return triggers
|
||||||
|
|
||||||
|
|
||||||
async def async_get_trigger_capabilities(hass, config):
|
async def async_get_trigger_capabilities(
|
||||||
|
hass: HomeAssistant, config: ConfigType
|
||||||
|
) -> dict[str, vol.Schema]:
|
||||||
"""List trigger capabilities."""
|
"""List trigger capabilities."""
|
||||||
try:
|
try:
|
||||||
unit_of_measurement = get_unit_of_measurement(hass, config[CONF_ENTITY_ID])
|
unit_of_measurement = get_unit_of_measurement(hass, config[CONF_ENTITY_ID])
|
||||||
|
|
|
@ -19,7 +19,7 @@ async def async_call_action_from_config(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
variables: TemplateVarsType,
|
variables: TemplateVarsType,
|
||||||
context: Context,
|
context: Context | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Change state based on configuration."""
|
"""Change state based on configuration."""
|
||||||
await toggle_entity.async_call_action_from_config(
|
await toggle_entity.async_call_action_from_config(
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""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 (
|
from homeassistant.components.automation import (
|
||||||
|
@ -36,7 +34,7 @@ async def async_attach_trigger(
|
||||||
|
|
||||||
async def async_get_triggers(
|
async def async_get_triggers(
|
||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, str]]:
|
||||||
"""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)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Provides device triggers for update entities."""
|
"""Provides device triggers for update entities."""
|
||||||
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 (
|
from homeassistant.components.automation import (
|
||||||
|
@ -36,7 +34,7 @@ async def async_attach_trigger(
|
||||||
|
|
||||||
async def async_get_triggers(
|
async def async_get_triggers(
|
||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, str]]:
|
||||||
"""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)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
||||||
from homeassistant.core import Context, HomeAssistant
|
from homeassistant.core import Context, HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||||
|
|
||||||
from . import DOMAIN, SERVICE_RETURN_TO_BASE, SERVICE_START
|
from . import DOMAIN, SERVICE_RETURN_TO_BASE, SERVICE_START
|
||||||
|
|
||||||
|
@ -51,7 +52,10 @@ async def async_get_actions(
|
||||||
|
|
||||||
|
|
||||||
async def async_call_action_from_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:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
config = ACTION_SCHEMA(config)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""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 (
|
from homeassistant.components.automation import (
|
||||||
|
@ -38,7 +36,7 @@ TRIGGER_SCHEMA = 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, Any]]:
|
) -> list[dict[str, str]]:
|
||||||
"""List device triggers for Vacuum devices."""
|
"""List device triggers for Vacuum devices."""
|
||||||
registry = entity_registry.async_get(hass)
|
registry = entity_registry.async_get(hass)
|
||||||
triggers = []
|
triggers = []
|
||||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.const import (
|
||||||
from homeassistant.core import Context, HomeAssistant
|
from homeassistant.core import Context, HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
|
|
||||||
|
@ -52,7 +53,10 @@ async def async_get_actions(
|
||||||
|
|
||||||
|
|
||||||
async def async_call_action_from_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:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue