added dict get() instead of assuming keys exist; now handles config_flow setup failures without crashing
This commit is contained in:
committed by
rospogrigio
parent
7b37f07fd0
commit
d2fa4dc2a0
@@ -124,8 +124,10 @@ def async_config_entry_by_device_id(hass, device_id):
|
||||
"""Look up config entry by device id."""
|
||||
current_entries = hass.config_entries.async_entries(DOMAIN)
|
||||
for entry in current_entries:
|
||||
if device_id in entry.data[CONF_DEVICES]:
|
||||
if device_id in entry.data.get(CONF_DEVICES, []):
|
||||
return entry
|
||||
else:
|
||||
_LOGGER.warning(f"Missing device configuration for device_id {device_id}")
|
||||
return None
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user