mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 17:31:15 -04:00
Use get_device_and_config_entry_for_domain in unifi_access (#180116)
This commit is contained in:
@@ -53,22 +53,19 @@ def _async_get_target(
|
||||
hass: HomeAssistant, call: ServiceCall
|
||||
) -> tuple[UnifiAccessConfigEntry, str]:
|
||||
"""Resolve a service call to a UniFi Access config entry and door ID."""
|
||||
device_registry = dr.async_get(hass)
|
||||
device_id = call.data[ATTR_DEVICE_ID]
|
||||
if (device := device_registry.async_get(device_id)) is None:
|
||||
device, entry = dr.async_get_device_and_config_entry_for_domain(
|
||||
hass, device_id, domain=DOMAIN
|
||||
)
|
||||
if device is None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="invalid_target",
|
||||
)
|
||||
|
||||
for entry_id in device.config_entries:
|
||||
if (
|
||||
entry := hass.config_entries.async_get_entry(entry_id)
|
||||
) is None or entry.domain != DOMAIN:
|
||||
continue
|
||||
|
||||
if entry is not None:
|
||||
config_entry: UnifiAccessConfigEntry = service.async_get_config_entry(
|
||||
hass, DOMAIN, entry_id
|
||||
hass, DOMAIN, entry.entry_id
|
||||
)
|
||||
coordinator = config_entry.runtime_data
|
||||
for identifier_domain, identifier_value in device.identifiers:
|
||||
|
||||
Reference in New Issue
Block a user