From 2728ba35b97022189a7018f1892a7e5f9bbfbe27 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 25 Aug 2026 19:40:43 +0200 Subject: [PATCH] Use async_get_device_and_config_entry service helper in reolink (#180160) --- homeassistant/components/reolink/services.py | 21 +++---------------- homeassistant/components/reolink/strings.json | 3 --- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/reolink/services.py b/homeassistant/components/reolink/services.py index 4e62d06bd4bc..d7e38d45e5c5 100644 --- a/homeassistant/components/reolink/services.py +++ b/homeassistant/components/reolink/services.py @@ -5,15 +5,10 @@ from reolink_aio.enums import ChimeToneEnum import voluptuous as vol from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN -from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_DEVICE_ID from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ServiceValidationError -from homeassistant.helpers import ( - config_validation as cv, - device_registry as dr, - service, -) +from homeassistant.helpers import config_validation as cv, service from .const import DOMAIN, SUPPORT_PTZ_SPEED from .host import ReolinkHost @@ -30,19 +25,9 @@ async def _async_play_chime(service_call: ServiceCall) -> None: service_data = service_call.data for device_id in service_data[ATTR_DEVICE_ID]: - device, config_entry = dr.async_get_device_and_config_entry_for_domain( - service_call.hass, device_id, domain=DOMAIN + device, config_entry = service.async_get_device_and_config_entry( + service_call.hass, DOMAIN, device_id ) - if ( - config_entry is None - or device is None - or config_entry.state is not ConfigEntryState.LOADED - ): - raise ServiceValidationError( - translation_domain=DOMAIN, - translation_key="service_entry_ex", - translation_placeholders={"service_name": "play_chime"}, - ) host: ReolinkHost = config_entry.runtime_data.host (_device_uid, chime_id, is_chime) = get_device_uid_and_ch(device, host) chime: Chime | None = host.api.chime(chime_id) diff --git a/homeassistant/components/reolink/strings.json b/homeassistant/components/reolink/strings.json index 63b41b2f97f6..e0fbf84ba3f2 100644 --- a/homeassistant/components/reolink/strings.json +++ b/homeassistant/components/reolink/strings.json @@ -939,9 +939,6 @@ "not_supported": { "message": "Function not supported by this device: {err}" }, - "service_entry_ex": { - "message": "Reolink {service_name} error: config entry not found or not loaded" - }, "service_not_chime": { "message": "Reolink play_chime error: {device_name} is not a Chime" },