Much simpler solution . if start is resent timer_1 just stops itself and restarts.
[
{
"id": "775258288b8ca03e",
"type": "debug",
"z": "f396d031fe5c8965",
"name": "debug 95",
"active": true,
"tosidebar": false,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 1040,
"y": 460,
"wires": []
},
{
"id": "86d14da29090ac75",
"type": "Blockly",
"z": "f396d031fe5c8965",
"func": "if ((msg['payload']) == 'start') {\n var timeout_1 = setTimeout(function() {\n node.send([msg]);\n }, 10000);\n context.set(\"timeout_1\", timeout_1);} else if ((msg['payload']) == 'stop') {\n if (context.get(\"timeout_1\")) {\n clearTimeout(context.get(\"timeout_1\"));\n context.set(\"timeout_1\", undefined);\n }\n node.send([msg]);\n} else if ((msg['payload']) == 'restart') {\n if (context.get(\"timeout_1\")) {\n clearTimeout(context.get(\"timeout_1\"));\n context.set(\"timeout_1\", undefined);\n }\n var timeout_1 = setTimeout(function() {\n node.send([msg]);\n }, 10000);\n context.set(\"timeout_1\", timeout_1);}\n",
"workspaceXml": "<xml xmlns=\"https://developers.google.com/blockly/xml\">\n <block type=\"controls_if\" id=\"d-gJ+-Lq}:E?Ih`(p.L#\" x=\"-262\" y=\"-212\">\n <mutation elseif=\"2\"></mutation>\n <value name=\"IF0\">\n <block type=\"logic_compare\" id=\"7h)4nWxurO74^2RHro/Y\">\n <field name=\"OP\">EQ</field>\n <value name=\"A\">\n <block type=\"node_object_get\" id=\"se?zaAa=tm4q#6:Q:Ar7\">\n <mutation xmlns=\"http://www.w3.org/1999/xhtml\" action=\"GET\"></mutation>\n <field name=\"action\">GET</field>\n <value name=\"object\">\n <shadow type=\"node_msg\" id=\"^_=%(?!Ye.|7|GlE!*/:\"></shadow>\n </value>\n <value name=\"field_name\">\n <shadow type=\"text\" id=\"tKCxp.A,}yFs[O)H$._R\">\n <field name=\"TEXT\">payload</field>\n </shadow>\n </value>\n </block>\n </value>\n <value name=\"B\">\n <block type=\"text\" id=\"Jcw3~FeMIhlH4#z`!)13\">\n <field name=\"TEXT\">start</field>\n </block>\n </value>\n </block>\n </value>\n <statement name=\"DO0\">\n <block type=\"set_timeout\" id=\"4.)r.V*t|qjH@SN}qG1f\">\n <field name=\"NAME\">timeout_1</field>\n <field name=\"DELAY\">10</field>\n <field name=\"UNIT\">sec</field>\n <statement name=\"STATEMENT\">\n <block type=\"node_send\" id=\"zK9w]#-iTIp+3IuZ-lCN\">\n <field name=\"OUTPUT_NR\">1</field>\n <value name=\"MESSAGE_INPUT\">\n <shadow type=\"node_msg\" id=\",YwLpM.![IK!RaW.(tv|\"></shadow>\n </value>\n </block>\n </statement>\n </block>\n </statement>\n <value name=\"IF1\">\n <block type=\"logic_compare\" id=\"()Jk[]VL=p~QT96S!S%g\">\n <field name=\"OP\">EQ</field>\n <value name=\"A\">\n <block type=\"node_object_get\" id=\"RCoifxD7I,{]I34`@|{*\">\n <mutation xmlns=\"http://www.w3.org/1999/xhtml\" action=\"GET\"></mutation>\n <field name=\"action\">GET</field>\n <value name=\"object\">\n <shadow type=\"node_msg\" id=\"=9)a6t./UZPuXO%$a,^{\"></shadow>\n </value>\n <value name=\"field_name\">\n <shadow type=\"text\" id=\"(EhRL;{@6o4k2dlL1@{2\">\n <field name=\"TEXT\">payload</field>\n </shadow>\n </value>\n </block>\n </value>\n <value name=\"B\">\n <block type=\"text\" id=\"1pLJ*h?#.%^u8PALoKyI\">\n <field name=\"TEXT\">stop</field>\n </block>\n </value>\n </block>\n </value>\n <statement name=\"DO1\">\n <block type=\"clear_timeout\" id=\"Nk+g`6knu_(;$?Q;qc?A\">\n <mutation xmlns=\"http://www.w3.org/1999/xhtml\" dropdown_options=\"{"nothing_selected":"none","4.)r.V*t|qjH@SN}qG1f":"timeout_1","H_l(`BM?,l!vYpDe^{=N":"timeout_1"}\"></mutation>\n <field name=\"NAME\">4.)r.V*t|qjH@SN}qG1f</field>\n <next>\n <block type=\"node_send\" id=\"q95KnJCwwhxL5!r75?8w\">\n <field name=\"OUTPUT_NR\">1</field>\n <value name=\"MESSAGE_INPUT\">\n <shadow type=\"node_msg\" id=\"KL(A+95*L-p!Y}mg=_Cf\"></shadow>\n </value>\n </block>\n </next>\n </block>\n </statement>\n <value name=\"IF2\">\n <block type=\"logic_compare\" id=\"q0W=e`3/a~hO8`E(gd=,\">\n <field name=\"OP\">EQ</field>\n <value name=\"A\">\n <block type=\"node_object_get\" id=\"npKWA!.@:4GB5-/z?E[A\">\n <mutation xmlns=\"http://www.w3.org/1999/xhtml\" action=\"GET\"></mutation>\n <field name=\"action\">GET</field>\n <value name=\"object\">\n <shadow type=\"node_msg\" id=\"xSl@3VU(1P%#qEA0(,X!\"></shadow>\n </value>\n <value name=\"field_name\">\n <shadow type=\"text\" id=\"jGklls{0UOq4vB-VXDzw\">\n <field name=\"TEXT\">payload</field>\n </shadow>\n </value>\n </block>\n </value>\n <value name=\"B\">\n <block type=\"text\" id=\"n8U?]*.9`FdW%5Zq|M+%\">\n <field name=\"TEXT\">restart</field>\n </block>\n </value>\n </block>\n </value>\n <statement name=\"DO2\">\n <block type=\"clear_timeout\" id=\"-_bWB.AvI%~}9,/{42Iu\">\n <mutation xmlns=\"http://www.w3.org/1999/xhtml\" dropdown_options=\"{"nothing_selected":"none","4.)r.V*t|qjH@SN}qG1f":"timeout_1","H_l(`BM?,l!vYpDe^{=N":"timeout_1"}\"></mutation>\n <field name=\"NAME\">4.)r.V*t|qjH@SN}qG1f</field>\n <next>\n <block type=\"set_timeout\" id=\"H_l(`BM?,l!vYpDe^{=N\">\n <field name=\"NAME\">timeout_1</field>\n <field name=\"DELAY\">10</field>\n <field name=\"UNIT\">sec</field>\n <statement name=\"STATEMENT\">\n <block type=\"node_send\" id=\"dol5Ocqaak0lz8NOvEi?\">\n <field name=\"OUTPUT_NR\">1</field>\n <value name=\"MESSAGE_INPUT\">\n <shadow type=\"node_msg\" id=\"E[#SQ.`@:)38cSfbp#MQ\"></shadow>\n </value>\n </block>\n </statement>\n </block>\n </next>\n </block>\n </statement>\n </block>\n</xml>",
"outputs": 1,
"timeout": 0,
"blocklyConfig": "49b50d82dba520c7",
"backpackContents": [],
"noerr": 0,
"name": "",
"x": 880,
"y": 460,
"wires": [
[
"775258288b8ca03e"
]
]
},
{
"id": "5801af9ae34c0125",
"type": "inject",
"z": "f396d031fe5c8965",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "start",
"payloadType": "str",
"x": 710,
"y": 460,
"wires": [
[
"86d14da29090ac75"
]
]
},
{
"id": "fcb5838615df7c8b",
"type": "inject",
"z": "f396d031fe5c8965",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "stop",
"payloadType": "str",
"x": 710,
"y": 500,
"wires": [
[
"86d14da29090ac75"
]
]
},
{
"id": "e0f0d27e46db34f9",
"type": "inject",
"z": "f396d031fe5c8965",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "restart",
"payloadType": "str",
"x": 710,
"y": 540,
"wires": [
[
"86d14da29090ac75"
]
]
},
{
"id": "49b50d82dba520c7",
"type": "blockly-config",
"language": "en",
"showTrashcan": true,
"allowComments": true,
"showZoomControl": true,
"showMiniMap": true,
"enableBackPack": false,
"backpackContents": [],
"toolboxPosition": "left",
"renderer": "zelos",
"theme": "classic",
"categories": [
{
"name": "Node-RED",
"files": [
"blockly-contrib/npm/node-red-contrib-blockly/lib/nodered/nodeRedBlocksCodeGen.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/nodered/nodeRedBlocksDefs.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/nodered/toolbox.xml",
"blockly-contrib/npm/node-red-contrib-blockly/messages/en.js"
]
},
{
"name": "Objects",
"files": [
"blockly-contrib/npm/node-red-contrib-blockly/lib/json/objectBlocksCodeGen.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/json/objectBlocksDefs.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/json/toolbox.xml",
"blockly-contrib/npm/node-red-contrib-blockly/messages/en.js"
]
},
{
"name": "Buffer",
"files": [
"blockly-contrib/npm/node-red-contrib-blockly/lib/buffer/bufferBlocksCodeGen.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/buffer/bufferBlocksDefs.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/buffer/toolbox.xml",
"blockly-contrib/npm/node-red-contrib-blockly/messages/en.js"
]
},
{
"name": "Date/time",
"files": [
"blockly-contrib/npm/@blockly___SEPARATOR___field-date/dist/index.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/datetime/dateTimeBlocksCodeGen.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/datetime/dateTimeBlocksDefs.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/datetime/toolbox.xml",
"blockly-contrib/npm/node-red-contrib-blockly/messages/en.js"
]
},
{
"name": "Timer",
"files": [
"blockly-contrib/npm/node-red-contrib-blockly/lib/timer/timerBlocksCodeGen.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/timer/timerBlocksDefs.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/timer/toolbox.xml",
"blockly-contrib/npm/node-red-contrib-blockly/messages/en.js"
]
},
{
"name": "Blockly extension",
"files": [
"blockly-contrib/npm/node-red-contrib-blockly/lib/extra/extraBlocksCodeGen.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/extra/extraBlocksDefs.js",
"blockly-contrib/npm/node-red-contrib-blockly/lib/extra/toolbox.xml",
"blockly-contrib/npm/node-red-contrib-blockly/messages/en.js"
]
},
{
"name": "Blockly standard",
"files": [
"blockly-contrib/npm/node-red-contrib-blockly/lib/basic/toolbox.xml"
]
}
],
"customizeToolbox": false,
"name": "blo-config"
}]