Hi Oeople,
I creted a function node to check if the msg is equal or not.
if (msg.payload[0].timestamp == msg.newTime) { msg.payload = '1'; } else { msg.payload = '0' } return msg;
I can see in a debug window that both msg going in is exactly the same but it always comes back 0.
What am I missing? Thanks
jbudd
2
Hard to tell unless you show us your incoming msg.payload and msg.newTime.
E1cid
4
That looks like 2 different messages. You will need to join the streams
See this article in the cookbook for an example of how to join messages into one object.
Or use context to save each message Working with context : Node-RED Node context : Node-RED
1 Like
Does
- payload[0].timestamp
- msg.newTime
Appear in the same message object, i.e they are within the same message, when you're running that function?
My thought exactly
jbudd
6
Assuming that these are properties of a single message:
I think you need to force both sides of the == to be treated as a number not a date object
if (Number(msg.payload[0].timestamp) == Number(msg.newTime))
yes it part of a lon msg.payload
I made it work with a filter node, only sending out the msg. if it it different. Thanks for the help
system
Closed
9
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.