I have a working flow below, but I want to understand how to simplify it so my flows are cleaner (and learn something new). I was thinking a function node could do all of it, and would appreciate any pointers.
The input is a zigbee door sensor which output the JSON string over MQTT.
When the door is open (contact = false) I want the message to be passed onto a trigger node.
When the door is closed (contact = true) I want the message blocked.
Current flow and debugs:
My basic thoughts of a function node would be:
var doorstate = msg.payload.contact; //read contact state into a variable if (doorstate = false) // false means door is open msg.payload = 1; //any value works when sent to the trigger node return msg;
I'm not sure how to read the payload from the MQTT node.
Also I 'think' a payload may still get passed through to the trigger node like this.