-
Notifications
You must be signed in to change notification settings - Fork 4
Delayed message
cflurin edited this page Sep 13, 2018
·
2 revisions
A single node approach to store a delay (local) and to send a msg to the output after the delay.
{
"data": {
"delay": 3000
},
"methods": {
"setDelay": "sm.data.delay = msg.payload;",
"default": {
"name": "timer",
"param": "delay",
"do": [
"node.status({fill:'blue', shape:'ring', text:msg.payload});",
"node.send(msg);"
]
},
"status": {
"fill": "blue",
"shape": "dot",
"text": {
"get": "sm.data.delay"
}
}
}
}
[{"id":"b515039c.868a4","type":"inject","z":"57ef434a.058a6c","name":"","topic":"setDelay","payload":"2000","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":3320,"wires":[["ca209e47.928a3"]]},{"id":"a9267621.f4dfa8","type":"inject","z":"57ef434a.058a6c","name":"","topic":"","payload":"delayed msg","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":3400,"wires":[["ca209e47.928a3"]]},{"id":"1c7b4650.41cb3a","type":"inject","z":"57ef434a.058a6c","name":"","topic":"setDelay","payload":"4000","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":111,"y":3358,"wires":[["ca209e47.928a3"]]},{"id":"4b822dd8.f6c324","type":"debug","z":"57ef434a.058a6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":450,"y":3360,"wires":[]},{"id":"ca209e47.928a3","type":"dsm","z":"57ef434a.058a6c","name":"delay","sm_config":"{\n \"data\": {\n \"delay\": 3000\n },\n \"methods\": {\n \"setDelay\": \"sm.data.delay = msg.payload;\",\n \"default\": {\n \"name\": \"timer\",\n \"param\": \"delay\",\n \"do\": [\n \"node.status({fill:'blue', shape:'ring', text:msg.payload});\",\n \"node.send(msg);\"\n ]\n },\n \"status\": {\n \"fill\": \"blue\",\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"sm.data.delay\"\n }\n }\n }\n}","x":300,"y":3360,"wires":[["4b822dd8.f6c324"]]}]