Use get_device_and_config_entry_for_domain in teslemetry (#180115)

This commit is contained in:
Erik Montnemery
2026-08-25 10:30:30 +02:00
committed by GitHub
parent 3e0e171613
commit 9f0548f71c
@@ -88,10 +88,11 @@ def async_get_config_for_device(
hass: HomeAssistant, device_entry: dr.DeviceEntry
) -> TeslemetryConfigEntry:
"""Get the config entry related to a device entry."""
for entry_id in device_entry.config_entries:
if entry := hass.config_entries.async_get_entry(entry_id):
if entry.domain == DOMAIN:
return entry
_, config_entry = dr.async_get_device_and_config_entry_for_domain(
hass, device_entry.id, domain=DOMAIN
)
if config_entry:
return config_entry
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="no_config_entry_for_device",