Send http request using delay node

Hi all,

I'm developing a simple node red IoT project
In particular, when a sensor value is over a threshold, an http request is performed against a ticket system and, if doesn't yet exist, a ticket is opened
This is ok but, because data are gathered each second, if the value is higher than the threshold, node red will perform an http request each second too and this isn't good, I think.
So, I put a delay node using Rate Limit and a period of 30 second
In this way, when the value is over the threshold the first ticket will be opened after 30 second, while I would like open the ticket immediately and then wait for 30 second
Is this possibile using only the delay node or shall I develop custom code?
I hope my explation is clear
Thanks in advance for your help

Regards

I think you can use the Trigger node with following settings

many thanks. But this configuration works only with a single message.
If I have multiple messages distingueshed by msg.topic the trigger node sent only a message.
(see the following flow)

[{"id":"19407975.95b1f7","type":"tab","label":"TEST","disabled":false,"info":""},{"id":"9072b336.4e1e9","type":"function","z":"19407975.95b1f7","name":"extract info","func":"\nreturn [\n\n\t{payload: msg.payload.Stoccaggio},\n\t{payload: msg.payload.Prelievo},\n\t{payload: msg.payload.Alimentazione}\n    \n];","outputs":3,"noerr":0,"x":752.6587905883789,"y":88.52387809753418,"wires":[["adbad9a5.3df078"],["32a22c82.9c4ed4"],["8c144221.4ea41"]],"outputLabels":["Stoccaggio","Prelievo","Alimentazione"]},{"id":"32a22c82.9c4ed4","type":"function","z":"19407975.95b1f7","name":"Prelievo","func":"//msg.payload = Math.floor(msg.payload/3600.0*100)/100;\n\nmsg.topic = 'Prelievo magazzino';\nmsg.soglia = -1;\nmsg.WO_DESC = 'Prelievo magazzino';\nmsg.WORKTYPE = 'FAIL';\nmsg.LOCATION = 'POEMP';\nmsg.WO_STATUS = 'NUOVO';\n\nvar m  = msg.payload*1.5;\nmsg.ui_control = {\"min\":0,\"max\":m}\n\nmsg.url = \"aa\"; \n\nreturn msg;","outputs":1,"noerr":0,"x":1022.4169082641602,"y":88.25006294250488,"wires":[["876030c3.c812"]]},{"id":"876030c3.c812","type":"switch","z":"19407975.95b1f7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"-1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1209.7383003234863,"y":91.57147407531738,"wires":[["70b8b856.797888"]]},{"id":"87f3534d.9e49a","type":"debug","z":"19407975.95b1f7","name":"Do HTTP Request","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1573.5002708435059,"y":92.00007486343384,"wires":[]},{"id":"8c144221.4ea41","type":"function","z":"19407975.95b1f7","name":"Alimentazione","func":"//msg.payload = Math.floor(msg.payload/3600.0*100)/100;\n\nmsg.topic = 'Contatore Alimentazione';\nmsg.soglia = -1;\nmsg.WO_DESC = 'Contatore Alimentazione';\nmsg.WORKTYPE = 'FAIL';\nmsg.LOCATION = 'POEMP';\nmsg.WO_STATUS = 'NUOVO';\n\nvar m  = msg.payload*1.5;\nmsg.ui_control = {\"min\":0,\"max\":m}\n\nmsg.url = \"aa\"; \n\nreturn msg;","outputs":1,"noerr":0,"x":1045.6669082641602,"y":138.0000514984131,"wires":[["876030c3.c812"]]},{"id":"adbad9a5.3df078","type":"function","z":"19407975.95b1f7","name":"Stoccaggio","func":"//msg.payload = Math.floor(msg.payload/3600.0*100)/100;\n\nmsg.topic = 'Stoccaggio';\nmsg.soglia = -1;\nmsg.WO_DESC = 'Contatore Stoccaggio';\nmsg.WORKTYPE = 'FAIL';\nmsg.LOCATION = 'POEMP';\nmsg.WO_STATUS = 'NUOVO';\n\nvar m  = msg.payload*1.5;\nmsg.ui_control = {\"min\":0,\"max\":m}\n\nmsg.url = \"aa\"; \n\nreturn msg;","outputs":1,"noerr":0,"x":1040.047866821289,"y":37.44049835205078,"wires":[["876030c3.c812"]]},{"id":"d5da8ab.f366678","type":"random","z":"19407975.95b1f7","name":"","low":"1","high":"1000","inte":"true","property":"payload","x":334.5,"y":40.00000762939453,"wires":[["4e261493.d63a7c"]]},{"id":"ef4c7c2e.fde31","type":"inject","z":"19407975.95b1f7","name":"","topic":"Stoccaggio","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":144.10000610351562,"y":40,"wires":[["d5da8ab.f366678"]]},{"id":"c5c0f24f.dcef","type":"inject","z":"19407975.95b1f7","name":"","topic":"Prelievo","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":133,"y":94.00000381469727,"wires":[["973aae07.d2f32"]]},{"id":"514f00f8.35e8c","type":"inject","z":"19407975.95b1f7","name":"","topic":"Alimentazione","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":149,"y":138.0000057220459,"wires":[["afd3aed3.9cf2c"]]},{"id":"973aae07.d2f32","type":"random","z":"19407975.95b1f7","name":"","low":"1","high":"1000","inte":"true","property":"payload","x":332.00000381469727,"y":93.00002861022949,"wires":[["4e261493.d63a7c"]]},{"id":"afd3aed3.9cf2c","type":"random","z":"19407975.95b1f7","name":"","low":"1","high":"1000","inte":"true","property":"payload","x":373.00000762939453,"y":137.6000051498413,"wires":[["4e261493.d63a7c"]]},{"id":"4e261493.d63a7c","type":"join","z":"19407975.95b1f7","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":562.5000114440918,"y":89.00000667572021,"wires":[["9072b336.4e1e9"]]},{"id":"70b8b856.797888","type":"trigger","z":"19407975.95b1f7","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"30","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":1374.1000747680664,"y":88.00000190734863,"wires":[["87f3534d.9e49a"]]}]

Can I handle this behavior in a different way?
many thanks again for your help

use a switch node to splitpaths based on msg.topic?

If you have finite amount of topics (3 I see in your flow) then you can use Trigger node for each and combine flows after Trigger nodes.

I joined msg.topic before :slight_smile:
I would like avoid redundancy of similar nodes.
In fact, if the values are higher than the threshold the behavior is the same, i.e. perfom the http request to the ticket system
Many thanks

Actually I would separate input from output. With your input values per topic, just store the values somewhere (global or flow) Then add a triger node with the rate you'll need to send out the request. And use it to do the calculations using latest stored input values and send out the request.