From 2f724b042b71ae098a0411a76fb2954fa4172033 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 4 Feb 2024 08:15:51 -0600 Subject: [PATCH] Avoid looking up services to check if they support responses (#109588) We already have the Service object as its the value in the services_map so there is not need to look it up again --- homeassistant/helpers/service.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 30516e3a099..3fe0c0eb086 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -640,7 +640,7 @@ async def async_get_all_descriptions( descriptions[domain] = {} domain_descriptions = descriptions[domain] - for service_name in services_map: + for service_name, service in services_map.items(): cache_key = (domain, service_name) description = descriptions_cache.get(cache_key) if description is not None: @@ -695,11 +695,10 @@ async def async_get_all_descriptions( if "target" in yaml_description: description["target"] = yaml_description["target"] - if ( - response := hass.services.supports_response(domain, service_name) - ) != SupportsResponse.NONE: + response = service.supports_response + if response is not SupportsResponse.NONE: description["response"] = { - "optional": response == SupportsResponse.OPTIONAL, + "optional": response is SupportsResponse.OPTIONAL, } descriptions_cache[cache_key] = description