Node red and Tradfri lights

I’m trying to utilize a button to change the color_temp of my Tradfri lights. Through Node Red, I would like to be able to push “button 1” and have the color_temp increase by say 50. So if the current color_temp is 300 and I push the button, I want it to go up to 350.

So, using a “current state” node, I can see that the current color_temp is 300 (or whatever it is) and I can separate out that value.
My question is this, how do I add 50 pts to that value and then set the color_temp to 350? Obviously, I want this to work if the value was 275 going to 325 as well.

Use a function node.
Assuming the payload is msg.payload.color_temp the function would be:

msg.payload.color_temp = msg.payload.color_temp + 50;
return msg;

Yep that worked. I’m still trying to figure out the syntax for the function node.

1 Like