Is it Possible to Collect Datas with Visualizing with Nodered


#21

Thanks for all your suppport. Everything is going well now and one more question..

Its now logging temp and humidty. Is it possible to show devices connected or disconnected with a graphic.

Graphic should take datas from devices which is defined DSM node.

Its need for statistics, for example 1st device 3 times get down this month.2.nd devices 11 times down and average is %92 like this ?


#22

Anything is possible. But it sounds like you want something quite specific to your setup. So you need to think about how to gather the data you want to display. Passing it to a widget in the dashboard is the relatively easy part.


#23

Dear @knolleary as I Shared codes before my post and just want to make a graphic with dashboard graph , just want to connect it with dsm code connected buton and when they get down and uptime it should take and show statistics.

For example ; Lazer 1: 3 times get down and ability is %98, this kind of graph chart.


#24

It is not clear (to me) what you are trying to do. Right now you have the output of the DSM node going to a button...why? Do you want to start collectind data when someone pushes the button? Right now, the button will automatically change when the gpio pin changes and you don't send the output anywhere.

If you want to collect data from the output of the DSM node, then you need to link it to a node where you collect the data and decide how to handle it. Are you looking to count how many times the state switches? then you would just add one to a counter - or do you onky want to count how many times it goes to 0?

When will the counter get reset? You will need to add node(s) to handle that case.

Take is slow and solve one issue at a time and experiment and play with things - that's the way you will learn.


#25

I decided to go step by step my project.
And take a little bit way doing this.
Now Humid and Temp is logging with time, everything is ok.
My next target is this : How can I log dsm nodes, it is like 0 is not connected, 1 is connected.

I just want to log dsm state is in my record file, how can I do this ? Thanks for now your helps.

This is my project

