Reorganize trigger code (#38655)

This commit is contained in:
Phil Bruckner authored and GitHub committed 2020-08-17 11:54:56 -05:00
1 parent fca071742d
commit ca9dd0c833
51 files changed
+306 -194

No files matched your search

@@ -3,8 +3,9 @@ from typing import List
import voluptuous as vol
from homeassistant.components.automation import AutomationActionType, state
from homeassistant.components.automation import AutomationActionType
from homeassistant.components.device_automation import TRIGGER_BASE_SCHEMA
from homeassistant.components.homeassistant.triggers import state as state_trigger
from homeassistant.const import (
CONF_DEVICE_ID,
CONF_DOMAIN,
@@ -80,12 +81,12 @@ async def async_attach_trigger(
to_state = STATE_UNLOCKED
state_config = {
state.CONF_PLATFORM: "state",
CONF_PLATFORM: "state",
CONF_ENTITY_ID: config[CONF_ENTITY_ID],
state.CONF_FROM: from_state,
state.CONF_TO: to_state,
state_trigger.CONF_FROM: from_state,
state_trigger.CONF_TO: to_state,
}
state_config = state.TRIGGER_SCHEMA(state_config)
return await state.async_attach_trigger(
state_config = state_trigger.TRIGGER_SCHEMA(state_config)
return await state_trigger.async_attach_trigger(
hass, state_config, action, automation_info, platform_type="device"
)