Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicate calls to color_supported and color_temp_supported in emulated_hue #104096

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions homeassistant/components/emulated_hue/hue_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down