2019-06-11 00:36:11 +02:00
|
|
|
"""Offer device oriented automation."""
|
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
from homeassistant.const import CONF_DOMAIN, CONF_PLATFORM
|
|
|
|
from homeassistant.loader import async_get_integration
|
|
|
|
|
|
|
|
|
2019-08-12 06:38:18 +03:00
|
|
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
|
|
|
|
2019-07-31 12:25:30 -07:00
|
|
|
TRIGGER_SCHEMA = vol.Schema(
|
|
|
|
{vol.Required(CONF_PLATFORM): "device", vol.Required(CONF_DOMAIN): str},
|
|
|
|
extra=vol.ALLOW_EXTRA,
|
|
|
|
)
|
2019-06-11 00:36:11 +02:00
|
|
|
|
|
|
|
|
2019-09-24 14:57:05 -07:00
|
|
|
async def async_attach_trigger(hass, config, action, automation_info):
|
2019-06-11 00:36:11 +02:00
|
|
|
"""Listen for trigger."""
|
|
|
|
integration = await async_get_integration(hass, config[CONF_DOMAIN])
|
2019-09-24 14:57:05 -07:00
|
|
|
platform = integration.get_platform("device_trigger")
|
|
|
|
return await platform.async_attach_trigger(hass, config, action, automation_info)
|