Provide slight speedup to Guardian device lookup during service call (#77004)
* Provide slight speedup to Guardian device lookup during service call * Messages
This commit is contained in:
parent
6d49362573
commit
dd109839b9
1 changed files with 9 additions and 5 deletions
|
@ -103,12 +103,16 @@ def async_get_entry_id_for_service_call(hass: HomeAssistant, call: ServiceCall)
|
||||||
device_id = call.data[CONF_DEVICE_ID]
|
device_id = call.data[CONF_DEVICE_ID]
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
|
|
||||||
if device_entry := device_registry.async_get(device_id):
|
if (device_entry := device_registry.async_get(device_id)) is None:
|
||||||
for entry in hass.config_entries.async_entries(DOMAIN):
|
raise ValueError(f"Invalid Guardian device ID: {device_id}")
|
||||||
if entry.entry_id in device_entry.config_entries:
|
|
||||||
return entry.entry_id
|
|
||||||
|
|
||||||
raise ValueError(f"No client for device ID: {device_id}")
|
for entry_id in device_entry.config_entries:
|
||||||
|
if (entry := hass.config_entries.async_get_entry(entry_id)) is None:
|
||||||
|
continue
|
||||||
|
if entry.domain == DOMAIN:
|
||||||
|
return entry_id
|
||||||
|
|
||||||
|
raise ValueError(f"No config entry for device ID: {device_id}")
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue