I've looked everywhere, but amazingly can't find an answer to this, seemingly simple problem.
I'm fairly new to Node Red, so please go gently on me.
I'm trying to use a call service node to set the brightness and ultimately cool white and warm white
states for a lamp.
Entering a specific value in the data will set the brightness to that figure. e.g. {"brightness":"190"}
Bur how do I replace "190" in this example with msg.payload and get it to work please?
I'll then need to try and adapt that solution to set the "c" and "w" states (independently) also.
So asuming msg.payload is a number, something like this should work MessageForHA.brightness = msg.payload;
If it's a string, you will have to convert it to a number.
Sorry, there was an error in second string of my OP. Now corrected to remove the duplicated brightness value.
Yes, I'm using Node Red within Home Assistant.
I've tried pasting MessageForHA.brightness = msg.payload; into the nodes data field, but no joy. Should I be replacing 'MessageForHA' with something else?
Finally managed to solve this by using a separate function node for the data, rather than the data field of the call service node, which seems limited.
var newMsg = {
payload: {"data":{"color_temp":msg.payload}}
};
return newMsg;