From 89893cd1603b225321d6140df81c6d035cb869df Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 25 Aug 2026 09:13:36 +0200 Subject: [PATCH] Use get_device_and_config_entry_for_domain in octoprint (#180102) --- homeassistant/components/octoprint/services.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/octoprint/services.py b/homeassistant/components/octoprint/services.py index 8f6085dcc57f..22f6cb0e71b0 100644 --- a/homeassistant/components/octoprint/services.py +++ b/homeassistant/components/octoprint/services.py @@ -29,13 +29,12 @@ def async_get_client_for_service_call( ) -> OctoprintClient: """Get the client related to a service call (by device ID).""" device_id = call.data[CONF_DEVICE_ID] - device_registry = dr.async_get(hass) - if device_entry := device_registry.async_get(device_id): - for entry_id in device_entry.config_entries: - if entry := hass.config_entries.async_get_entry(entry_id): - if entry.domain == DOMAIN and entry.state is ConfigEntryState.LOADED: - return cast(OctoprintConfigEntry, entry).runtime_data.octoprint + _, config_entry = dr.async_get_device_and_config_entry_for_domain( + hass, device_id, domain=DOMAIN + ) + if config_entry is not None and config_entry.state is ConfigEntryState.LOADED: + return cast(OctoprintConfigEntry, config_entry).runtime_data.octoprint raise ServiceValidationError( translation_domain=DOMAIN,