Closed olvier closed 4 years ago
Hi,
You're correct in your interpretation of syntax - what I suspect is it's a javascript/node-red thing that's stopping it working as expected.
What you're trying to do there is set the "mon" property on the payload object. If the input coming into the function node isn't a JSON object this [helpfully] fails silently and just passes the input to the output (with your return msg
).
I verified this by using an inject
node set to payload of timestamp (default), then fed this into a function node with your code (below), then into an eztimer node.
msg.payload.mon = false;
return msg;
The eztimer node receieved simply the timestamp value: To fix this, wherever you set the payload, if its not already a JSON object, you need to ensure it is with this code/syntax:
msg.payload = { "mon": false };
return msg;
When I use this code in the function node of the same test flow: You can see now there's an object being passed to the eztimer node - and the node is happy with it.
You can also verify when the timer is next going to fire using the info
input (good for troubleshooting day of week enabling/disabling) and sending the output to a debug node.
Let me know if you get it sorted - if not, feel free to post your flow and I'll have a look at it.
Thanks!
Ah, such an easy solution, for this kind of "stupid" question. If I had think about it for some more seconds, I could have get it for my own.
Thank you very much for your great explanation!!
Hi, i am getting "unsupported input", when i am sending
msg.payload.mon = false; return msg;
via function-node. Is that wrong? This is what i am understanding when interpreting your readme.
kind regards