Show how much time is left in a delay


#1

I have some long delays in a flow and I wanted to know how much time is remaining in them (one is 30 secs - the other is 5 minutes) when I'm sitting around debugging it.

Using Blockly, I've come up with this combination of a Blockly (or JS function) node and a standard delay node

The Blockly node defaults to counting down in 10 sec intervals from 60 seconds (these seemed like a reasonable defaults for a long running delay) but you can override the number of steps and the overall delay by inserting msg.steps and/or msg.delay (which is in seconds not milliseconds) into the flow along with the actual real msg

The flow here contains both the Blocky version and a copy/paste of the JS code it generates to be used in a function node if you want to use it that way

[{"id":"cc99e4f4.578408","type":"Blockly","z":"3bfd8455.6e864c","language":"en","func":"var oldMsg;\n\n/**\n * Describe this function...\n */\nfunction deleteAllContextProperties() {\n  context.set('steps');\n  context.set('delay');\n  context.set('oldMsg');\n  context.set('delayInterval');\n  node.status({});\n}\n\n\nif ('reset' in msg) {\n  msg['reset'] = true;\n  node.send([msg, null]);\n  deleteAllContextProperties();\n  return;\n}\nif (!(context.keys().includes('steps'))) {\n  // Either set the count and delay here or set them with\n  // via msg.delay (in secs) and msg.steps\n  context.set('steps', 6);\n  context.set('delay', 60);\n  if ('steps' in msg) {\n    context.set('steps', (msg['steps']));\n    delete msg['steps'];\n  }\n  if ('delay' in msg) {\n    context.set('delayInterval', ((msg['delay']) / (context.get('steps'))));\n    delete msg['delay'];\n  } else {\n    context.set('delayInterval', ((context.get('delay')) / (context.get('steps'))));\n  }\n  context.set('oldMsg', RED.util.cloneMessage(msg));\n}\nif ((context.get('steps')) > 0) {\n  msg['payload'] = (context.get('steps'));\n  msg['delay'] = ((context.get('delayInterval')) * 1000);\n  node.status({fill:\"blue\", shape:\"ring\", text:(String((context.get('steps')) * (context.get('delayInterval'))) + String('s'))});\n  node.send([msg, null]);\n  context.set('steps', ((context.get('steps')) - 1));\n} else {\n  oldMsg = (context.get('oldMsg'));\n  deleteAllContextProperties();\n  return [null, oldMsg];\n}\nreturn;\n","workspaceXml":"<xml xmlns=\"http://www.w3.org/1999/xhtml\"><variables><variable type=\"\" id=\"HKO%Q}Y-f%,]dF#E9bEq\">oldMsg</variable></variables><block type=\"controls_if\" id=\"ut);{+7j.yo8f*.vB~]t\" x=\"-12\" y=\"-187\"><value name=\"IF0\"><block type=\"node_object_get\" id=\"5H=si~S2q~?^GfW?2-2)\"><mutation action=\"HAS\"></mutation><field name=\"action\">HAS</field><value name=\"object\"><shadow type=\"node_msg\" id=\"FKJx:cJ.`+PXU-X)P+CJ\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"hO5Nnw4/v:oMIT%]QW-:\"><field name=\"TEXT\">reset</field></shadow></value></block></value><statement name=\"DO0\"><block type=\"node_object_set\" id=\"9ezUQ3V%FKGlEn^RP*(:\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"ENNAl@y`4=8J2vC/11Fq\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"2?,hMUh!=Uo4`Qwt1CR-\"><field name=\"TEXT\">reset</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"AwrmYmp}iJX9vDf{CP%7\"><field name=\"TEXT\"></field></shadow><block type=\"logic_boolean\" id=\"QVpQ6;d}3_;v?kBMvOJx\"><field name=\"BOOL\">TRUE</field></block></value><next><block type=\"node_send\" id=\"Xci;AqSB)XnZu/s73Ne@\"><field name=\"OUTPUT_NR\">1</field><value name=\"MESSAGE_INPUT\"><shadow type=\"node_msg\" id=\"PCV,M8p5T1[.UUnbHJe5\"></shadow></value><next><block type=\"procedures_callnoreturn\" id=\"6?p2zRb{qXyq+J+@5Ev3\"><mutation name=\"deleteAllContextProperties\"></mutation><next><block type=\"node_return\" id=\"?Pep(`:lgYf=|^5x)5{f\"></block></next></block></next></block></next></block></statement><next><block type=\"controls_if\" id=\"+bF0gT(c/Dw61BZ%[=n/\"><value name=\"IF0\"><block type=\"logic_negate\" id=\"8f8y6tTeb+`:d=e4^{F1\"><value name=\"BOOL\"><block type=\"node_object_get\" id=\"a},naI(G*{@b-o9.0Id8\"><mutation action=\"HAS\"></mutation><field name=\"action\">HAS</field><value name=\"object\"><shadow type=\"node_msg\" id=\"FKJx:cJ.`+PXU-X)P+CJ\"></shadow><block type=\"node_context_memory\" id=\"fO0.WL3BRWpyuPT}1w5Z\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"8jiWdo-gp%f3M8]Jm9PS\"><field name=\"TEXT\">steps</field></shadow></value></block></value></block></value><statement name=\"DO0\"><block type=\"misc_comment\" id=\"MudZ(G6+@I4ri!SY30A]\"><value name=\"TEXT\"><shadow type=\"text\" id=\";=gJs-V(`uWm0?Yxb{#c\"><field name=\"TEXT\">Either set the count and delay here or set them with </field></shadow></value><next><block type=\"misc_comment\" id=\"oHbC4k6_9CLb/k8~KK0j\"><value name=\"TEXT\"><shadow type=\"text\" id=\"AgE|HE$:5F[7gvXP/fty\"><field name=\"TEXT\">via msg.delay (in secs) and msg.steps </field></shadow></value><next><block type=\"node_object_set\" id=\"1Bw|VX*,Y#P_Mw*LWXnv\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"U)Y]i/(nmEgyWj=!V2Ti\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"9C}bdC_Ji(KQkDt%}4*)\"><field name=\"TEXT\">steps</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">30</field></shadow><block type=\"math_number\" id=\":OgQ%DddOB*D?26p4A=o\"><field name=\"NUM\">6</field></block></value><next><block type=\"node_object_set\" id=\"gisD*?OmT_`fP#NfeOX#\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"V/8IOA}T1fV7QVDN()e;\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"/62l0FX^*ivj?#w8}H%T\"><field name=\"TEXT\">delay</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">10</field></shadow><block type=\"math_number\" id=\"ZF)ShK??zet!TtmGuA-U\"><field name=\"NUM\">60</field></block></value><next><block type=\"controls_if\" id=\"wzegmAGE|qLk%SIF@z:M\"><value name=\"IF0\"><block type=\"node_object_get\" id=\"13V+t(Tm/e2:0%kI^FU=\"><mutation action=\"HAS\"></mutation><field name=\"action\">HAS</field><value name=\"object\"><shadow type=\"node_msg\" id=\"^6z,).W|LRPHJ(mv,N8,\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"_mYulzCx|$^a#+(@JIu}\"><field name=\"TEXT\">steps</field></shadow></value></block></value><statement name=\"DO0\"><block type=\"node_object_set\" id=\"kRyQ2-[In5:0YzLXl)H.\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"HEoA?5wu)?5+E*j9@Wj8\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"9BJjCc+_zgjrS-,q;OiC\"><field name=\"TEXT\">steps</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">10</field></shadow><block type=\"node_object_get\" id=\"gh]IE8JRp+0S-s)q@=i]\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"OIx%.lXT~3k9Xo5BDuVZ\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"Xwvw8u0rceAF46B,A]e4\"><field name=\"TEXT\">steps</field></shadow></value></block></value><next><block type=\"node_object_get\" id=\"myJiSmFeDe71~Ueb79;z\"><mutation action=\"REMOVE\"></mutation><field name=\"action\">REMOVE</field><value name=\"object\"><shadow type=\"node_msg\" id=\"1+BTaV%1kq,siZ+$iXiX\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"CfXm]9;||f077Jtw.VEO\"><field name=\"TEXT\">steps</field></shadow></value></block></next></block></statement><next><block type=\"controls_if\" id=\",}#Dt:0L0^{m@.gW/!f6\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"node_object_get\" id=\",zL^sDw?Xed@=!c*]o[A\"><mutation action=\"HAS\"></mutation><field name=\"action\">HAS</field><value name=\"object\"><shadow type=\"node_msg\" id=\"!Xa,u*o)E,X;|Zn@lvr,\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"$0@!#+_3J}KYWaG{yyq=\"><field name=\"TEXT\">delay</field></shadow></value></block></value><statement name=\"DO0\"><block type=\"node_object_set\" id=\"H%NC$KyKz:oy+{aQ6`DN\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"EsS%qmdvu$!.#+QoA$rM\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"qC_%!qFhl;WXS:W%J_bf\"><field name=\"TEXT\">delayInterval</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">10</field></shadow><block type=\"math_arithmetic\" id=\"cx0%oNLoOV)GR],3Im_9\" inline=\"false\"><field name=\"OP\">DIVIDE</field><value name=\"A\"><shadow type=\"math_number\" id=\"ANd8Zx[K,#1/b:`R:IC,\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"Ut0d3F6Upy7*:YYoDz_`\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"=n]Y^fUv|dVYPTHzSN;6\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\")I8dP=OBg*YTAcW.j~tF\"><field name=\"TEXT\">delay</field></shadow></value></block></value><value name=\"B\"><shadow type=\"math_number\" id=\"/`hJ5.h@mk*sx*$y=-5e\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"8Hx41]aB^#]6-ujjfd)T\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"+j7R=~H#/Y#!|OAzJoe%\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"(}_jP@LSP_wOY{xS24r1\"><field name=\"TEXT\">steps</field></shadow></value></block></value></block></value><next><block type=\"node_object_get\" id=\"p7K8~?lsUq8hPdi,%-uZ\"><mutation action=\"REMOVE\"></mutation><field name=\"action\">REMOVE</field><value name=\"object\"><shadow type=\"node_msg\" id=\"0IfAm;.pBK|9p6;14{TW\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"T_5HXMw:Mx}zp~.=#.jl\"><field name=\"TEXT\">delay</field></shadow></value></block></next></block></statement><statement name=\"ELSE\"><block type=\"node_object_set\" id=\"`^O7CyHvtH./.B2tyOWI\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"+-NDzjU[fyw`zk^xs^FD\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"sNxDH!$9Jy!PqX]}SYwG\"><field name=\"TEXT\">delayInterval</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">10</field></shadow><block type=\"math_arithmetic\" id=\"9R!7ScUodK=x1bI0Gsxj\" inline=\"false\"><field name=\"OP\">DIVIDE</field><value name=\"A\"><shadow type=\"math_number\" id=\"ANd8Zx[K,#1/b:`R:IC,\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"$%_T1]M8G}kHMnQhUTR@\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"k$rX3,tMC)#h47CGaO$g\"></shadow><block type=\"node_context_memory\" id=\"BsIdxNlz}8^I]1RSp[.{\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"+l/nPpG|U!)R,(nddW6*\"><field name=\"TEXT\">delay</field></shadow></value></block></value><value name=\"B\"><shadow type=\"math_number\" id=\"/`hJ5.h@mk*sx*$y=-5e\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"/{|Dj-|CB280R.F*OG/!\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"#ilO-WXSn+5I[-fyC(=_\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"K-`|^!so~{_l-^M`mIh?\"><field name=\"TEXT\">steps</field></shadow></value></block></value></block></value></block></statement><next><block type=\"node_object_set\" id=\"H)c[zXr5r*3+)O.e+jGj\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"Y)mRVV#dVYsuW0[XX?p8\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"@d7toD:j1wzcH4GNxC@v\"><field name=\"TEXT\">oldMsg</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">10</field></shadow><block type=\"node_clone\" id=\"nODzwIzht)g;/-}_|otM\"><value name=\"OBJECT_INPUT\"><shadow type=\"node_msg\" id=\"cgj;Z(kf$c%rC~nXJy*s\"></shadow><block type=\"node_msg\" id=\"p-(^3(C2=Z3).y|-W{,m\"></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement><next><block type=\"controls_if\" id=\"$,_X=tuX`~bDkr*kunn#\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"logic_compare\" id=\"[sbxx}=99x;~|60HzYet\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"node_object_get\" id=\"_%O=~_*u9^S{a0O:Pu.*\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"P/cpN:pw.ZF#:X;Bg@_;\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"F!j1.bAMY+NMElIG?PyW\"><field name=\"TEXT\">steps</field></shadow></value></block></value><value name=\"B\"><block type=\"math_number\" id=\"7;13d|%I=j5olY85^.E;\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"node_object_set\" id=\"dt::hx_#rbdVL%RzIV?X\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"cb(Ks+rWD9[ipqfvwAuC\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"z)dhAchBqR?6+Uk||=tI\"><field name=\"TEXT\">payload</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"G$9)Wvrea(9gr@8;?A/^\"><field name=\"TEXT\"></field></shadow><block type=\"node_object_get\" id=\"_[Q5L[mBsP/4q~fEU$rk\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"/O9/)!iVTnH[Swy]fY?^\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"*5BT:/L0ICsZ5CwF%wdd\"><field name=\"TEXT\">steps</field></shadow></value></block></value><next><block type=\"node_object_set\" id=\"+/qyDNJ8GL?2Cc:..T7g\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"D*ZjiPNi@aAPpj?sx+Vr\"></shadow></value><value name=\"field_name\"><shadow type=\"text\" id=\"/caCBwO32zwX_R@mvGtP\"><field name=\"TEXT\">delay</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"#I?u*`WU*f]YRWV.??M5\"><field name=\"TEXT\"></field></shadow><block type=\"math_arithmetic\" id=\"4_9WL%eP]f?)5f?1jF4`\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><shadow type=\"math_number\" id=\".?tHLWC`YRRaL8)_eD;[\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"LQ2J]@OJ~JM5YZctk:#+\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"sNh}[PB`BCk3-WU[m/u`\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"hW^G-!{Hn_@$S+{F%mZ4\"><field name=\"TEXT\">delayInterval</field></shadow></value></block></value><value name=\"B\"><shadow type=\"math_number\" id=\"`KiQj@vjzxk4ScTEkxZ}\"><field name=\"NUM\">1000</field></shadow></value></block></value><next><block type=\"node_status\" id=\"Ehn*X,?~Ss]5e-[z3V9|\"><field name=\"COLOUR\">#0000FF</field><field name=\"SHAPE\">RING</field><value name=\"TEXT_INPUT\"><shadow type=\"text\" id=\"%n018j5.TBOnRR7K/KYk\"><field name=\"TEXT\"></field></shadow><block type=\"text_join\" id=\"$w+*pj?YI3cqq`(i*e3!\"><mutation items=\"2\"></mutation><value name=\"ADD0\"><block type=\"math_arithmetic\" id=\"p_(Aj?NNj?%hH7OLEc]/\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><shadow type=\"math_number\" id=\"o0nGuXmK2EVP%J5:2!e6\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"#+hU3-=^$ZK`+UY!5,*4\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"Jf$4$-9NI16sCYQ+dly`\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"cNrK|Pc:)O-9j,s%xz$B\"><field name=\"TEXT\">steps</field></shadow></value></block></value><value name=\"B\"><shadow type=\"math_number\" id=\"E?q/.UQkETe/OcMac/P`\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"K3cUV]a}1PtY(?P;EP[,\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"Ox1uT+,*17ej]?/fnq`%\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"kbk4,YK3WZ)sqGxjK4d@\"><field name=\"TEXT\">delayInterval</field></shadow></value></block></value></block></value><value name=\"ADD1\"><block type=\"text\" id=\"t,0[D]{;SL^tY3p]0Q4b\"><field name=\"TEXT\">s</field></block></value></block></value><next><block type=\"node_send\" id=\"OKq_oZj2]KAkj@4q,hD!\"><field name=\"OUTPUT_NR\">1</field><value name=\"MESSAGE_INPUT\"><shadow type=\"node_msg\" id=\"|*~76/aTZj]t]l~NSkX6\"></shadow></value><next><block type=\"node_object_set\" id=\"Gt()LE!.!oo]H4XknCfW\" inline=\"true\"><value name=\"object_field\"><shadow type=\"node_msg\" id=\"Mk.GB0YwJODq$bt/UxRO\"></shadow><block type=\"node_context_memory\" id=\"83bbw]W0:Pe+]}KxOL[,\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"VHv5~F.:ee7TJO8a)eq;\"><field name=\"TEXT\">steps</field></shadow></value><value name=\"value_field\"><shadow type=\"text\" id=\"po_V@D10s;ziqUpwNq4B\"><field name=\"TEXT\">10</field></shadow><block type=\"math_arithmetic\" id=\"^6r6=+$O;6_5(v/~}5J0\"><field name=\"OP\">MINUS</field><value name=\"A\"><shadow type=\"math_number\" id=\"?[Sm#}bkWPujsJaQ|Ofr\"><field name=\"NUM\">1</field></shadow><block type=\"node_object_get\" id=\"i*s`g!yy7p.C)]T6nidl\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"C;`NvIV2Q/R[)F*;*ZI/\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"fo=m@-{sW#w]u{h%CwR|\"><field name=\"TEXT\">steps</field></shadow></value></block></value><value name=\"B\"><shadow type=\"math_number\" id=\"r!8p!R0oE}U{U:nh.|=`\"><field name=\"NUM\">1</field></shadow></value></block></value></block></next></block></next></block></next></block></next></block></statement><statement name=\"ELSE\"><block type=\"variables_set\" id=\"3xRKnr-eW.+cBHGEOW*8\"><field name=\"VAR\" id=\"HKO%Q}Y-f%,]dF#E9bEq\" variabletype=\"\">oldMsg</field><value name=\"VALUE\"><block type=\"node_object_get\" id=\"-xt6^^r3;s=vF{D/`O,~\"><mutation action=\"GET\"></mutation><field name=\"action\">GET</field><value name=\"object\"><shadow type=\"node_msg\" id=\"`=MhXcRM0i*tFsP{.UWr\"></shadow><block type=\"node_context_memory\" id=\"+DY1XMkzsI6@v8,*#H{H\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"=oFhI^yQ:b$D*:2[|otB\"><field name=\"TEXT\">oldMsg</field></shadow></value></block></value><next><block type=\"procedures_callnoreturn\" id=\"Xr.6M!!k]%z}U()z]Fz;\"><mutation name=\"deleteAllContextProperties\"></mutation><next><block type=\"node_return_message\" id=\"tj-WzNC^GvrT+APKl{T+\"><field name=\"OUTPUT_NR\">2</field><value name=\"MESSAGE_INPUT\"><shadow type=\"node_msg\" id=\"]Pj{6CuCZ.nC1^%Dz_2d\"></shadow><block type=\"variables_get\" id=\"-h!GtR7:!yi[$jl,3qh(\"><field name=\"VAR\" id=\"HKO%Q}Y-f%,]dF#E9bEq\" variabletype=\"\">oldMsg</field></block></value></block></next></block></next></block></statement><next><block type=\"node_return\" id=\"U[e[3Wg_Qo$:U%Kgqlwi\"></block></next></block></next></block></next></block><block type=\"procedures_defnoreturn\" id=\"pDuj~i9-fmlu%boefdy(\" x=\"12\" y=\"1312\"><field name=\"NAME\">deleteAllContextProperties</field><comment pinned=\"false\" h=\"80\" w=\"160\">Describe this function...</comment><statement name=\"STACK\"><block type=\"node_object_get\" id=\"Q(HxP0aKYatpJT^,L3b-\"><mutation action=\"REMOVE\"></mutation><field name=\"action\">REMOVE</field><value name=\"object\"><shadow type=\"node_msg\" id=\"dgTWtiCgHscFW+C3|vmy\"></shadow><block type=\"node_context_memory\" id=\"6^Bahz4}0T]z$n[T|=~=\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"4q8`w{DlQcXG1S3D7RJ|\"><field name=\"TEXT\">steps</field></shadow></value><next><block type=\"node_object_get\" id=\"AxV1DAyo^u/wC%|h{~}t\"><mutation action=\"REMOVE\"></mutation><field name=\"action\">REMOVE</field><value name=\"object\"><shadow type=\"node_msg\" id=\"dgTWtiCgHscFW+C3|vmy\"></shadow><block type=\"node_context_memory\" id=\"OH6ztRyO)M$.2)[;VJcJ\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"N!D7():k(JdFm;7L[:AJ\"><field name=\"TEXT\">delay</field></shadow></value><next><block type=\"node_object_get\" id=\"t+7UYy/WHnqYaqWD!9_t\"><mutation action=\"REMOVE\"></mutation><field name=\"action\">REMOVE</field><value name=\"object\"><shadow type=\"node_msg\" id=\"dgTWtiCgHscFW+C3|vmy\"></shadow><block type=\"node_context_memory\" id=\"t/![g)1YN^v$/P8x|xx4\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\"yzaieJOu@HlR|RgCDPtc\"><field name=\"TEXT\">oldMsg</field></shadow></value><next><block type=\"node_object_get\" id=\"C$u2M_Ag}RW6P,/*F$OI\"><mutation action=\"REMOVE\"></mutation><field name=\"action\">REMOVE</field><value name=\"object\"><shadow type=\"node_msg\" id=\"dgTWtiCgHscFW+C3|vmy\"></shadow><block type=\"node_context_memory\" id=\"SFpY9_;0?7|o.y=P`1xt\"></block></value><value name=\"field_name\"><shadow type=\"text\" id=\".CwVnRIiSRu6nz1)Bm,N\"><field name=\"TEXT\">delayInterval</field></shadow></value><next><block type=\"node_remove_status\" id=\"%P-^Rrw|6?lH%EQ!nU{r\"></block></next></block></next></block></next></block></next></block></statement></block></xml>","outputs":2,"name":"showDelay","x":690,"y":40,"wires":[["9af0b116.40e83"],["58289501.ff66bc"]],"icon":"node-red/timer.png"}]

