mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Provide slight speedup to RainMachine device lookup during service call (#76944)
Fix
This commit is contained in:
parent
655e2f92ba
commit
c3305caabe
@ -159,11 +159,15 @@ def async_get_controller_for_service_call(
|
||||
device_id = call.data[CONF_DEVICE_ID]
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
if device_entry := device_registry.async_get(device_id):
|
||||
for entry in hass.config_entries.async_entries(DOMAIN):
|
||||
if entry.entry_id in device_entry.config_entries:
|
||||
data: RainMachineData = hass.data[DOMAIN][entry.entry_id]
|
||||
return data.controller
|
||||
if (device_entry := device_registry.async_get(device_id)) is None:
|
||||
raise ValueError(f"Invalid RainMachine 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:
|
||||
data: RainMachineData = hass.data[DOMAIN][entry_id]
|
||||
return data.controller
|
||||
|
||||
raise ValueError(f"No controller for device ID: {device_id}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user