Hue magic and tuya LSC


new to Node-RED, I'm gradually discovering the immense possibilities it offers. I've successfully integrated my Hue lights using Node Hue Magic, and everything is working correctly. I've also integrated non-Zigbee Tuya LSC devices using node-red-contrib-tuya-smart-device, and that's all fine too. However, I still have a question. I would like one of my Hue bulbs to be able to send its color state to a Tuya device to synchronize them together. I'm trying to retrieve the status of the Hue bulb, perhaps by creating a looptimer that fetches its status every 2 seconds and then sends it to the Tuya Wi-Fi device. Is this feasible?

If anyone has done this before, I'd appreciate your help in advance.

You probably do not need to fetch the status of your zigbee lamp as mine send an update whenever an attribute changes. So, as long as you have the details of how to translate the output data from the zigbee lamp to the input required by the Tuya lamp this should be fairly straightforward.

If you are trying to match colours, brightness etc. you will probably have to do some experimentation to get the lamp outputs to match.

I'm going to try some tests, but if someone has the conversion function, it would be helpful to me because I'm just starting out, and it doesn't seem so easy, but it will help me learn how to use Node-RED a bit more.

I'm not quite sure how to create a function that takes the payload from a Hue bulb and returns the brightness, color, and state of the bulb. I'm looking at the API

tuyapi 7.2.0 | Documentation

, but it doesn't seem to be working right now. I'll continue working on it tomorrow. Thank you.

I'm still unable to pair a Hue bulb and a Tuya LSC bulb with Node-RED, nothing is working. I would like the Tuya light to follow the colors and brightness of the Hue light. I've also tried with Home Assistant and the group light feature, but without success. I've seen a node that should do this called "node-red-contrib-light," but I don't quite understand how it works. If anyone has a concrete example of this, I'm stuck. Thank you.

If you supply the output from the Hue bulb - result in Node-RED (MQTT and debug node) and the required input to the Tuya bulb I will have a go

Thank you very much for looking into this. Regarding the Tuya input, I believe it's in the documentation I provided earlier. Otherwise, I'm not sure how to capture it. I might need a code to send for it. For the Hue, I received this code. {"on":true,"brightness":90.12,"brightnessLevel":229,"reachable":true,"connectionStatus":"connected","updated":"2023-09-17T23:47:44+02:00","rgb":[255,235,73],"hex":"ffeb49","xyColor":{"x":0.4524,"y":0.476},"color":"black","colorTemp":false,"colorTempName":"unknown"}

As you have installed the node-red-contrib-tuya-smart-device to get / set the Tuya bulb you should be able to control it by sending

msg.payload  = {"dps":"20","set":true}

and you should get back something like

{"data":{"dps":{"20":true},"t":1695071477},"deviceId":"bfed04c9d469db879doe2y","deviceName":"Smart Bulb 04"}

These are some of the DPs that work for my lamps

Version 3.3 - Light Type (RGB)
DPS Function  Point 	Type 		Range 						Units
20 	Switch 				bool 		True/False 	
21 	Mode 				enum 		white,colour,scene,music 	
22 	Bright 				integer 	10-1000						% * 10 	
23 	Color Temp 			integer 	0-1000 						1,000,000 / kelvins
24 	Color 				hexstring 	h:0-360,s:0-1000,v:0-1000 	hsv (s & v * 10)

this function converts an HSV colour to the hex string used by my Tuya lamps

	* Description	Converts an HSV colour value to Tuya hexadecimal colour.
	* 				Assumes Hue in set [0, 360], Saturation and Value in the set [0, 100] and
	* 				returns Tuya colour as 12 character hexadecimal string
	* @param   {Object | number} hue    - The hue as an integer or an HSV Object {hue, saturation, value})
	* @param   {number} [saturation]	- The saturation
	* @param   {number} [value]       	- The value
	* @returns {string}             	- A 12 character hexadecimal string as used by Tuya devices for colour
	* Note: To convert RGB colour to Tuya colour use RGBtoHSV() as input

	function HSVtoTuyaColour(hue, saturation, value) {
		// Note: hue = hue.hue MUST go last
		if (arguments.length === 1) {
			saturation = hue.saturation;
			value = hue.value;
			hue = hue.hue;


		// Increase saturation & value to correct set [0, 1000]
		saturation = saturation * 10;
		value = value * 10;

		return HSVtoHexStr(hue, saturation, value);

	} // End Function HSVtoTuyaColour()

You will need to convert the zigbee RGB colour to HSV

Okay, thank you very much. I will try to understand all of this first. Yes, I have the same code for the Tuya LSC lamp, not Zigbee, only Wi-Fi. So, the conversion function from Hue to it might be different, but for now, I can't even turn it on when I connect them together. Thank you for all of this. But since I'm redoing all the home automation towards Node-RED, I have many other things to look at too. Right now, I've managed to control my IPX800 and parse all its content. It works great, at least that's something, haha!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.