I'd appreciate a few road tests by others

Note: It only handles one message at a time - if you send it another msg while 1st one is being delayed - very unpredictable results occur!


#2

Couldnt you just use the MyTimeout node and do the same thing - thats how i use it

Craig


#3

I hadn;t heard of this node - I'll go and check it out ta :slight_smile:

As well as wanting the functionality ,this was an exercise to see if I could do it with Blockly

It proved very useful in finding some bugs in the original 1.0.0 release


#4

Aah - more power to you then !!

Mytimeout by Ncherry

Very good - he has based it on the code from Peter Scargills big timer - i have found it invaluable - lets me have a countdown under the node as well as grabbing the countdown in code and displaying it on my dashboard

Craig


#5

Could you post an example of how it can be configured to just delay a msg - I'm getting confused by all the stuff about states!


#6

Aah not so sure on just delay a message - i use it as a timeout - so lets say i want something to run for 1 hour (3600 secs) i fire into it - here is my flow

[{"id":"be23d858.f070d8","type":"debug","z":"a78930fe.ed232","name":"Boiler Fire up - Node 1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":930,"y":1180,"wires":[]},{"id":"5bab8b3b.564f94","type":"mqtt out","z":"a78930fe.ed232","name":"","topic":"topic/fireuptheboileroverride","qos":"","retain":"","broker":"389dd264.7716de","x":940,"y":1220,"wires":[]},{"id":"e1483885.249c28","type":"inject","z":"a78930fe.ed232","name":"Turn off Boiler Override","topic":"topic/fireuptheboileroverride","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":180,"y":1260,"wires":[["5f3a7a46.e835c4"]]},{"id":"15a8756f.b0232b","type":"ui_button","z":"a78930fe.ed232","name":"Manual Turn on of Boiler 1hr","group":"4da5d3cb.b9673c","order":1,"width":0,"height":0,"passthru":false,"label":"Manual Boiler 1 Hr Turn on","color":"","bgcolor":"","icon":"","payload":"{     \"payload\": \"on\",     \"timeout\": 3600,     \"warning\": 5 }","payloadType":"json","topic":"topic/fireuptheboileroverride","x":180,"y":1180,"wires":[["5f3a7a46.e835c4"]]},{"id":"d5c02b4c.5620c8","type":"ui_button","z":"a78930fe.ed232","name":"Turn off Manual Boiler Override","group":"4da5d3cb.b9673c","order":3,"width":0,"height":0,"passthru":false,"label":"Turn off Manual Boiler Override","color":"","bgcolor":"","icon":"","payload":"0","payloadType":"str","topic":"topic/fireuptheboileroverride","x":190,"y":1220,"wires":[["5f3a7a46.e835c4"]]},{"id":"23210b71.6a2104","type":"debug","z":"a78930fe.ed232","name":"Boiler Fire up - Node 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":920,"y":1280,"wires":[]},{"id":"e56bee14.2f24b","type":"ui_button","z":"a78930fe.ed232","name":"Manual Turn on of Boiler 2hr","group":"4da5d3cb.b9673c","order":2,"width":0,"height":0,"passthru":false,"label":"Manual Boiler 2 Hr Turn on","color":"","bgcolor":"","icon":"","payload":"{     \"payload\": \"on\",     \"timeout\": 7200,     \"warning\": 5 }","payloadType":"json","topic":"topic/fireuptheboileroverride","x":180,"y":1140,"wires":[["5f3a7a46.e835c4"]]},{"id":"5f3a7a46.e835c4","type":"mytimeout","z":"a78930fe.ed232","name":"Boiler Manual Turn on - New Node","outtopic":"topic/fireuptheboileroverride","outsafe":"1","outwarning":"","outunsafe":"0","warning":"2","timer":"10","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":600,"y":1180,"wires":[["5bab8b3b.564f94","be23d858.f070d8"],["23210b71.6a2104","34467ea3.dbffa2"]]},{"id":"34467ea3.dbffa2","type":"change","z":"a78930fe.ed232","name":"Set Flow Variable - BoilerTimeToRun","rules":[{"t":"set","p":"BoilerTimeToRun","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1280,"wires":[["9cd8ac49.7c2aa"]]},{"id":"9cd8ac49.7c2aa","type":"change","z":"a78930fe.ed232","name":"Take Variable and Put it into Payload","rules":[{"t":"move","p":"BoilerTimeToRun","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1340,"wires":[["fc794523.ba6918"]]},{"id":"fc794523.ba6918","type":"ui_text_input","z":"a78930fe.ed232","name":"","label":"Manual Boiler  - Time to run (Sec)","group":"4da5d3cb.b9673c","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":960,"y":1340,"wires":[[]]},{"id":"389dd264.7716de","type":"mqtt-broker","z":"a78930fe.ed232","broker":"localhost","port":"1883","clientid":"Node-Red","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"4da5d3cb.b9673c","type":"ui_group","z":"","name":"Boiler Control","tab":"c9d53e06.a95c8","order":5,"disp":true,"width":"5"},{"id":"c9d53e06.a95c8","type":"ui_tab","z":"","name":"CURTIN house main page","icon":"dashboard","order":1}]

SO basically i have a number of buttons on my dashboard - they tell this to run for a certain period (1hr, 2hr etc) and a cancel button - the 1hr button sends in 3600 as its payload and the timout node counts down, when it gets to 0 it then sends out a payload (can also send out a warning payload prior to that)

so in your instance you could send in your message - store it as a variable, fire off the timeout node, when it expires, the next node reads the varaible for the payload and goes on its way

Craig


#7

Got you - my flow is a simple Delay node replacement but just giving the time remaining as well as the standard blue dot triggered info.

Just designed to give slightly enhanced editor information


#8

Fair enough

Craig