I’m re-working some of my messy flows and decided to try using a gate node to block or pass messages based on some conditions. The sample test flow works just fine:
[{"id":"f61b4c1c.d6f8","type":"inject","z":"ebbab6440b29a652","name":"input","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":730,"y":400,"wires":[["b464bbaa.5be868"]]},{"id":"57c0705e.2b648","type":"inject","z":"ebbab6440b29a652","name":"open","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":830,"y":300,"wires":[["b464bbaa.5be868"]]},{"id":"e56d6ef2.db15b8","type":"inject","z":"ebbab6440b29a652","name":"close","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"close","payloadType":"str","x":830,"y":340,"wires":[["b464bbaa.5be868","af5e9f6fc32b264d"]]},{"id":"310d032f.aa197c","type":"inject","z":"ebbab6440b29a652","name":"toggle","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"toggle","payloadType":"str","x":830,"y":460,"wires":[["b464bbaa.5be868"]]},{"id":"c5e19f28.1e37d","type":"inject","z":"ebbab6440b29a652","name":"reset","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"default","payloadType":"str","x":830,"y":500,"wires":[["b464bbaa.5be868"]]},{"id":"7f423eb5.3d6508","type":"inject","z":"ebbab6440b29a652","name":"status","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"status","payloadType":"str","x":830,"y":540,"wires":[["b464bbaa.5be868"]]},{"id":"b464bbaa.5be868","type":"gate","z":"ebbab6440b29a652","name":"gate demo","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"x":1030,"y":400,"wires":[["8ba20475.bd1c28"]]},{"id":"8ba20475.bd1c28","type":"debug","z":"ebbab6440b29a652","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":400,"wires":[]}]
My flow, generally, will 1) pass a message, 2) block future message and/or block all messages based on some conditions, and 3) allow messages to pass again after a delay. A trigger node passes the first message, and then is supposed to re-open the gate after a delay… but it doesn’t! The payload between the “open” inject node and the delayed output of my trigger node look identical. I can’t figure out why the trigger node can’t control the gate. Any ideas?
[{"id":"6e808ad0f1f1d1cd","type":"trigger","z":"ebbab6440b29a652","name":"Wait 15 minutes...","op1":"{\"topic\":\"front_yard\",\"message\":\"Motion has been detected in the front yard.\"}","op2":"{\"payload\":\"open\",\"topic\":\"control\"}","op1type":"json","op2type":"json","duration":"5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":370,"y":1480,"wires":[["0c23a38c5492646f"]]},{"id":"827a89ab8df285a8","type":"inject","z":"ebbab6440b29a652","name":"close","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"close","payloadType":"str","x":410,"y":1600,"wires":[["0c23a38c5492646f","1119843b15350c99"]]},{"id":"0c23a38c5492646f","type":"gate","z":"ebbab6440b29a652","name":"Gate","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"x":630,"y":1620,"wires":[["298d601aa36afd7e"]]},{"id":"298d601aa36afd7e","type":"debug","z":"ebbab6440b29a652","name":"Gate output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":1620,"wires":[]},{"id":"d251da81458b806b","type":"status","z":"ebbab6440b29a652","name":"Gate status","scope":["0c23a38c5492646f"],"x":610,"y":1720,"wires":[["af158e8b64cd41ff"]]},{"id":"af158e8b64cd41ff","type":"debug","z":"ebbab6440b29a652","name":"Gate status text","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"status.text","targetType":"msg","statusVal":"","statusType":"auto","x":840,"y":1720,"wires":[]},{"id":"aa344388334e0139","type":"inject","z":"ebbab6440b29a652","name":"Front Yard Motion","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":150,"y":1480,"wires":[["6e808ad0f1f1d1cd"]]},{"id":"3f9b590c1dc21f42","type":"inject","z":"ebbab6440b29a652","name":"open","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":410,"y":1540,"wires":[["0c23a38c5492646f","1119843b15350c99"]]},{"id":"1119843b15350c99","type":"debug","z":"ebbab6440b29a652","name":"Inject output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":1520,"wires":[]}]
In the screen shot above, I pressed the inject nodes in sequence: open, close, Front Yard Motion. Also, the label on my trigger is wrong; I have it set for 5 seconds for testing.
EDIT: It looks like in my trigger node, I’m not actually setting the msg.payload and msg.topic, but probably msg.payload.payload and msg.payload.topic instead. I have a syntax problem in my JSON.
EDIT 2: I guess I’ll just use change nodes instead. I was trying to get away without using additional nodes, and just send the payloads I wanted from the trigger nodes.