Need help displaying data each interval

Im having trouble to display data every 5 seconds interval after using the switch node. But when i debug the node before it reaches the switch node, the output shows what its supposed to every 5 seconds. Hope you guys can help me with this. Below is my flow;

[{"id":"b4f66c67.11694","type":"inject","z":"33298230.b1694e","name":"","topic":"","payload":"StringData","payloadType":"global","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":120,"wires":[["b5a2f96d.2d98b8"]]},{"id":"4a8bb6e5.0628e8","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":60,"wires":[]},{"id":"fee2783.6487988","type":"inject","z":"33298230.b1694e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":180,"wires":[["b772f531.8eeb48"]]},{"id":"b772f531.8eeb48","type":"function","z":"33298230.b1694e","name":"","func":"global.set(\"StringData\",\"1 2 3 4 5 \");\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":180,"wires":[[]]},{"id":"b5a2f96d.2d98b8","type":"split","z":"33298230.b1694e","name":"","splt":" ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":410,"y":120,"wires":[["4a8bb6e5.0628e8","a2538e41.8e82c"]]},{"id":"a2538e41.8e82c","type":"change","z":"33298230.b1694e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":140,"wires":[["7600ed7b.9c0a34"]]},{"id":"7600ed7b.9c0a34","type":"switch","z":"33298230.b1694e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":720,"y":240,"wires":[["e0ae2ad8.7654b8"],["420444a4.20cf0c"],["cda710de.4cb8b"],["9901502d.ab861"],["f9288d5b.24a72"]]},{"id":"e0ae2ad8.7654b8","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":880,"y":180,"wires":[]},{"id":"420444a4.20cf0c","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":880,"y":220,"wires":[]},{"id":"cda710de.4cb8b","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":260,"wires":[]},{"id":"9901502d.ab861","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":300,"wires":[]},{"id":"f9288d5b.24a72","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":340,"wires":[]}]

what datatype are you sending to the switch and what datatype are you testing?

p.s. you have a second bug you will need to fix, but I think you shold be able to find it.

I was sending the number 1-5 with the split function everytime it founds a space. The data shows perfectly in each interval of 5 secs before i add in the switch node so it displays the data in different outputs. I think this flow works better.

[{"id":"4a8bb6e5.0628e8","type":"debug","z":"33298230.b1694e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":60,"wires":[]},{"id":"fee2783.6487988","type":"inject","z":"33298230.b1694e","name":"","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":120,"wires":[["b772f531.8eeb48"]]},{"id":"b772f531.8eeb48","type":"function","z":"33298230.b1694e","name":"","func":"var newMsg = {payload: \"1 2 3 4 5 \"}\nreturn newMsg;","outputs":1,"noerr":0,"x":260,"y":120,"wires":[["b5a2f96d.2d98b8"]]},{"id":"b5a2f96d.2d98b8","type":"split","z":"33298230.b1694e","name":"","splt":" ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":410,"y":120,"wires":[["4a8bb6e5.0628e8","a2538e41.8e82c"]]},{"id":"a2538e41.8e82c","type":"change","z":"33298230.b1694e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":140,"wires":[["7600ed7b.9c0a34"]]},{"id":"7600ed7b.9c0a34","type":"switch","z":"33298230.b1694e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":720,"y":240,"wires":[["e0ae2ad8.7654b8"],["420444a4.20cf0c"],["cda710de.4cb8b"],["9901502d.ab861"],["f9288d5b.24a72"]]},{"id":"e0ae2ad8.7654b8","type":"debug","z":"33298230.b1694e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":180,"wires":[]},{"id":"420444a4.20cf0c","type":"debug","z":"33298230.b1694e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":220,"wires":[]},{"id":"cda710de.4cb8b","type":"debug","z":"33298230.b1694e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":260,"wires":[]},{"id":"9901502d.ab861","type":"debug","z":"33298230.b1694e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":300,"wires":[]},{"id":"f9288d5b.24a72","type":"debug","z":"33298230.b1694e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":890,"y":340,"wires":[]}]

try changing your debug nodes to display the 'Complete msg object' and see it that gives you more to debug with

Also I would shut off the internal so you can manually inject to see what happens each time and I'd try just using 2 numbers instead of 5

1 Like

Have an especially close look at the msg.parts.index property you are testing for. You can even change the debug node just to show you this property:


[{"id":"23c12be8.0d7cec","type":"inject","z":"f954564f.03e718","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":460,"y":2860,"wires":[["f4ac441f.17e598"]]},{"id":"f4ac441f.17e598","type":"function","z":"f954564f.03e718","name":"","func":"var newMsg = {payload: \"1 2 3 4 5 \"}\nreturn newMsg;","outputs":1,"noerr":0,"x":620,"y":2860,"wires":[["637ce2c3.245a94"]]},{"id":"637ce2c3.245a94","type":"split","z":"f954564f.03e718","name":"","splt":" ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":770,"y":2860,"wires":[["175d4e78.8b9622"]]},{"id":"175d4e78.8b9622","type":"change","z":"f954564f.03e718","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":2860,"wires":[["87c8edb5.d49b7","b60ec983.343638"]]},{"id":"87c8edb5.d49b7","type":"switch","z":"f954564f.03e718","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"}],"checkall":"true","repair":false,"outputs":5,"x":1070,"y":2960,"wires":[["cae54f4d.8cb5"],["e5c86628.8c1eb8"],["39db57a6.213458"],["e97ceb4d.bf9ab8"],["6af8fa7d.b9908c"]]},{"id":"cae54f4d.8cb5","type":"debug","z":"f954564f.03e718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":2920,"wires":[]},{"id":"e5c86628.8c1eb8","type":"debug","z":"f954564f.03e718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":2960,"wires":[]},{"id":"39db57a6.213458","type":"debug","z":"f954564f.03e718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":3000,"wires":[]},{"id":"e97ceb4d.bf9ab8","type":"debug","z":"f954564f.03e718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":3040,"wires":[]},{"id":"6af8fa7d.b9908c","type":"debug","z":"f954564f.03e718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1250,"y":3080,"wires":[]},{"id":"b60ec983.343638","type":"debug","z":"f954564f.03e718","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"parts.index","targetType":"msg","x":1140,"y":2820,"wires":[]}]

I modified your flow so that you can manually inject and will see just this property in the debug.
Best regards Johannes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.