hello Here is my problem I have to make a dashboard which indicates the stopping time of three different stations (stop by switch) with cummul + reset and an indication of the total temp with cummul also but what I have problem is that the temp total must stop when all stations are on. (sorry for the google translation)
[
{
"id": "d0c67fe9591b0f00",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8c598fca9b188070",
"type": "rpi-gpio in",
"z": "d0c67fe9591b0f00",
"name": "",
"pin": "4",
"intype": "down",
"debounce": "25",
"read": false,
"bcm": true,
"x": 90,
"y": 160,
"wires": [
[
"ab53647bf7fdd738",
"bd86cc6f65d66a8c"
]
]
},
{
"id": "457e1e6cf1ab284a",
"type": "dsm",
"z": "d0c67fe9591b0f00",
"name": "operating time",
"sm_config": "{\n \"currentState\": \"stopped\",\n \"states\": {\n \"stopped\": {\n \"on\": \"started\"\n },\n \"started\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n },\n \"counting\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n }\n },\n \"data\": {\n \"prev_time\": null,\n \"time\": 0,\n \"seconds\": 0,\n \"interval\": 1,\n \"interval_output\": true,\n \"hms_format\": true\n },\n \"methods\": {\n \"init\": [\n \"sm.calc_time = function() {\",\n \" var now = Date.now();\",\n \" sm.data.time += now - sm.data.prev_time;\",\n \" sm.data.prev_time = now;\",\n \" sm.data.seconds = Math.round(sm.data.time / 1000);\",\n \"};\",\n \"sm.sec2hhmmss = function(sec) {\",\n \"var t = {};\",\n \"t.h = pad(Math.floor(sec / 3600));\",\n \"sec %= 3600;\",\n \"t.m = pad(Math.floor(sec / 60));\",\n \"t.s = pad(sec % 60);\",\n \"return t.h+':'+t.m+':'+t.s;\",\n \"};\"\n ],\n \"on\": [\n \"if (sm.currentState === 'started') {\",\n \" sm.data.prev_time = Date.now();\",\n \" resume('inc', msg);\",\n \"}\",\n \"output = false;\"\n ],\n \"inc\": [\n \"timeout.interval = setTimeout(function() {\",\n \" sm.calc_time();\",\n \" msg.data = sm.data;\",\n \" if (sm.data.interval_output) {\",\n \" msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\",\n \" node.send(msg);\",\n \" }\",\n \" resume('inc', msg);\",\n \"}, sm.data.interval*1000);\",\n \"output = false;\"\n ],\n \"off\": [\n \"clearTimeout(timeout.interval);\",\n \"sm.calc_time();\",\n \"msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\"\n ],\n \"reset\": [\n \"sm.data.time = 0;\",\n \"sm.data.seconds = 0;\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.currentState === 'counting' ? 'green' : 'grey';\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"'time ' + (sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds);\"\n }\n }\n }\n}\n",
"x": 450,
"y": 100,
"wires": [
[
"769b622a5cba09b2"
]
]
},
{
"id": "ab53647bf7fdd738",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "on",
"func": "if (msg.payload == 1){\n msg.topic = \"on\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 100,
"wires": [
[
"457e1e6cf1ab284a"
]
]
},
{
"id": "bd86cc6f65d66a8c",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "off",
"func": "if (msg.payload == 0){\n msg.topic = \"off\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 180,
"wires": [
[
"457e1e6cf1ab284a",
"397a7b66eb6280e0"
]
]
},
{
"id": "769b622a5cba09b2",
"type": "ui_text",
"z": "d0c67fe9591b0f00",
"group": "338ade4865229a46",
"order": 1,
"width": 0,
"height": 0,
"name": "",
"label": "poste1",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"x": 650,
"y": 100,
"wires": []
},
{
"id": "8ee12ae98a8e02da",
"type": "rpi-gpio in",
"z": "d0c67fe9591b0f00",
"name": "",
"pin": "17",
"intype": "down",
"debounce": "25",
"read": false,
"bcm": true,
"x": 100,
"y": 340,
"wires": [
[
"b48e5058b0a6761b",
"61269ce5b826c9c7"
]
]
},
{
"id": "40a0fca564be2a2b",
"type": "dsm",
"z": "d0c67fe9591b0f00",
"name": "operating time",
"sm_config": "{\n \"currentState\": \"stopped\",\n \"states\": {\n \"stopped\": {\n \"on\": \"started\"\n },\n \"started\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n },\n \"counting\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n }\n },\n \"data\": {\n \"prev_time\": null,\n \"time\": 0,\n \"seconds\": 0,\n \"interval\": 1,\n \"interval_output\": true,\n \"hms_format\": true\n },\n \"methods\": {\n \"init\": [\n \"sm.calc_time = function() {\",\n \" var now = Date.now();\",\n \" sm.data.time += now - sm.data.prev_time;\",\n \" sm.data.prev_time = now;\",\n \" sm.data.seconds = Math.round(sm.data.time / 1000);\",\n \"};\",\n \"sm.sec2hhmmss = function(sec) {\",\n \"var t = {};\",\n \"t.h = pad(Math.floor(sec / 3600));\",\n \"sec %= 3600;\",\n \"t.m = pad(Math.floor(sec / 60));\",\n \"t.s = pad(sec % 60);\",\n \"return t.h+':'+t.m+':'+t.s;\",\n \"};\"\n ],\n \"on\": [\n \"if (sm.currentState === 'started') {\",\n \" sm.data.prev_time = Date.now();\",\n \" resume('inc', msg);\",\n \"}\",\n \"output = false;\"\n ],\n \"inc\": [\n \"timeout.interval = setTimeout(function() {\",\n \" sm.calc_time();\",\n \" msg.data = sm.data;\",\n \" if (sm.data.interval_output) {\",\n \" msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\",\n \" node.send(msg);\",\n \" }\",\n \" resume('inc', msg);\",\n \"}, sm.data.interval*1000);\",\n \"output = false;\"\n ],\n \"off\": [\n \"clearTimeout(timeout.interval);\",\n \"sm.calc_time();\",\n \"msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\"\n ],\n \"reset\": [\n \"sm.data.time = 0;\",\n \"sm.data.seconds = 0;\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.currentState === 'counting' ? 'green' : 'grey';\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"'time ' + (sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds);\"\n }\n }\n }\n}\n",
"x": 450,
"y": 280,
"wires": [
[
"f5e4f31b317dded8"
]
]
},
{
"id": "b48e5058b0a6761b",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "on",
"func": "if (msg.payload == 1){\n msg.topic = \"on\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 280,
"wires": [
[
"40a0fca564be2a2b"
]
]
},
{
"id": "61269ce5b826c9c7",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "off",
"func": "if (msg.payload == 0){\n msg.topic = \"off\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 360,
"wires": [
[
"40a0fca564be2a2b",
"397a7b66eb6280e0"
]
]
},
{
"id": "f5e4f31b317dded8",
"type": "ui_text",
"z": "d0c67fe9591b0f00",
"group": "338ade4865229a46",
"order": 1,
"width": 0,
"height": 0,
"name": "",
"label": "poste2",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"x": 650,
"y": 280,
"wires": []
},
{
"id": "7f12afa5f956f5b7",
"type": "rpi-gpio in",
"z": "d0c67fe9591b0f00",
"name": "",
"pin": "27",
"intype": "down",
"debounce": "25",
"read": false,
"bcm": true,
"x": 100,
"y": 520,
"wires": [
[
"5a5e07977c070278",
"7a6bf88058053219"
]
]
},
{
"id": "784df4903a15fb33",
"type": "dsm",
"z": "d0c67fe9591b0f00",
"name": "operating time",
"sm_config": "{\n \"currentState\": \"stopped\",\n \"states\": {\n \"stopped\": {\n \"on\": \"started\"\n },\n \"started\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n },\n \"counting\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n }\n },\n \"data\": {\n \"prev_time\": null,\n \"time\": 0,\n \"seconds\": 0,\n \"interval\": 1,\n \"interval_output\": true,\n \"hms_format\": true\n },\n \"methods\": {\n \"init\": [\n \"sm.calc_time = function() {\",\n \" var now = Date.now();\",\n \" sm.data.time += now - sm.data.prev_time;\",\n \" sm.data.prev_time = now;\",\n \" sm.data.seconds = Math.round(sm.data.time / 1000);\",\n \"};\",\n \"sm.sec2hhmmss = function(sec) {\",\n \"var t = {};\",\n \"t.h = pad(Math.floor(sec / 3600));\",\n \"sec %= 3600;\",\n \"t.m = pad(Math.floor(sec / 60));\",\n \"t.s = pad(sec % 60);\",\n \"return t.h+':'+t.m+':'+t.s;\",\n \"};\"\n ],\n \"on\": [\n \"if (sm.currentState === 'started') {\",\n \" sm.data.prev_time = Date.now();\",\n \" resume('inc', msg);\",\n \"}\",\n \"output = false;\"\n ],\n \"inc\": [\n \"timeout.interval = setTimeout(function() {\",\n \" sm.calc_time();\",\n \" msg.data = sm.data;\",\n \" if (sm.data.interval_output) {\",\n \" msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\",\n \" node.send(msg);\",\n \" }\",\n \" resume('inc', msg);\",\n \"}, sm.data.interval*1000);\",\n \"output = false;\"\n ],\n \"off\": [\n \"clearTimeout(timeout.interval);\",\n \"sm.calc_time();\",\n \"msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\"\n ],\n \"reset\": [\n \"sm.data.time = 0;\",\n \"sm.data.seconds = 0;\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.currentState === 'counting' ? 'green' : 'grey';\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"'time ' + (sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds);\"\n }\n }\n }\n}\n",
"x": 450,
"y": 460,
"wires": [
[
"463e39c82e4fcf14"
]
]
},
{
"id": "5a5e07977c070278",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "on",
"func": "if (msg.payload == 1){\n msg.topic = \"on\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 460,
"wires": [
[
"784df4903a15fb33"
]
]
},
{
"id": "7a6bf88058053219",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "off",
"func": "if (msg.payload == 0){\n msg.topic = \"off\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 540,
"wires": [
[
"784df4903a15fb33",
"397a7b66eb6280e0"
]
]
},
{
"id": "463e39c82e4fcf14",
"type": "ui_text",
"z": "d0c67fe9591b0f00",
"group": "338ade4865229a46",
"order": 1,
"width": 0,
"height": 0,
"name": "",
"label": "poste3",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"x": 650,
"y": 460,
"wires": []
},
{
"id": "eec0208fc2482c1a",
"type": "rpi-gpio in",
"z": "d0c67fe9591b0f00",
"name": "",
"pin": "22",
"intype": "down",
"debounce": "25",
"read": false,
"bcm": true,
"x": 100,
"y": 680,
"wires": [
[
"d5a9c6f59461680e",
"6e94fd907f11c45e"
]
]
},
{
"id": "ae4ecf691ef58ce5",
"type": "dsm",
"z": "d0c67fe9591b0f00",
"name": "operating time",
"sm_config": "{\n \"currentState\": \"stopped\",\n \"states\": {\n \"stopped\": {\n \"on\": \"started\"\n },\n \"started\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n },\n \"counting\": {\n \"inc\": \"counting\",\n \"off\": \"stopped\"\n }\n },\n \"data\": {\n \"prev_time\": null,\n \"time\": 0,\n \"seconds\": 0,\n \"interval\": 1,\n \"interval_output\": true,\n \"hms_format\": true\n },\n \"methods\": {\n \"init\": [\n \"sm.calc_time = function() {\",\n \" var now = Date.now();\",\n \" sm.data.time += now - sm.data.prev_time;\",\n \" sm.data.prev_time = now;\",\n \" sm.data.seconds = Math.round(sm.data.time / 1000);\",\n \"};\",\n \"sm.sec2hhmmss = function(sec) {\",\n \"var t = {};\",\n \"t.h = pad(Math.floor(sec / 3600));\",\n \"sec %= 3600;\",\n \"t.m = pad(Math.floor(sec / 60));\",\n \"t.s = pad(sec % 60);\",\n \"return t.h+':'+t.m+':'+t.s;\",\n \"};\"\n ],\n \"on\": [\n \"if (sm.currentState === 'started') {\",\n \" sm.data.prev_time = Date.now();\",\n \" resume('inc', msg);\",\n \"}\",\n \"output = false;\"\n ],\n \"inc\": [\n \"timeout.interval = setTimeout(function() {\",\n \" sm.calc_time();\",\n \" msg.data = sm.data;\",\n \" if (sm.data.interval_output) {\",\n \" msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\",\n \" node.send(msg);\",\n \" }\",\n \" resume('inc', msg);\",\n \"}, sm.data.interval*1000);\",\n \"output = false;\"\n ],\n \"off\": [\n \"clearTimeout(timeout.interval);\",\n \"sm.calc_time();\",\n \"msg.payload = sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds;\"\n ],\n \"reset\": [\n \"sm.data.time = 0;\",\n \"sm.data.seconds = 0;\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.currentState === 'counting' ? 'green' : 'grey';\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"'time ' + (sm.data.hms_format ? sm.sec2hhmmss(sm.data.seconds): sm.data.seconds);\"\n }\n }\n }\n}\n",
"x": 450,
"y": 620,
"wires": [
[
"36c37917c17515bf"
]
]
},
{
"id": "d5a9c6f59461680e",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "on",
"func": "if (msg.payload == 1){\n msg.topic = \"on\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 620,
"wires": [
[
"ae4ecf691ef58ce5"
]
]
},
{
"id": "6e94fd907f11c45e",
"type": "function",
"z": "d0c67fe9591b0f00",
"name": "off",
"func": "if (msg.payload == 0){\n msg.topic = \"off\";\n return msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 230,
"y": 700,
"wires": [
[
"ae4ecf691ef58ce5",
"397a7b66eb6280e0"
]
]
},
{
"id": "36c37917c17515bf",
"type": "ui_text",
"z": "d0c67fe9591b0f00",
"group": "338ade4865229a46",
"order": 1,
"width": 0,
"height": 0,
"name": "",
"label": "poste4",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"x": 650,
"y": 620,
"wires": []
},
{
"id": "e80842eabf993d7f",
"type": "ui_text",
"z": "d0c67fe9591b0f00",
"group": "338ade4865229a46",
"order": 4,
"width": 0,
"height": 0,
"name": "",
"label": "Total time",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"x": 660,
"y": 380,
"wires": []
},
{
"id": "397a7b66eb6280e0",
"type": "and-gate",
"z": "d0c67fe9591b0f00",
"name": "",
"rules": [
{
"t": "eq",
"v": "",
"vt": "str",
"propertyType": "msg",
"property": "payload",
"topic": ""
}
],
"outputTopic": "",
"gateType": "and",
"emitOnlyIfTrue": false,
"x": 470,
"y": 380,
"wires": [
[
"e80842eabf993d7f"
]
]
},
{
"id": "d4ddfb09862279ec",
"type": "inject",
"z": "d0c67fe9591b0f00",
"name": "Reset",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "reset",
"payloadType": "date",
"x": 90,
"y": 420,
"wires": [
[
"ae4ecf691ef58ce5",
"784df4903a15fb33",
"40a0fca564be2a2b",
"457e1e6cf1ab284a"
]
]
},
{
"id": "338ade4865229a46",
"type": "ui_group",
"name": "poste1",
"tab": "284b0a0e2ab40f48",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "284b0a0e2ab40f48",
"type": "ui_tab",
"name": "poste",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]