[{"id":"52aefd4e.740f64","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"40","intype":"tri","debounce":"25","read":false,"x":213.00003051757812,"y":67,"wires":[["156168cd.c7a547"]]},{"id":"156168cd.c7a547","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 1 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 1 Error!!!';\"\n    }\n}","x":399.0000305175781,"y":65,"wires":[["64f79176.65005"]]},{"id":"64f79176.65005","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 1","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":612.0000762939453,"y":65,"wires":[[]]},{"id":"18ad9b4e.092f4d","type":"ui_gauge","z":"1ecb654.7ecff9b","name":"Temp Gauge","group":"d98dc4a9.46b7b8","order":0,"width":0,"height":0,"gtype":"gage","title":"Temp Gauge","label":"°C","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#fb9b44","#ca3838"],"seg1":"","seg2":"","x":763.4701194763184,"y":485.649977684021,"wires":[]},{"id":"1ca042f6.aa8b95","type":"ui_gauge","z":"1ecb654.7ecff9b","name":"Humid Gauge","group":"4e5ca64e.71c688","order":0,"width":0,"height":0,"gtype":"gage","title":"Humid Gauge","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":726.4701118469238,"y":672.6499032974243,"wires":[]},{"id":"6f2a2d17.1ffc64","type":"ui_chart","z":"1ecb654.7ecff9b","name":"Humid Graph","group":"4e5ca64e.71c688","order":0,"width":0,"height":0,"label":"Humid Graph","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":723.4700927734375,"y":636.649956703186,"wires":[[],[]]},{"id":"741ed75e.8ddc1","type":"ui_chart","z":"1ecb654.7ecff9b","name":"Temp Graph","group":"d98dc4a9.46b7b8","order":0,"width":0,"height":0,"label":"Temp Graph","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"50","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":758.4701461791992,"y":451.64998149871826,"wires":[[],[]]},{"id":"f1e2c76f.df8308","type":"function","z":"1ecb654.7ecff9b","name":"Humidity","func":"msg.payload = msg.humidity;\nreturn msg;","outputs":1,"noerr":0,"x":524.4701499938965,"y":642.6499452590942,"wires":[["1ca042f6.aa8b95","6f2a2d17.1ffc64","5a28295c.893a28"]]},{"id":"8909c15c.86df4","type":"function","z":"1ecb654.7ecff9b","name":"Temperature","func":"msg.payload = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":543.470085144043,"y":544.6499710083008,"wires":[["18ad9b4e.092f4d","741ed75e.8ddc1","5a28295c.893a28"]]},{"id":"7a79211d.cc9cf","type":"rpi-dht22","z":"1ecb654.7ecff9b","name":"","topic":"Isi/Nem","dht":"11","pintype":"0","pin":4,"x":330.47007751464844,"y":594.6499862670898,"wires":[["f1e2c76f.df8308","8909c15c.86df4"]]},{"id":"d5137d8d.98fe7","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"7","intype":"tri","debounce":"25","read":false,"x":155.47007751464844,"y":592.6499862670898,"wires":[["7a79211d.cc9cf"]]},{"id":"cf178d5f.19c83","type":"file","z":"1ecb654.7ecff9b","name":"Rec","filename":"Temp&Humid","appendNewline":true,"createDir":true,"overwriteFile":"false","x":1282.4701614379883,"y":551.6499843597412,"wires":[[]]},{"id":"a2c8973f.9ffd18","type":"inject","z":"1ecb654.7ecff9b","name":"","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":false,"onceDelay":0.1,"x":169.00005340576172,"y":552.0000276565552,"wires":[["7a79211d.cc9cf"]]},{"id":"5a28295c.893a28","type":"function","z":"1ecb654.7ecff9b","name":"Rec Function","func":"var d = new Date();\nvar options = { timeZone: 'UTC', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second:'2-digit'};\nvar _resultDate = d.toLocaleDateString('de-CH', options);\nmsg.payload = _resultDate + ' T:' + msg.payload + ' H:' + msg.humidity;\nreturn msg;","outputs":1,"noerr":0,"x":1014.1911239624023,"y":550.5486068725586,"wires":[["cf178d5f.19c83"]]},{"id":"89d153e7.3e87c","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"38","intype":"tri","debounce":"25","read":false,"x":208.01734924316406,"y":111.01041412353516,"wires":[["24357a2d.4f0c46"]]},{"id":"24357a2d.4f0c46","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 2 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 2 Error!!!';\"\n    }\n}","x":394.01734924316406,"y":109.01041412353516,"wires":[["d2fb8b76.3ad8a8"]]},{"id":"d2fb8b76.3ad8a8","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 2","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":607.0173950195312,"y":109.01041412353516,"wires":[[]]},{"id":"6fb48a6.4e2d474","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"37","intype":"tri","debounce":"25","read":false,"x":211.01734924316406,"y":156.01040649414062,"wires":[["a77bb4e8.9412b8"]]},{"id":"a77bb4e8.9412b8","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 3 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 3 Error!!!';\"\n    }\n}","x":397.01734924316406,"y":154.01040649414062,"wires":[["e8cd4c0a.46363"]]},{"id":"e8cd4c0a.46363","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 3","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":610.0173950195312,"y":154.01040649414062,"wires":[[]]},{"id":"8081637f.aed4c","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"36","intype":"tri","debounce":"25","read":false,"x":211.01734924316406,"y":196.01040649414062,"wires":[["3a0798af.be5e28"]]},{"id":"3a0798af.be5e28","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 4 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 4 Error!!!';\"\n    }\n}","x":397.01734924316406,"y":194.01040649414062,"wires":[["dfbacbba.c96588"]]},{"id":"dfbacbba.c96588","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 4","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":610.0173950195312,"y":194.01040649414062,"wires":[[]]},{"id":"39daf8d9.4f9ce8","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"35","intype":"tri","debounce":"25","read":false,"x":211.01734924316406,"y":241.01040649414062,"wires":[["3bb7fdd7.be8552"]]},{"id":"3bb7fdd7.be8552","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 5 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 5 Error!!!';\"\n    }\n}","x":397.01734924316406,"y":239.01040649414062,"wires":[["4698f47b.bdf69c"]]},{"id":"4698f47b.bdf69c","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 5","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":610.0173950195312,"y":239.01040649414062,"wires":[[]]},{"id":"a24d6d28.2e65b","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"33","intype":"tri","debounce":"25","read":false,"x":213.01734924316406,"y":279.0104064941406,"wires":[["d4c05901.b020b8"]]},{"id":"d4c05901.b020b8","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 6 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 6 Error!!!';\"\n    }\n}","x":399.01734924316406,"y":277.0104064941406,"wires":[["49f8a8b6.e31178"]]},{"id":"49f8a8b6.e31178","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 6","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":612.0173950195312,"y":277.0104064941406,"wires":[[]]},{"id":"8e766a0b.e97ba8","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"32","intype":"tri","debounce":"25","read":false,"x":211.01734924316406,"y":326.0104064941406,"wires":[["5c7dea0f.8d3414"]]},{"id":"5c7dea0f.8d3414","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 7 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 7 Error!!!';\"\n    }\n}","x":397.01734924316406,"y":324.0104064941406,"wires":[["4c25e6ff.abf048"]]},{"id":"4c25e6ff.abf048","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 7","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":610.0173950195312,"y":324.0104064941406,"wires":[[]]},{"id":"9eb35a96.a65658","type":"rpi-gpio in","z":"1ecb654.7ecff9b","name":"","pin":"31","intype":"tri","debounce":"25","read":false,"x":213.01734924316406,"y":364.0104064941406,"wires":[["33cc99bd.ccd4b6"]]},{"id":"33cc99bd.ccd4b6","type":"dsm","z":"1ecb654.7ecff9b","name":"state right","sm_config":"{\n    \"triggerInput\": \"payload\",\n    \"currentState\": \"running\",\n    \"states\": {\n        \"stopped\": {\n            \"0\": \"running\"\n        },\n        \"running\": {\n            \"1\": \"stopped\"\n        }\n    },\n    \"methods\": {\n        \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n        \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 8 Working';\",\n        \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 8 Error!!!';\"\n    }\n}","x":399.01734924316406,"y":362.0104064941406,"wires":[["823fe41c.8f8978"]]},{"id":"823fe41c.8f8978","type":"ui_button","z":"1ecb654.7ecff9b","name":"Laser 8","group":"c3ea62eb.8eeac","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":612.0173950195312,"y":362.0104064941406,"wires":[[]]},{"id":"c3ea62eb.8eeac","type":"ui_group","z":"","name":"Assembly Lines","tab":"ed5b6d19.3a506","disp":true,"width":"6","collapse":false},{"id":"d98dc4a9.46b7b8","type":"ui_group","z":"","name":"Assembly Lines ","tab":"ed5b6d19.3a506","disp":true,"width":"6","collapse":false},{"id":"4e5ca64e.71c688","type":"ui_group","z":"","name":"Assembly Lines  ","tab":"ed5b6d19.3a506","disp":true,"width":"6","collapse":false},{"id":"ed5b6d19.3a506","type":"ui_tab","z":"","name":"Chasis Lines","icon":"dashboard"}] ```

#26

First thing to do is connect a debug node to the output of the dsm node so you can see what it is sending. Then you can decide how to format it to send to the log. You could use a function node to format it or you might be able to use the 'change' node depending on what the data looks like and what you want entered in the log.

So what do you want it to look like and what does it currently look like?"


#27

I solved problem with debug advice, thank you.

Now next step is this for me..

Now I can logging with DSM node my devices.
How can I calculate results time between up and down time and saving this data.

23.10.2018, 11:35:09 Laser 2:1
23.10.2018, 11:35:28 Laser 2:0
19 second

23.10.2018, 11:35:50 Laser 5:1
23.10.2018, 11:36:02 Laser 5:0
12second

23.10.2018, 11:38:44 Conveyor:1
23.10.2018, 11:39:27 Conveyor:0
43 second

23.10.2018, 11:39:28 Light Barrier Glass:1
23.10.2018, 11:39:51 Light Barrier Glass:0
23 second


#28

In javascript you can calculate the difference between two times just by subtracting one timestamp from the other.


#29

Dear @Colin I dont have any or enough experince javascript, could you please help me more, where can I get code or if it is basic, please help me.


#30

I suggest taking a couple of days out to work through the tuturial at https://www.learnenough.com/javascript-tutorial (which is free to use online). That will give you the basics of javascript.


#31

Dear Colin I dont have enough time and need to make it.
Now Im logging data what time it gets down and up, maybe I have to change my idea in function node.

Is it possible to logging time differences up and down time,


#32

Presumably you think that I do have enough time. Is this for work or home?


#33

No I dont think like this. Everyone busy , I want to help a trainee , he didnt speak English and I want to help him.


#34

Again me.

Is it possible to save dsm node 1-0 values to sqlite ?
I want to save this values and any time want to reach from DB


#35

And again the answer is yes. If you want ideas on how to do it then you need to define in much more detail what you want to do.


#36

Ok I will explain it with graph soon thanks.


#37

Fİrst Step.

I installed Sqlite in RPI and now I want to save running and stopped status in DB. How can I do this ?


#38

Do you understand how to create sqlite tables and how to use the sqlite nodes to write data to the database?


#39

I already installed SQLite on my RPI and also created DB and some tables. But I dont know anything about sqlite nodes and how it works, how it save values to DB


#40

did you try a search of the flows using 'sqlite'? Always a idea of a place you might find something helpful...