I use function to generate a value for data field for my lightbulb node but it appears that it is not populated correctly. Any ideas?
Function code:
msg.payload = parseFloat(msg.payload); // Convert payload to a number
if (msg.payload < 2) {
msg.payload = {
"brightness": 255, // Full brightness (0-255)
"rgb_color": [0, 0, 255] // Blue color
};
} else {
msg.payload = {
"brightness": 255,
"rgb_color": [255, 0, 0] // Red color
};
}
return msg;
-------
Error: Call-service error. extra keys not allowed @ data['0']
E1cid
26 May 2024 07:22
2
Hi and welcome.
Not a HA user, but i remember that mustache does not allow object replacement.
Why not select msg.
and then just type payload
in the data field.
1 Like
replacing {{{payload}}} in data field in Light node with payload only gives "invalid properties: -data" error.
I guess the question is how to properly populate the field with the message from the Function node which is:
{"brightness":255,"rgb_color":[255,0,0]}
When I enter this result manually in the Light node - it works, so the message seems to be in correct format.
I think you were correct. Once I changed data to "payload" (it was JSON) previously - it worked.
THANK YOU SO MUCH!!!!!!!
system
Closed
24 August 2024 15:34
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.