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
This commit is contained in:
J. Nick Koston 2024-02-04 08:15:51 -06:00 committed by GitHub
parent e877113b21
commit 2f724b042b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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