From b00ccf98f03803528393f6212cf8c6d2ee16f0ca Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 27 Apr 2021 11:19:21 +0200 Subject: [PATCH] TP Link: Don't report HS when in CT mode (#49704) * TP Link: Don't report HS when in CT mode * Update tests --- homeassistant/components/tplink/light.py | 2 +- tests/components/tplink/test_light.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tplink/light.py b/homeassistant/components/tplink/light.py index 0d9db7ba108..61123bd6353 100644 --- a/homeassistant/components/tplink/light.py +++ b/homeassistant/components/tplink/light.py @@ -354,7 +354,7 @@ class TPLinkSmartBulb(LightEntity): ): color_temp = kelvin_to_mired(light_state_params[LIGHT_STATE_COLOR_TEMP]) - if light_features.supported_features & SUPPORT_COLOR: + if color_temp is None and light_features.supported_features & SUPPORT_COLOR: hue_saturation = ( light_state_params[LIGHT_STATE_HUE], light_state_params[LIGHT_STATE_SATURATION], diff --git a/tests/components/tplink/test_light.py b/tests/components/tplink/test_light.py index 5e81295468b..ea8809bc679 100644 --- a/tests/components/tplink/test_light.py +++ b/tests/components/tplink/test_light.py @@ -524,8 +524,8 @@ async def test_light(hass: HomeAssistant, light_mock_data: LightMockData) -> Non state = hass.states.get("light.light1") assert state.state == "on" assert state.attributes["brightness"] == 51 - assert state.attributes["hs_color"] == (110, 90) assert state.attributes["color_temp"] == 222 + assert "hs_color" not in state.attributes assert light_state["on_off"] == 1 await hass.services.async_call( @@ -541,6 +541,7 @@ async def test_light(hass: HomeAssistant, light_mock_data: LightMockData) -> Non assert state.state == "on" assert state.attributes["brightness"] == 56 assert state.attributes["hs_color"] == (23, 27) + assert "color_temp" not in state.attributes assert light_state["brightness"] == 22 assert light_state["hue"] == 23 assert light_state["saturation"] == 27 @@ -580,8 +581,8 @@ async def test_light(hass: HomeAssistant, light_mock_data: LightMockData) -> Non state = hass.states.get("light.light1") assert state.state == "on" assert state.attributes["brightness"] == 168 - assert state.attributes["hs_color"] == (77, 78) assert state.attributes["color_temp"] == 156 + assert "hs_color" not in state.attributes assert light_state["brightness"] == 66 assert light_state["hue"] == 77 assert light_state["saturation"] == 78