diff --git a/homeassistant/components/tuya/light.py b/homeassistant/components/tuya/light.py index aef9908c825..d070ffd038a 100644 --- a/homeassistant/components/tuya/light.py +++ b/homeassistant/components/tuya/light.py @@ -186,14 +186,14 @@ class _ColorDataWrapper(DPCodeJsonWrapper): ) def _convert_value_to_raw_value( - self, device: CustomerDevice, value: tuple[tuple[float, float], float] + self, device: CustomerDevice, value: tuple[float, float, float] ) -> Any: - """Convert a Home Assistant color/brightness pair back to a raw device value.""" - color, brightness = value + """Convert a Home Assistant tuple (H, S, V) back to a raw device value.""" + hue, saturation, brightness = value return json.dumps( { - "h": round(self.h_type.remap_value_from(color[0])), - "s": round(self.s_type.remap_value_from(color[1])), + "h": round(self.h_type.remap_value_from(hue)), + "s": round(self.s_type.remap_value_from(saturation)), "v": round(self.v_type.remap_value_from(brightness)), } ) diff --git a/tests/components/tuya/test_light.py b/tests/components/tuya/test_light.py index 37d70150d11..d0b541a0231 100644 --- a/tests/components/tuya/test_light.py +++ b/tests/components/tuya/test_light.py @@ -11,6 +11,7 @@ from tuya_sharing import CustomerDevice, Manager from homeassistant.components.light import ( ATTR_BRIGHTNESS, + ATTR_HS_COLOR, ATTR_WHITE, DOMAIN as LIGHT_DOMAIN, SERVICE_TURN_OFF, @@ -91,6 +92,18 @@ async def test_platform_setup_and_discovery( {"code": "bright_value_v2", "value": 592}, ], ), + ( + SERVICE_TURN_ON, + { + ATTR_BRIGHTNESS: 255, + ATTR_HS_COLOR: (10.1, 20.2), + }, + [ + {"code": "switch_led", "value": True}, + {"code": "work_mode", "value": "colour"}, + {"code": "colour_data_v2", "value": '{"h": 10, "s": 202, "v": 1000}'}, + ], + ), ( SERVICE_TURN_OFF, {},