zenofmud:
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.
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"}] ```