I have a motion sensor. When there is motion ik got the following message:
How can i translate the message to simple payload = "ON" or "OFF".
I have a motion sensor. When there is motion ik got the following message:
How can i translate the message to simple payload = "ON" or "OFF".
Try this code in a function node.
msg.payload = msg.payload.object.newValue ? "ON" : "OFF";
return msg;
maybe typo's as it's hard to copy and paste from an image.
Thanks @E1cid. Your solution works.
I got only double messages on the output of the debug node, because the motion sensor returns values of 2 properties the same time. I have fixed this with Switch Node to pass only 1 property.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.