Reorg device automation (#26880)
* async_trigger -> async_attach_trigger * Reorg device automations * Update docstrings * Fix types * Fix extending schemas
This commit is contained in:
parent
b52cfd3409
commit
6fdff9ffab
48 changed files with 2014 additions and 1771 deletions
33
homeassistant/components/light/device_trigger.py
Normal file
33
homeassistant/components/light/device_trigger.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""Provides device trigger for lights."""
|
||||
from typing import List
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import HomeAssistant, CALLBACK_TYPE
|
||||
from homeassistant.components.automation import AutomationActionType
|
||||
from homeassistant.components.device_automation import toggle_entity
|
||||
from homeassistant.const import CONF_DOMAIN
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from . import DOMAIN
|
||||
|
||||
|
||||
TRIGGER_SCHEMA = toggle_entity.TRIGGER_SCHEMA.extend(
|
||||
{vol.Required(CONF_DOMAIN): DOMAIN}
|
||||
)
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
action: AutomationActionType,
|
||||
automation_info: dict,
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Listen for state changes based on configuration."""
|
||||
config = TRIGGER_SCHEMA(config)
|
||||
return await toggle_entity.async_attach_trigger(
|
||||
hass, config, action, automation_info
|
||||
)
|
||||
|
||||
|
||||
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]:
|
||||
"""List device triggers."""
|
||||
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
|
Loading…
Add table
Add a link
Reference in a new issue