2020-09-07 13:54:18 +00:00
|
|
|
"""Provides device actions for remotes."""
|
2021-03-18 13:31:38 +00:00
|
|
|
from __future__ import annotations
|
2020-09-07 13:54:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN})
|
|
|
|
|
|
|
|
|
|
|
|
async def async_call_action_from_config(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
config: ConfigType,
|
|
|
|
variables: TemplateVarsType,
|
|
|
|
context: Context,
|
|
|
|
) -> None:
|
|
|
|
"""Change state based on configuration."""
|
|
|
|
await toggle_entity.async_call_action_from_config(
|
|
|
|
hass, config, variables, context, DOMAIN
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-03-18 13:31:38 +00:00
|
|
|
async def async_get_actions(hass: HomeAssistant, device_id: str) -> list[dict]:
|
2020-09-07 13:54:18 +00:00
|
|
|
"""List device actions."""
|
|
|
|
return await toggle_entity.async_get_actions(hass, device_id, DOMAIN)
|