mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +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_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 RainMachine device ID: {device_id}")
|
||||||
if entry.entry_id in device_entry.config_entries:
|
|
||||||
data: RainMachineData = hass.data[DOMAIN][entry.entry_id]
|
for entry_id in device_entry.config_entries:
|
||||||
return data.controller
|
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}")
|
raise ValueError(f"No controller for device ID: {device_id}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user