Hello dear @E1cid I have done your flow. I need a little bit more help.
this is my flow
[{"id":"5bc4fcf5.332164","type":"subflow","name":"Subflow 1","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"2c29ca9d.1f3726"}]}],"out":[{"x":920,"y":100,"wires":[{"id":"26fe58d.da0d2a8","port":0}]},{"x":540,"y":120,"wires":[{"id":"c3cccc67.eba87","port":0}]}]},{"id":"2c29ca9d.1f3726","type":"function","z":"5bc4fcf5.332164","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":200,"y":80,"wires":[["c3cccc67.eba87","dc32c467.fb1168"]]},{"id":"dc32c467.fb1168","type":"switch","z":"5bc4fcf5.332164","name":"allow only 1 ","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":80,"wires":[["90e7351e.a17e68"],["54e68c10.45d2f4"]]},{"id":"c3cccc67.eba87","type":"trigger","z":"5bc4fcf5.332164","op1":"","op2":"Kapı 30 saniyedir açık!!","op1type":"nul","op2type":"str","duration":"30","extend":false,"units":"s","reset":"1","bytopic":"all","name":"","x":390,"y":120,"wires":[[]]},{"id":"90e7351e.a17e68","type":"change","z":"5bc4fcf5.332164","name":"High","rules":[{"t":"set","p":"bc","pt":"msg","to":"orange","tot":"str"},{"t":"set","p":"status","pt":"msg","to":"Kapalı","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":80,"wires":[["26fe58d.da0d2a8"]]},{"id":"54e68c10.45d2f4","type":"change","z":"5bc4fcf5.332164","name":"Low","rules":[{"t":"set","p":"bc","pt":"msg","to":"purple","tot":"str"},{"t":"set","p":"status","pt":"msg","to":"Açık","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":120,"wires":[["26fe58d.da0d2a8"]]},{"id":"26fe58d.da0d2a8","type":"function","z":"5bc4fcf5.332164","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":780,"y":100,"wires":[[]]},{"id":"8665aba4.942bc8","type":"change","z":"f3966c66.61ab9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"},{"t":"set","p":"topic","pt":"msg","to":"epoch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":180,"wires":[["7ace719e.dd215"]]},{"id":"c3ed8690.589198","type":"switch","z":"f3966c66.61ab9","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":340,"y":200,"wires":[["8665aba4.942bc8"],["88fc78b8.fd7988"]]},{"id":"88fc78b8.fd7988","type":"change","z":"f3966c66.61ab9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"},{"t":"set","p":"topic","pt":"msg","to":"durum","tot":"str"},{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":220,"wires":[["7ace719e.dd215"]]},{"id":"7ace719e.dd215","type":"join","z":"f3966c66.61ab9","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":670,"y":200,"wires":[["a26b3aa1.1029c8","ffbc2c4e.3259e"]]},{"id":"a26b3aa1.1029c8","type":"template","z":"f3966c66.61ab9","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"INSERT INTO 'sensor_durumu' ('durum','epoc') VALUES ({{payload.durum}},{{payload.epoch}});","output":"str","x":850,"y":200,"wires":[["1fa43285.c6713d"]]},{"id":"ffbc2c4e.3259e","type":"function","z":"f3966c66.61ab9","name":"","func":"msg.payload = (msg.payload.durum - msg.payload.epoch)/1000;\nmsg.topic = \"time diff\";\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":120,"wires":[["53fb1968.72f428","b179a5fa.9bd698"]]},{"id":"1fa43285.c6713d","type":"debug","z":"f3966c66.61ab9","name":"store in db","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1060,"y":200,"wires":[]},{"id":"53fb1968.72f428","type":"ui_chart","z":"f3966c66.61ab9","name":"","group":"7f157da0.9d75f4","order":4,"width":"10","height":"10","label":"mySQL data","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"bezier","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"1000","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"x":1060,"y":120,"wires":[[]]},{"id":"b179a5fa.9bd698","type":"debug","z":"f3966c66.61ab9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1080,"y":80,"wires":[]},{"id":"ab569222.21cbe","type":"sqlite","z":"f3966c66.61ab9","mydb":"e35ee04b.a8bff","sqlquery":"msg.topic","sql":"","name":"sqliteDB","x":960,"y":420,"wires":[["255d44ec.4fe69c"]]},{"id":"bbc0d33e.3c661","type":"ui_button","z":"f3966c66.61ab9","name":"","group":"c55d32a2.85a79","order":9,"width":"3","height":"1","passthru":false,"label":"B5 Kapı - 1 {{msg.status}}","color":"","bgcolor":"{{bc}}","icon":"","payload":"1","payloadType":"num","topic":"topic","x":590,"y":340,"wires":[[]]},{"id":"decb95c3.0e60b8","type":"template","z":"f3966c66.61ab9","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"INSERT INTO 'sensor_durumu' ('durum','epoc') VALUES ({{pyload}},{{zaman}});","output":"str","x":800,"y":420,"wires":[["ab569222.21cbe"]]},{"id":"f94f4ab.35715b8","type":"rpi-gpio in","z":"f3966c66.61ab9","name":"","pin":"40","intype":"down","debounce":"25","read":false,"x":130,"y":380,"wires":[["62f47367.f400cc","516c7814.fdeab8"]]},{"id":"62f47367.f400cc","type":"subflow:5bc4fcf5.332164","z":"f3966c66.61ab9","name":"Pin Status Monitoring","x":340,"y":380,"wires":[["bbc0d33e.3c661","c3ed8690.589198"],["9011dffb.52cb5"]]},{"id":"9011dffb.52cb5","type":"ui_toast","z":"f3966c66.61ab9","position":"dialog","displayTime":"","highlight":"","outputs":1,"ok":"OK","cancel":"","topic":"Uyarı","name":"","x":570,"y":380,"wires":[[]]},{"id":"b6b8950.87d4068","type":"function","z":"f3966c66.61ab9","name":"Zamanın Oluşturulması","func":"var d= new Date();\nvar zaman = d.getTime();\nmsg.zaman=zaman;\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":420,"wires":[["decb95c3.0e60b8"]]},{"id":"255d44ec.4fe69c","type":"debug","z":"f3966c66.61ab9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1110,"y":420,"wires":[]},{"id":"516c7814.fdeab8","type":"dsm","z":"f3966c66.61ab9","name":"sensör_durumu","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 \"1\": \"sta.fill='green';msg.background='red';msg.label='S';\",\n \"0\": \"sta.fill='red';msg.background='green';msg.label='S';\"\n }\n}","x":330,"y":420,"wires":[["b6b8950.87d4068","decb95c3.0e60b8"]]},{"id":"7f157da0.9d75f4","type":"ui_group","z":"","name":"Home","tab":"6f5ce300.48f7bc","order":10,"disp":true,"width":"10","collapse":false},{"id":"e35ee04b.a8bff","type":"sqlitedb","z":"","db":"/var/www/html/database/kapi","mode":"RWC"},{"id":"c55d32a2.85a79","type":"ui_group","z":"","name":"Orginal","tab":"6f5ce300.48f7bc","order":9,"disp":true,"width":"6","collapse":false},{"id":"6f5ce300.48f7bc","type":"ui_tab","z":"","name":"Mercedes-Benz Türk AŞ Kamyon Fabrikası Hol Kapıları","icon":"dashboard","order":1}]
And after injection it looks like at photo. Is it possible to calculate automatically and showing the screen time difference.
This is my flow photos
This is my dashboard photo.