Help with line Chart plotting 2 separate lines instead of one

Hi

Still learning, I trying to create a remote test application where I can toggle the I/O's on an external device using a Rpi which so far is going well. The simple switch and on/off buttons is working fine and was a good intro.
image

But for the the automatic switching the chart is displaying two separate lines. I'm trying to figure out how to get a single line. Any idea's?

image

My code so far is here.

[{"id":"92c9a219.972d7","type":"dsm","z":"7f79a8fd.2964d8","name":"blinking","sm_config":"{\n    \"currentState\": \"idle\",\n    \"states\": {\n        \"idle\": {\n            \"start\": \"on\",\n            \"stop\": \"idle\"\n        },\n        \"on\": {\n            \"turn_off\": \"off\",\n            \"stop\": \"idle\"\n        },\n        \"off\": {\n            \"turn_on\": \"on\",\n            \"stop\": \"idle\"\n    }\n    },\n    \"data\": {\n        \"on\": 1,\n        \"off\": 0,\n        \"on_time\": 2000,\n        \"off_time\": 2000,\n        \"blinks\": \"continuing\",\n        \"count\": 0\n    },\n    \"methods\": {\n        \n        \"setOn\": [\n\t\t\"sm.data.on_time = msg.payload;\",\n\t\t\"sm.fill = 'blue';\",\n\t\t\"sm.text = 'On time = '+sm.data.on;\"\n\t\t],\n\t\t\"setOff\": [\n\t\t\"sm.data.off_time = msg.payload;\",\n\t\t\"sm.fill = 'purple';\"\n\t\t],\n        \"init\": [\n            \"sm.schedule = function(tran, delay, msg) {\",\n            \"   timeout.id = setTimeout(function() {\",\n            \"       resume(tran, msg)\",\n            \"   },delay);\",\n            \"};\",\n            \"sta.fill = 'grey';\"\n        ],\n        \"onBeforeTransition\": [\n            \"if (!msg.topic) msg.topic = 'start';\",\n            \"if (msg.blinks) sm.data.blinks = msg.blinks;\",\n            \"if (msg.on_time) sm.data.on_time = msg.on_time;\",\n            \"if (msg.off_time) sm.data.off_time = msg.off_time;\"\n        ],\n        \"start\": [\n            \"sm.data.count = sm.data.blinks;\",\n            \"resume('turn_on', msg);\",\n            \"output = false;\"\n        ],\n        \"turn_on\": [\n            \"if (sm.data.count) {\",\n            \"   sm.schedule('turn_off', sm.data.on_time, msg);\",\n            \"   if(sm.data.blinks !== 'continuing') sm.data.count--;\",\n            \"   sm.fill = 'green';\",\n            \"   msg.payload = sm.data.on;\",\n            \"   output = true;\",\n            \"} else {\",\n            \"   sm.currentState = 'idle';\",\n            \"   sm.fill = 'grey';\",\n            \"   output = false;\",\n            \"}\"\n        ],\n        \"turn_off\": [\n            \"sm.schedule('turn_on', sm.data.off_time, msg);\",\n            \"sm.fill = 'red';\",\n            \"msg.payload = sm.data.off;\"\n        ],\n        \"stop\": [\n            \"clearTimeout(timeout.id);\",\n            \"sm.fill = 'red';\",\n            \"msg.payload = sm.data.off;\"\n        ],\n        \"status\": {\n            \"fill\": {\n                \"get\": \"sm.fill;\"\n            },\n            \"shape\": \"dot\",\n            \"text\": {\n                \"get\": \"sm.currentState;\"\n            }\n        }\n    }\n}","x":1540,"y":140,"wires":[["4f6b7b5e.cb3a34","76d67a20.bed444"]]},{"id":"362b0416.37f27c","type":"inject","z":"7f79a8fd.2964d8","name":"","topic":"stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1320,"y":160,"wires":[["92c9a219.972d7"]]},{"id":"6c703d91.b92384","type":"inject","z":"7f79a8fd.2964d8","name":"","topic":"start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1320,"y":120,"wires":[["92c9a219.972d7"]]},{"id":"11f47898.4ce3c7","type":"ui_button","z":"7f79a8fd.2964d8","name":"","group":"dbfb559b.006638","order":1,"width":1,"height":1,"passthru":false,"label":"On","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"start","x":1320,"y":20,"wires":[["92c9a219.972d7"]]},{"id":"f1922118.3b239","type":"ui_button","z":"7f79a8fd.2964d8","name":"","group":"dbfb559b.006638","order":2,"width":1,"height":1,"passthru":false,"label":"Off","tooltip":"","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"stop","x":1320,"y":60,"wires":[["92c9a219.972d7"]]},{"id":"4f6b7b5e.cb3a34","type":"ui_chart","z":"7f79a8fd.2964d8","name":"","group":"dbfb559b.006638","order":3,"width":10,"height":4,"label":"chart I/O 3","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1720,"y":140,"wires":[[]]},{"id":"b163281f.82f738","type":"ui_text_input","z":"7f79a8fd.2964d8","name":"","label":"On Time","tooltip":"","group":"dbfb559b.006638","order":4,"width":2,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"setOn","x":1030,"y":240,"wires":[["63a60d37.210c14"]]},{"id":"6b8e0493.a294dc","type":"function","z":"7f79a8fd.2964d8","name":"","func":"msg.payload *= 60000;\nreturn msg;","outputs":1,"noerr":0,"x":1340,"y":240,"wires":[["92c9a219.972d7"]]},{"id":"63a60d37.210c14","type":"change","z":"7f79a8fd.2964d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":240,"wires":[["6b8e0493.a294dc"]]},{"id":"13deee38.d9e842","type":"function","z":"7f79a8fd.2964d8","name":"","func":"msg.payload *= 60000;\nreturn msg;","outputs":1,"noerr":0,"x":1340,"y":300,"wires":[["92c9a219.972d7","8e8ec056.f86bf"]]},{"id":"7512720b.603fec","type":"change","z":"7f79a8fd.2964d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":300,"wires":[["13deee38.d9e842","a21b55b9.f90b88"]]},{"id":"76d67a20.bed444","type":"rpi-gpio out","z":"7f79a8fd.2964d8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":1710,"y":100,"wires":[]},{"id":"9ee9f99f.3fc6d8","type":"ui_text_input","z":"7f79a8fd.2964d8","name":"","label":"Off Time","tooltip":"","group":"dbfb559b.006638","order":5,"width":2,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"setOff","x":1020,"y":300,"wires":[["7512720b.603fec"]]},{"id":"a21b55b9.f90b88","type":"debug","z":"7f79a8fd.2964d8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1500,"y":340,"wires":[]},{"id":"8e8ec056.f86bf","type":"debug","z":"7f79a8fd.2964d8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1500,"y":380,"wires":[]},{"id":"dbfb559b.006638","type":"ui_group","z":"","name":"I/O 3","tab":"7bc03c24.5ef4a4","order":3,"disp":true,"width":12,"collapse":false},{"id":"7bc03c24.5ef4a4","type":"ui_tab","z":"","name":"Automated Controls","icon":"fa-cogs","order":5}]

Line chart creates one line for each topic it gets. If you'll need only one line, make sure that the messages going into chart node have same topic.
You may also find node-red-contrib-ui-state-trail as useful node to display state changes.

Awesome, finally had time to get back to this. Thanks for pointing me in the right direction.

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