Validate device trigger schemas once (#48319)
This commit is contained in:
parent
de1fa706a0
commit
72281f4718
16 changed files with 0 additions and 26 deletions
|
@ -131,8 +131,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "triggered":
|
if config[CONF_TYPE] == "triggered":
|
||||||
to_state = STATE_ALARM_TRIGGERED
|
to_state = STATE_ALARM_TRIGGERED
|
||||||
elif config[CONF_TYPE] == "disarmed":
|
elif config[CONF_TYPE] == "disarmed":
|
||||||
|
|
|
@ -56,7 +56,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
job = HassJob(action)
|
job = HassJob(action)
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turn_on":
|
if config[CONF_TYPE] == "turn_on":
|
||||||
|
|
|
@ -113,7 +113,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
trigger_type = config[CONF_TYPE]
|
trigger_type = config[CONF_TYPE]
|
||||||
|
|
||||||
if trigger_type == "hvac_mode_changed":
|
if trigger_type == "hvac_mode_changed":
|
||||||
|
|
|
@ -170,8 +170,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] in STATE_TRIGGER_TYPES:
|
if config[CONF_TYPE] in STATE_TRIGGER_TYPES:
|
||||||
if config[CONF_TYPE] == "opened":
|
if config[CONF_TYPE] == "opened":
|
||||||
to_state = STATE_OPEN
|
to_state = STATE_OPEN
|
||||||
|
|
|
@ -71,8 +71,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "enters":
|
if config[CONF_TYPE] == "enters":
|
||||||
event = zone.EVENT_ENTER
|
event = zone.EVENT_ENTER
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -71,8 +71,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turned_on":
|
if config[CONF_TYPE] == "turned_on":
|
||||||
to_state = STATE_ON
|
to_state = STATE_ON
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -257,8 +257,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
device_id = config[CONF_DEVICE_ID]
|
device_id = config[CONF_DEVICE_ID]
|
||||||
device = hass.data[TRIGGERS][device_id]
|
device = hass.data[TRIGGERS][device_id]
|
||||||
return await device.async_attach_trigger(config, action, automation_info)
|
return await device.async_attach_trigger(config, action, automation_info)
|
||||||
|
|
|
@ -84,8 +84,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turn_on":
|
if config[CONF_TYPE] == "turn_on":
|
||||||
return _attach_trigger(hass, config, action, EVENT_TURN_ON)
|
return _attach_trigger(hass, config, action, EVENT_TURN_ON)
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "locked":
|
if config[CONF_TYPE] == "locked":
|
||||||
to_state = STATE_LOCKED
|
to_state = STATE_LOCKED
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -66,8 +66,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turned_on":
|
if config[CONF_TYPE] == "turned_on":
|
||||||
to_state = STATE_ON
|
to_state = STATE_ON
|
||||||
elif config[CONF_TYPE] == "turned_off":
|
elif config[CONF_TYPE] == "turned_off":
|
||||||
|
|
|
@ -319,7 +319,6 @@ async def async_attach_trigger(
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
if DEVICE_TRIGGERS not in hass.data:
|
if DEVICE_TRIGGERS not in hass.data:
|
||||||
hass.data[DEVICE_TRIGGERS] = {}
|
hass.data[DEVICE_TRIGGERS] = {}
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
device_id = config[CONF_DEVICE_ID]
|
device_id = config[CONF_DEVICE_ID]
|
||||||
discovery_id = config[CONF_DISCOVERY_ID]
|
discovery_id = config[CONF_DISCOVERY_ID]
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
event_config = event_trigger.TRIGGER_SCHEMA(
|
event_config = event_trigger.TRIGGER_SCHEMA(
|
||||||
{
|
{
|
||||||
event_trigger.CONF_PLATFORM: "event",
|
event_trigger.CONF_PLATFORM: "event",
|
||||||
|
|
|
@ -125,8 +125,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||||
device = device_registry.async_get(config[CONF_DEVICE_ID])
|
device = device_registry.async_get(config[CONF_DEVICE_ID])
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
event_config = {
|
event_config = {
|
||||||
event_trigger.CONF_PLATFORM: CONF_EVENT,
|
event_trigger.CONF_PLATFORM: CONF_EVENT,
|
||||||
event_trigger.CONF_EVENT_TYPE: EVENT_SHELLY_CLICK,
|
event_trigger.CONF_EVENT_TYPE: EVENT_SHELLY_CLICK,
|
||||||
|
|
|
@ -273,7 +273,6 @@ async def async_attach_trigger(
|
||||||
"""Attach a device trigger."""
|
"""Attach a device trigger."""
|
||||||
if DEVICE_TRIGGERS not in hass.data:
|
if DEVICE_TRIGGERS not in hass.data:
|
||||||
hass.data[DEVICE_TRIGGERS] = {}
|
hass.data[DEVICE_TRIGGERS] = {}
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
device_id = config[CONF_DEVICE_ID]
|
device_id = config[CONF_DEVICE_ID]
|
||||||
discovery_id = config[CONF_DISCOVERY_ID]
|
discovery_id = config[CONF_DISCOVERY_ID]
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,6 @@ async def async_attach_trigger(
|
||||||
automation_info: dict,
|
automation_info: dict,
|
||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] == "cleaning":
|
if config[CONF_TYPE] == "cleaning":
|
||||||
to_state = STATE_CLEANING
|
to_state = STATE_CLEANING
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue