core/homeassistant/components/fan/device_trigger.py

39 lines
1.2 KiB
Python
Raw Normal View History

2019-11-07 11:38:58 +00:00
"""Provides device automations for Fan."""
2021-03-17 22:49:01 +00:00
from __future__ import annotations
2019-11-07 11:38:58 +00:00
import voluptuous as vol
2020-08-17 16:54:56 +00:00
from homeassistant.components.automation import AutomationActionType
from homeassistant.components.device_automation import toggle_entity
from homeassistant.const import CONF_DOMAIN
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
2019-11-07 11:38:58 +00:00
from homeassistant.helpers.typing import ConfigType
2019-11-07 11:38:58 +00:00
from . import DOMAIN
TRIGGER_SCHEMA = toggle_entity.TRIGGER_SCHEMA.extend(
{vol.Required(CONF_DOMAIN): DOMAIN}
2019-11-07 11:38:58 +00:00
)
2021-03-17 22:49:01 +00:00
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
2019-11-07 11:38:58 +00:00
"""List device triggers for Fan devices."""
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
2019-11-07 11:38:58 +00:00
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict:
"""List trigger capabilities."""
return await toggle_entity.async_get_trigger_capabilities(hass, config)
2019-11-07 11:38:58 +00:00
async def async_attach_trigger(
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: dict,
) -> CALLBACK_TYPE:
"""Listen for state changes based on configuration."""
return await toggle_entity.async_attach_trigger(
hass, config, action, automation_info
2019-11-07 11:38:58 +00:00
)