Triggering on specific message

Dear All,

I would like to have a functionality where in I need to run specific flow repeatedly when I receive specific type of message. Please let me know how to handle this in node red.

Is it possible to do this in trigger node. If so please let me know how to do this?

Thanks & Regards
Varun

a simple example using switch node

[{"id":"91be1257.55f2","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"a special message","payloadType":"str","x":210,"y":400,"wires":[["dc2b7cc9.db3fd8"]]},{"id":"187967a.a95e618","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"not a special message","payloadType":"str","x":220,"y":440,"wires":[["dc2b7cc9.db3fd8"]]},{"id":"dc2b7cc9.db3fd8","type":"switch","z":"4484ee28.caa3c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"a special message","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":400,"wires":[["269a25ff.79887a"]]},{"id":"269a25ff.79887a","type":"debug","z":"4484ee28.caa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]}]

Hi,

Thanks for the response. But how to input specific message to inject node?

Thanks & Regards
Varun

You don't you remove inject and feed your message into the switch node. The injects where to show what happens with different message values.

Post you code between back ticks to make it easy to copy and paste.
e.g.
```
code
```
becomes

code

edit previous by clicking pencil icon, then add back ticks before and after code, on their own line.

[{"id":"e5b745ac.4ac7b8","type":"inject","z":"31a9ecb9.4a4704","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"10 15 * * *","once":false,"onceDelay":0.1,"x":110,"y":860,"wires":[["b80bd9cc.48b1e8"]]},{"id":"b80bd9cc.48b1e8","type":"function","z":"31a9ecb9.4a4704","name":"","func":"msg.payload = \"Another varun happy\";\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":820,"wires":[["b52400a5.2c6a6","e6a98594.c681e8"]]},{"id":"b52400a5.2c6a6","type":"debug","z":"31a9ecb9.4a4704","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":710,"y":820,"wires":[]},{"id":"e6a98594.c681e8","type":"delay","z":"31a9ecb9.4a4704","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":940,"wires":[["6a769ec6.b1356"]]},{"id":"6a769ec6.b1356","type":"function","z":"31a9ecb9.4a4704","name":"","func":"msg.payload1 = \"Delay varun happy\";\nmsg.payload = 12;\nmsg.delay=2 * 60000;\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":940,"wires":[["b9992d9b.61344","9fb624dd.a0c388"]]},{"id":"b9992d9b.61344","type":"debug","z":"31a9ecb9.4a4704","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":1020,"wires":[]},{"id":"9fb624dd.a0c388","type":"delay","z":"31a9ecb9.4a4704","name":"","pauseType":"delayv","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":140,"y":760,"wires":[["a2c86b9c.508448"]]},{"id":"a2c86b9c.508448","type":"function","z":"31a9ecb9.4a4704","name":"","func":"msg.payload2 = \"xxxxxxxxx\";\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":740,"wires":[["7af5576e.690058","b80bd9cc.48b1e8"]]},{"id":"7af5576e.690058","type":"debug","z":"31a9ecb9.4a4704","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":740,"wires":[]}]

Hope now your able to copy the code. I wanted to have complete control over variable delay node in my code. That is I want to trigger or stop sending message to subsequent flow based on specific message.

Yes to copy flow i can now click copy icon, also no messy code all over thread, maybe you could tidy up the mess?

As to what you are attempting, more info is required as i am not getting it.

Ok Sorry for the messy code. I was trying lot of options.Let me tell my requirement.

Requirement:

  1. At specific time inject node will trigger to turn OFF water dispensing system.
  2. after 10mins I shall turn it on again the water dispensing system.
  3. Step 1 and 2 should repeat till specific time is reached after that it stop looping till next day,

This what I wanted to achieve. I tried using trigger node. Which helps to loop but I was not have any control to stop it after specific time is reached.

so how do you turn it on? what device?

I am using Raspberry pi to control device

e.g.

[{"id":"86ccce84.e6c08","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"fbff5ba2.744b78","type":"trigger","z":"86ccce84.e6c08","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":290,"y":60,"wires":[["59cc72c8.23504c"]]},{"id":"59cc72c8.23504c","type":"function","z":"86ccce84.e6c08","name":"ON","func":"msg.payload =\"varun\";\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":60,"wires":[["b34c1395.444da","903c65aa.89fa78"]]},{"id":"903c65aa.89fa78","type":"delay","z":"86ccce84.e6c08","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":140,"wires":[["ae48183c.56da68"]]},{"id":"e90b8642.0ee058","type":"inject","z":"86ccce84.e6c08","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/10 19 * * *","once":false,"onceDelay":0.1,"x":90,"y":60,"wires":[["fbff5ba2.744b78"]]},{"id":"b34c1395.444da","type":"debug","z":"86ccce84.e6c08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":60,"wires":[]},{"id":"ae48183c.56da68","type":"function","z":"86ccce84.e6c08","name":"OFF","func":"msg.payload =\"XYZ\";\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":140,"wires":[["fbff5ba2.744b78"]]}]

This is what I wanted to achieve along with I wanted to stop further trigger after sometime. To turn ON and OFF I am using raspberry pi. Sorry I am very new to this.

Before you go too far, could you tidy-up some of the postings above (AKA mess).
Just use the pencil icon to edit your posts and delete the unformatted listings.
It will make reading the thread a lot easier for people.

Sorry for lot of messy post as I started using this recently . Now I cleaned it up.

Thanks - but I think you may have missed one.

FYI : In the code which I pasted in that I haven't used pi node as I am debugging it. Once I am able to control the trigger I shall add gpio node after ON/OFF.

try

[{"id":"61395a9c.5bfb0c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"355132d6.866d56","type":"function","z":"61395a9c.5bfb0c","name":"turn on water","func":"msg.payload =\"varun\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":140,"wires":[["7ebbbd4.b12a344"]]},{"id":"d2f7044f.164028","type":"delay","z":"61395a9c.5bfb0c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":60,"wires":[["355132d6.866d56"]]},{"id":"f4740e08.ff8138","type":"inject","z":"61395a9c.5bfb0c","name":"start time","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"06 11 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":90,"y":62,"wires":[["85bc7f14.7bd23"]]},{"id":"7ebbbd4.b12a344","type":"debug","z":"61395a9c.5bfb0c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":280,"wires":[]},{"id":"feb4da3d.3183a8","type":"inject","z":"61395a9c.5bfb0c","name":"finish time","props":[{"p":"reset","v":"true","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"07 11 * * *","once":false,"onceDelay":0.1,"topic":"","x":160,"y":100,"wires":[["85bc7f14.7bd23"]]},{"id":"85bc7f14.7bd23","type":"trigger","z":"61395a9c.5bfb0c","name":"","op1":"1","op2":"1","op1type":"str","op2type":"str","duration":"-10","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":360,"y":60,"wires":[["6a1eb1ff.550e2"]]},{"id":"6a1eb1ff.550e2","type":"function","z":"61395a9c.5bfb0c","name":"turn off water","func":"msg.payload =\"xyz\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":140,"wires":[["d2f7044f.164028","7ebbbd4.b12a344"]]}]

Thanks for the response. When I tested it , It is not stooping at finish time in the above flow

Finish node is sending message to trigger node. But it is not stopping. Is there any specific message I need to send to trigger node to understand and stop