diff --git a/homeassistant/components/teslemetry/services.py b/homeassistant/components/teslemetry/services.py index 7562c972ea0e..61ae8795d900 100644 --- a/homeassistant/components/teslemetry/services.py +++ b/homeassistant/components/teslemetry/services.py @@ -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",