This should be simple I think, but I am just not getting it. I have a sequence of operations to perform with a delay between each operation.
[ { "index": 1,"channel": 31, "level": 1, "delay": 2 }, { "index": 2,"channel": 35, "level": 1, "delay": 120 }, { "index": 3,"channel": 35, "level": 0, "delay": 2 }, { "index": 4,"channel": 36, "level": 1, "delay": 120 }, { "index": 5,"channel": 36, "level": 0, "delay": 2 }, { "index": 6,"channel": 33, "level": 1, "delay": 120 }, { "index": 7,"channel": 33, "level": 0, "delay": 2 }, { "index": 8,"channel": 31, "level": 0, "delay": 2 } ]
The flow looks like this:
Split the Sequence into separate messages, fill a msg.delay parameter which the variable delay will use, and then print each message.
And the content of the flow:
[{"id":"6243997b.f97288","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"acb0202b.01c01","type":"delay","z":"6243997b.f97288","name":"Variable Delay","pauseType":"delayv","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":700,"y":80,"wires":[["d838f6b5.c42358"]]},{"id":"2e46b9c2.3c88c6","type":"inject","z":"6243997b.f97288","name":"Sequence","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"[{\"index\":1,\"channel\":31,\"level\":1,\"delay\":2},{\"index\":2,\"channel\":35,\"level\":1,\"delay\":120},{\"index\":3,\"channel\":35,\"level\":0,\"delay\":2},{\"index\":4,\"channel\":36,\"level\":1,\"delay\":120},{\"index\":5,\"channel\":36,\"level\":0,\"delay\":2},{\"index\":6,\"channel\":33,\"level\":1,\"delay\":120},{\"index\":7,\"channel\":33,\"level\":0,\"delay\":2},{\"index\":8,\"channel\":31,\"level\":0,\"delay\":2}]","payloadType":"json","x":170,"y":80,"wires":[["fcbb279a.fb3068"]]},{"id":"d838f6b5.c42358","type":"debug","z":"6243997b.f97288","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":80,"wires":[]},{"id":"e9f83c3f.22184","type":"function","z":"6243997b.f97288","name":"Fill msg.delay","func":"msg.delay = msg.payload.delay\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":80,"wires":[["acb0202b.01c01"]]},{"id":"fcbb279a.fb3068","type":"split","z":"6243997b.f97288","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":330,"y":80,"wires":[["e9f83c3f.22184"]]}]
There are two problems with this - first the output order of the messages is sorted which I do not want, the sequence in the input should be left alone. Then the delay between the messages is not being respected. I am assuming it is in seconds, but did test *1000 in case it is ms.
Can someone help me along? Thank you in advance.