Remove asserts from lutron_caseta async_attach_trigger (#74429)
This commit is contained in:
parent
2ee5ac02cf
commit
6422040262
1 changed files with 8 additions and 3 deletions
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
|||
CONF_TYPE,
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
|
@ -429,9 +430,13 @@ async def async_attach_trigger(
|
|||
) -> CALLBACK_TYPE:
|
||||
"""Attach a trigger."""
|
||||
device_registry = dr.async_get(hass)
|
||||
device = device_registry.async_get(config[CONF_DEVICE_ID])
|
||||
assert device
|
||||
assert device.model
|
||||
if (
|
||||
not (device := device_registry.async_get(config[CONF_DEVICE_ID]))
|
||||
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)
|
||||
_, serial = list(device.identifiers)[0]
|
||||
schema = DEVICE_TYPE_SCHEMA_MAP[device_type]
|
||||
|
|
Loading…
Add table
Reference in a new issue