From cf9299df59cbda8bdf3e4877a45eecce917576fb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 16 Nov 2023 23:22:13 -0600 Subject: [PATCH] Avoid duplicate calls to color_supported and color_temp_supported in emulated_hue (#104096) --- homeassistant/components/emulated_hue/hue_api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 4dbe5aa315e..ad6b0541cd6 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -772,7 +772,9 @@ def state_to_json(config: Config, state: State) -> dict[str, Any]: "swversion": "123", } - if light.color_supported(color_modes) and light.color_temp_supported(color_modes): + color_supported = light.color_supported(color_modes) + color_temp_supported = light.color_temp_supported(color_modes) + if color_supported and color_temp_supported: # Extended Color light (Zigbee Device ID: 0x0210) # Same as Color light, but which supports additional setting of color temperature retval["type"] = "Extended color light" @@ -790,7 +792,7 @@ def state_to_json(config: Config, state: State) -> dict[str, Any]: json_state[HUE_API_STATE_COLORMODE] = "hs" else: json_state[HUE_API_STATE_COLORMODE] = "ct" - elif light.color_supported(color_modes): + elif color_supported: # Color light (Zigbee Device ID: 0x0200) # Supports on/off, dimming and color control (hue/saturation, enhanced hue, color loop and XY) retval["type"] = "Color light" @@ -804,7 +806,7 @@ def state_to_json(config: Config, state: State) -> dict[str, Any]: HUE_API_STATE_EFFECT: "none", } ) - elif light.color_temp_supported(color_modes): + elif color_temp_supported: # Color temperature light (Zigbee Device ID: 0x0220) # Supports groups, scenes, on/off, dimming, and setting of a color temperature retval["type"] = "Color temperature light"