//These 3 lines boost the saturation, relative to how de-saturated a colour is
satDiff = 100 - msg.payload[1];
saturation = msg.payload[1] + (satDiff / 2);
//But don't let the saturation be > 100 else HA with throw an error
if (saturation > 100) { saturation = 100; }
//Construct a payload to send to the light using our values
msg.payload =
{
"data":
{
"entity_id": "light.color_bulb",
"brightness": "255",
"hs_color": [msg.payload[0], saturation]
}
}
return msg;
what just surprises me:
I still have an "old" container running with NodeRED. Since I only had chaos there, I created a new CT.
In the old container, however, this function node is displayed "correctly".
and there I had taken over the code one to one.
The code you have does not actually have an error, but it is now considered bad practice to allow undeclared variables, as it can easily lead to bugs. The code checker in newer versions of node red is more strict than in older versions.