Reorg device automation (#26880)
* async_trigger -> async_attach_trigger * Reorg device automations * Update docstrings * Fix types * Fix extending schemas
This commit is contained in:
1 parent
b52cfd3409
commit
6fdff9ffab
48 files changed
+2014
-1771
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""Provides device actions for switches."""
|
||||
from typing import List
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import HomeAssistant, Context
|
||||
from homeassistant.components.device_automation import toggle_entity
|
||||
from homeassistant.const import CONF_DOMAIN
|
||||
from homeassistant.helpers.typing import TemplateVarsType, ConfigType
|
||||
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."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
await toggle_entity.async_call_action_from_config(
|
||||
hass, config, variables, context, DOMAIN
|
||||
)
|
||||
|
||||
|
||||
async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]:
|
||||
"""List device actions."""
|
||||
return await toggle_entity.async_get_actions(hass, device_id, DOMAIN)
|
||||
Reference in new issue
Block a user