mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove asserts from lutron_caseta async_attach_trigger (#74429)
This commit is contained in:
parent
2ee5ac02cf
commit
6422040262
@ -20,6 +20,7 @@ from homeassistant.const import (
|
|||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -429,9 +430,13 @@ async def async_attach_trigger(
|
|||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
device = device_registry.async_get(config[CONF_DEVICE_ID])
|
if (
|
||||||
assert device
|
not (device := device_registry.async_get(config[CONF_DEVICE_ID]))
|
||||||
assert device.model
|
or not device.model
|
||||||
|
):
|
||||||
|
raise HomeAssistantError(
|
||||||
|
f"Cannot attach trigger {config} because device with id {config[CONF_DEVICE_ID]} is missing or invalid"
|
||||||
|
)
|
||||||
device_type = _device_model_to_type(device.model)
|
device_type = _device_model_to_type(device.model)
|
||||||
_, serial = list(device.identifiers)[0]
|
_, serial = list(device.identifiers)[0]
|
||||||
schema = DEVICE_TYPE_SCHEMA_MAP[device_type]
|
schema = DEVICE_TYPE_SCHEMA_MAP[device_type]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user