Here is a test flow that may help you with using subflows
and context stuff.
I had a real bad time at the start and this kind of helped.
[{"id":"480c6735eef22428","type":"subflow","name":"Get parent flow context example","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"0baab8933b6c881b"}]}],"out":[{"x":410,"y":80,"wires":[{"id":"0baab8933b6c881b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99"},{"id":"0baab8933b6c881b","type":"function","z":"480c6735eef22428","name":"parent context get","func":"msg.payload = flow.get(\"$parent.example\");\nreturn msg;\n// flow.set(\"$parent.Timer\"+x, x);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":80,"wires":[[]]},{"id":"bc62956f2461c1bb","type":"inject","z":"7e987ddf260bdf0d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"A","payloadType":"str","x":110,"y":1950,"wires":[["4bc259bbc93e8c1d"]]},{"id":"1da3c7e9fc2e9311","type":"inject","z":"7e987ddf260bdf0d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"B","payloadType":"str","x":110,"y":1990,"wires":[["4bc259bbc93e8c1d"]]},{"id":"f9e8ec3151fa7e4b","type":"inject","z":"7e987ddf260bdf0d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":2090,"wires":[["9b854c5131989160","8e7dfd53955cbfad"]]},{"id":"4bc259bbc93e8c1d","type":"change","z":"7e987ddf260bdf0d","name":"","rules":[{"t":"set","p":"example","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":1970,"wires":[[]]},{"id":"ed2b683cd58e129f","type":"debug","z":"7e987ddf260bdf0d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":2090,"wires":[]},{"id":"9b854c5131989160","type":"subflow:480c6735eef22428","z":"7e987ddf260bdf0d","name":"","x":350,"y":2090,"wires":[["ed2b683cd58e129f"]]},{"id":"ef3e11816c8dc078","type":"debug","z":"7e987ddf260bdf0d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":480,"y":2150,"wires":[]},{"id":"8e7dfd53955cbfad","type":"change","z":"7e987ddf260bdf0d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"example","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":2150,"wires":[["ef3e11816c8dc078"]]}]
Hope it helps.
You just press the A
or B
node and then the timestamp
node and look at the two debug nodes.