Stop nodes with Logic AND

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
    }
]

If I understand you,

  1. you need to store the accumulated time for each switch when you turn off the station
  2. when all switches are off, you need to add the stored value for each switch and display it

In your statement you mentin 3 timers, but your flow shows 4. Here is an example of ne way you could get this to work:

[{"id":"d0c67fe9591b0f00","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"f361c5c123640491","type":"group","z":"d0c67fe9591b0f00","name":"COUNTER 1","style":{"stroke":"#ff0000","fill":"#ffbfbf","label":true},"nodes":["8c598fca9b188070","457e1e6cf1ab284a","ab53647bf7fdd738","bd86cc6f65d66a8c","769b622a5cba09b2","4f30c33264eec642","5762a3953132d627","077b5eedc9f0f7cb","150dabf6cb934e54","8c72daab610185df","341312aeea340f5e","902f5ce6766f2275"],"x":14,"y":59,"w":1032,"h":182},{"id":"3118cb1d7b168433","type":"group","z":"d0c67fe9591b0f00","name":"COUNTER 2","style":{"stroke":"#ffC000","fill":"#ffefbf","label":true},"nodes":["8ee12ae98a8e02da","40a0fca564be2a2b","b48e5058b0a6761b","61269ce5b826c9c7","f5e4f31b317dded8","c329260ad69b16ad","d2ba622e4d6ec9cc","d1e5fd630786142a","a83cf60adba131b0","f75185d50c3d31cd","ecbd136211992351","d383eeec42f0e2f8"],"x":14,"y":259,"w":1032,"h":202},{"id":"54f55257003a0cdc","type":"group","z":"d0c67fe9591b0f00","name":"COUNTER 3","style":{"stroke":"#ffff00","fill":"#ffffbf","label":true},"nodes":["7f12afa5f956f5b7","784df4903a15fb33","5a5e07977c070278","7a6bf88058053219","463e39c82e4fcf14","f29ca4b65758fc67","3bcbfd9c9b85cc2e","2fbee8cc1807f776","fecbf323f697343d","5cec4044f963a03f","9e84497652dfac23"],"x":14,"y":479,"w":1032,"h":182},{"id":"fee60ceb4c88cae6","type":"group","z":"d0c67fe9591b0f00","name":"COUNTER 4","style":{"stroke":"#92d04f","fill":"#e3f3d3","label":true},"nodes":["eec0208fc2482c1a","ae4ecf691ef58ce5","d5a9c6f59461680e","6e94fd907f11c45e","36c37917c17515bf","edae26c7c5381404","80f4bcd3856b819b","9381615b436c803c","0c280f49a595cfdc","dac15644eb5878d3","5b9736d9df84c2c9"],"x":14,"y":679,"w":1032,"h":202},{"id":"25434b1426f0e7d1","type":"group","z":"d0c67fe9591b0f00","name":"AND LOGIC","style":{"stroke":"#0070c0","fill":"#bfdbef","label":true},"nodes":["e80842eabf993d7f","397a7b66eb6280e0","68d09f536fea70fd","3beac44bb52c101b","3041fa5b28286de0"],"x":34,"y":939,"w":832,"h":122},{"id":"8c598fca9b188070","type":"rpi-gpio in","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"","pin":"4","intype":"down","debounce":"25","read":false,"bcm":true,"x":110,"y":140,"wires":[["ab53647bf7fdd738","bd86cc6f65d66a8c"]]},{"id":"457e1e6cf1ab284a","type":"dsm","z":"d0c67fe9591b0f00","g":"f361c5c123640491","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":530,"y":140,"wires":[["769b622a5cba09b2","077b5eedc9f0f7cb","150dabf6cb934e54"]]},{"id":"ab53647bf7fdd738","type":"function","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"on","func":"if (msg.payload == 1){\n    msg.topic = \"on\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":120,"wires":[["457e1e6cf1ab284a"]]},{"id":"bd86cc6f65d66a8c","type":"function","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"off","func":"if (msg.payload == 0){\n    msg.topic = \"off\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":160,"wires":[["457e1e6cf1ab284a","902f5ce6766f2275"]]},{"id":"769b622a5cba09b2","type":"ui_text","z":"d0c67fe9591b0f00","g":"f361c5c123640491","group":"338ade4865229a46","order":1,"width":0,"height":0,"name":"","label":"poste1","format":"{{msg.payload}}","layout":"col-center","className":"","x":770,"y":100,"wires":[]},{"id":"8ee12ae98a8e02da","type":"rpi-gpio in","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"","pin":"17","intype":"down","debounce":"25","read":false,"bcm":true,"x":120,"y":340,"wires":[["b48e5058b0a6761b","61269ce5b826c9c7"]]},{"id":"40a0fca564be2a2b","type":"dsm","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","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":530,"y":360,"wires":[["f5e4f31b317dded8","d1e5fd630786142a","f75185d50c3d31cd"]]},{"id":"b48e5058b0a6761b","type":"function","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"on","func":"if (msg.payload == 1){\n    msg.topic = \"on\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":320,"wires":[["40a0fca564be2a2b"]]},{"id":"61269ce5b826c9c7","type":"function","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"off","func":"if (msg.payload == 0){\n    msg.topic = \"off\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":360,"wires":[["40a0fca564be2a2b","d383eeec42f0e2f8"]]},{"id":"f5e4f31b317dded8","type":"ui_text","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","group":"338ade4865229a46","order":1,"width":0,"height":0,"name":"","label":"poste2","format":"{{msg.payload}}","layout":"col-center","className":"","x":770,"y":320,"wires":[]},{"id":"7f12afa5f956f5b7","type":"rpi-gpio in","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"","pin":"27","intype":"down","debounce":"25","read":false,"bcm":true,"x":120,"y":560,"wires":[["5a5e07977c070278","7a6bf88058053219"]]},{"id":"784df4903a15fb33","type":"dsm","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","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":530,"y":560,"wires":[["463e39c82e4fcf14","fecbf323f697343d"]]},{"id":"5a5e07977c070278","type":"function","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"on","func":"if (msg.payload == 1){\n    msg.topic = \"on\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":540,"wires":[["784df4903a15fb33"]]},{"id":"7a6bf88058053219","type":"function","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"off","func":"if (msg.payload == 0){\n    msg.topic = \"off\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":580,"wires":[["784df4903a15fb33","9e84497652dfac23"]]},{"id":"463e39c82e4fcf14","type":"ui_text","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","group":"338ade4865229a46","order":1,"width":0,"height":0,"name":"","label":"poste3","format":"{{msg.payload}}","layout":"col-center","className":"","x":770,"y":520,"wires":[]},{"id":"eec0208fc2482c1a","type":"rpi-gpio in","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"","pin":"22","intype":"down","debounce":"25","read":false,"bcm":true,"x":120,"y":760,"wires":[["d5a9c6f59461680e","6e94fd907f11c45e"]]},{"id":"ae4ecf691ef58ce5","type":"dsm","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","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":530,"y":780,"wires":[["36c37917c17515bf","0c280f49a595cfdc"]]},{"id":"d5a9c6f59461680e","type":"function","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"on","func":"if (msg.payload == 1){\n    msg.topic = \"on\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":740,"wires":[["ae4ecf691ef58ce5"]]},{"id":"6e94fd907f11c45e","type":"function","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"off","func":"if (msg.payload == 0){\n    msg.topic = \"off\";\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":780,"wires":[["ae4ecf691ef58ce5","5b9736d9df84c2c9"]]},{"id":"36c37917c17515bf","type":"ui_text","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","group":"338ade4865229a46","order":1,"width":0,"height":0,"name":"","label":"poste4","format":"{{msg.payload}}","layout":"col-center","className":"","x":770,"y":740,"wires":[]},{"id":"e80842eabf993d7f","type":"ui_text","z":"d0c67fe9591b0f00","g":"25434b1426f0e7d1","group":"338ade4865229a46","order":4,"width":0,"height":0,"name":"","label":"Total time","format":"{{msg.payload}}","layout":"col-center","className":"","x":780,"y":980,"wires":[]},{"id":"397a7b66eb6280e0","type":"and-gate","z":"d0c67fe9591b0f00","g":"25434b1426f0e7d1","name":"","rules":[{"t":"eq","v":"","vt":"str","propertyType":"msg","property":"payload","topic":""}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":false,"x":300,"y":980,"wires":[["68d09f536fea70fd"]]},{"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":352,"y":20,"wires":[["a6322c6ec9e50c0b"]]},{"id":"4f30c33264eec642","type":"inject","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":100,"wires":[["ab53647bf7fdd738"]]},{"id":"c329260ad69b16ad","type":"inject","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":300,"wires":[["b48e5058b0a6761b"]]},{"id":"f29ca4b65758fc67","type":"inject","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":520,"wires":[["5a5e07977c070278"]]},{"id":"edae26c7c5381404","type":"inject","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":720,"wires":[["d5a9c6f59461680e"]]},{"id":"80f4bcd3856b819b","type":"inject","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":820,"wires":[["6e94fd907f11c45e"]]},{"id":"3bcbfd9c9b85cc2e","type":"inject","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":620,"wires":[["7a6bf88058053219"]]},{"id":"d2ba622e4d6ec9cc","type":"inject","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":400,"wires":[["61269ce5b826c9c7"]]},{"id":"5762a3953132d627","type":"inject","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":200,"wires":[["bd86cc6f65d66a8c"]]},{"id":"077b5eedc9f0f7cb","type":"debug","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":180,"wires":[]},{"id":"d1e5fd630786142a","type":"debug","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":400,"wires":[]},{"id":"150dabf6cb934e54","type":"switch","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"stopped","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":140,"wires":[["8c72daab610185df"]]},{"id":"8c72daab610185df","type":"change","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"Store counter_1","rules":[{"t":"set","p":"counter_1","pt":"flow","to":"data.time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":140,"wires":[[]]},{"id":"68d09f536fea70fd","type":"change","z":"d0c67fe9591b0f00","g":"25434b1426f0e7d1","name":"","rules":[{"t":"set","p":"counter_1","pt":"msg","to":"counter_1","tot":"flow"},{"t":"set","p":"counter_2","pt":"msg","to":"counter_2","tot":"flow"},{"t":"set","p":"counter_3","pt":"msg","to":"counter_3","tot":"flow"},{"t":"set","p":"counter_4","pt":"msg","to":"counter_4","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"counter_1 + counter_2 + counter_3 + counter_4","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":980,"wires":[["e80842eabf993d7f","3beac44bb52c101b"]]},{"id":"817c228376793ab0","type":"link out","z":"d0c67fe9591b0f00","name":"Reset","mode":"link","links":["7f8dfb7fda07aefd","a0153c0f464fa81f","a83cf60adba131b0","ed45e49178ef6eba","341312aeea340f5e","2fbee8cc1807f776","9381615b436c803c"],"x":690.7391357421875,"y":20.33698844909668,"wires":[],"l":true},{"id":"a83cf60adba131b0","type":"link in","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"Reset-2","links":["817c228376793ab0"],"x":490,"y":320,"wires":[["40a0fca564be2a2b","f5e4f31b317dded8"]],"l":true},{"id":"341312aeea340f5e","type":"link in","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"Reset-1","links":["817c228376793ab0"],"x":490,"y":100,"wires":[["457e1e6cf1ab284a","769b622a5cba09b2"]],"l":true},{"id":"2fbee8cc1807f776","type":"link in","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"Reset-3","links":["817c228376793ab0"],"x":490,"y":520,"wires":[["784df4903a15fb33","463e39c82e4fcf14"]],"l":true},{"id":"9381615b436c803c","type":"link in","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"Reset-4","links":["817c228376793ab0"],"x":490,"y":740,"wires":[["ae4ecf691ef58ce5","36c37917c17515bf"]],"l":true},{"id":"f75185d50c3d31cd","type":"switch","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"stopped","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":360,"wires":[["ecbd136211992351"]]},{"id":"ecbd136211992351","type":"change","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"Store counter_2","rules":[{"t":"set","p":"counter_2","pt":"flow","to":"data.time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":360,"wires":[[]]},{"id":"fecbf323f697343d","type":"switch","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"stopped","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":560,"wires":[["5cec4044f963a03f"]]},{"id":"5cec4044f963a03f","type":"change","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"Store counter_3","rules":[{"t":"set","p":"counter_3","pt":"flow","to":"data.time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":560,"wires":[[]]},{"id":"0c280f49a595cfdc","type":"switch","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"stopped","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":780,"wires":[["dac15644eb5878d3"]]},{"id":"dac15644eb5878d3","type":"change","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"Store counter_4","rules":[{"t":"set","p":"counter_4","pt":"flow","to":"data.time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":780,"wires":[[]]},{"id":"3beac44bb52c101b","type":"debug","z":"d0c67fe9591b0f00","g":"25434b1426f0e7d1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":1020,"wires":[]},{"id":"a6322c6ec9e50c0b","type":"change","z":"d0c67fe9591b0f00","name":"","rules":[{"t":"set","p":"counter_1","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"counter_2","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"counter_3","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"counter_4","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":520.1358642578125,"y":20.13043212890625,"wires":[["817c228376793ab0"]]},{"id":"3041fa5b28286de0","type":"link in","z":"d0c67fe9591b0f00","g":"25434b1426f0e7d1","name":"AND","links":["5b9736d9df84c2c9","9e84497652dfac23","d383eeec42f0e2f8","902f5ce6766f2275"],"x":110,"y":980,"wires":[["397a7b66eb6280e0"]],"l":true},{"id":"5b9736d9df84c2c9","type":"link out","z":"d0c67fe9591b0f00","g":"fee60ceb4c88cae6","name":"To AND","mode":"link","links":["3041fa5b28286de0"],"x":500,"y":840,"wires":[],"l":true},{"id":"9e84497652dfac23","type":"link out","z":"d0c67fe9591b0f00","g":"54f55257003a0cdc","name":"To AND","mode":"link","links":["3041fa5b28286de0"],"x":500,"y":620,"wires":[],"l":true},{"id":"d383eeec42f0e2f8","type":"link out","z":"d0c67fe9591b0f00","g":"3118cb1d7b168433","name":"To AND","mode":"link","links":["3041fa5b28286de0"],"x":500,"y":420,"wires":[],"l":true},{"id":"902f5ce6766f2275","type":"link out","z":"d0c67fe9591b0f00","g":"f361c5c123640491","name":"To AND","mode":"link","links":["3041fa5b28286de0"],"x":500,"y":200,"wires":[],"l":true},{"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}]

Many thanks for the reply. But in fact what I need is for the total time counter to start as soon as a station counter starts and to stop as soon as all counters are stopped. (it must not add up all the counters). I hope my message is understandable. I have been trying to find a solution for 3 weeks.
Thank you again for your answer

So where I show the computing the elapsed time, put a timer in its place.

And if you don’t need the ‘on’ times, you can remove that code.

Sorry but I do not understand the answer.
(this is my first project on node red)
Can you please make the modification for me?
Once again a big thank you for your help.

You have 4 timers. Do you want time shown when any three are stopped or all four are stopped?

If you want it stopped when any three are stopped that makes it a bit harder.

Hello.
here is what it would take:
if (timer1=1 or timer2=1 or timer3=1 or timer4=1) then total_timer = start
if (timer1=0 and timer2=0 and timer3=0 and timer4=0 ) then total_timer = stop

Ok, this is a bit different that you originally stated. It pays to be detailed.

Here is a new flow that should do what yo want. I added some buttons you can use for testing on the dashboard.

[{"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":110,"y":140,"wires":[["ab53647bf7fdd738"]]},{"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":590,"y":140,"wires":[["769b622a5cba09b2"]]},{"id":"ab53647bf7fdd738","type":"function","z":"d0c67fe9591b0f00","name":"on/off","func":"let timers_on = flow.get(\"timers_on\")||0\nif (msg.payload == 1){\n    msg.topic = \"on\";\n    timers_on += 1\n}\nif (msg.payload == 0){\n    msg.topic = \"off\";\n    timers_on -= 1\n}\n\nif (timers_on < 0) timers_on = 0\nflow.set(\"timers_on\",timers_on)\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":140,"wires":[["457e1e6cf1ab284a","9ff481f3d2611166"]]},{"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":810,"y":140,"wires":[]},{"id":"8ee12ae98a8e02da","type":"rpi-gpio in","z":"d0c67fe9591b0f00","name":"","pin":"17","intype":"down","debounce":"25","read":false,"bcm":true,"x":120,"y":340,"wires":[["b48e5058b0a6761b"]]},{"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":590,"y":340,"wires":[["f5e4f31b317dded8"]]},{"id":"b48e5058b0a6761b","type":"function","z":"d0c67fe9591b0f00","name":"on/off","func":"let timers_on = flow.get(\"timers_on\")||0\nif (msg.payload == 1){\n    msg.topic = \"on\";\n    timers_on += 1\n}\nif (msg.payload == 0){\n    msg.topic = \"off\";\n    timers_on -= 1\n}\n\nif (timers_on < 0) timers_on = 0\nflow.set(\"timers_on\",timers_on)\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":340,"wires":[["40a0fca564be2a2b","9d85cc24599368ef"]]},{"id":"f5e4f31b317dded8","type":"ui_text","z":"d0c67fe9591b0f00","group":"338ade4865229a46","order":2,"width":0,"height":0,"name":"","label":"poste2","format":"{{msg.payload}}","layout":"col-center","className":"","x":810,"y":320,"wires":[]},{"id":"7f12afa5f956f5b7","type":"rpi-gpio in","z":"d0c67fe9591b0f00","name":"","pin":"27","intype":"down","debounce":"25","read":false,"bcm":true,"x":120,"y":560,"wires":[["5a5e07977c070278"]]},{"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":590,"y":560,"wires":[["463e39c82e4fcf14"]]},{"id":"5a5e07977c070278","type":"function","z":"d0c67fe9591b0f00","name":"on/off","func":"let timers_on = flow.get(\"timers_on\")||0\nif (msg.payload == 1){\n    msg.topic = \"on\";\n    timers_on += 1\n}\nif (msg.payload == 0){\n    msg.topic = \"off\";\n    timers_on -= 1\n}\n\nif (timers_on < 0) timers_on = 0\nflow.set(\"timers_on\",timers_on)\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":560,"wires":[["784df4903a15fb33","35daa02be44768c5"]]},{"id":"463e39c82e4fcf14","type":"ui_text","z":"d0c67fe9591b0f00","group":"338ade4865229a46","order":3,"width":0,"height":0,"name":"","label":"poste3","format":"{{msg.payload}}","layout":"col-center","className":"","x":810,"y":560,"wires":[]},{"id":"eec0208fc2482c1a","type":"rpi-gpio in","z":"d0c67fe9591b0f00","name":"","pin":"22","intype":"down","debounce":"25","read":false,"bcm":true,"x":120,"y":760,"wires":[["d5a9c6f59461680e"]]},{"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":590,"y":760,"wires":[["36c37917c17515bf"]]},{"id":"d5a9c6f59461680e","type":"function","z":"d0c67fe9591b0f00","name":"on/off","func":"let timers_on = flow.get(\"timers_on\")||0\nif (msg.payload == 1){\n    msg.topic = \"on\";\n    timers_on += 1\n}\nif (msg.payload == 0){\n    msg.topic = \"off\";\n    timers_on -= 1\n}\n\nif (timers_on < 0) timers_on = 0\nflow.set(\"timers_on\",timers_on)\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":760,"wires":[["ae4ecf691ef58ce5","24376cc1693c09f7"]]},{"id":"36c37917c17515bf","type":"ui_text","z":"d0c67fe9591b0f00","group":"338ade4865229a46","order":4,"width":0,"height":0,"name":"","label":"poste4","format":"{{msg.payload}}","layout":"col-center","className":"","x":810,"y":720,"wires":[]},{"id":"e80842eabf993d7f","type":"ui_text","z":"d0c67fe9591b0f00","group":"338ade4865229a46","order":5,"width":0,"height":0,"name":"","label":"Total time","format":"{{msg.payload}}","layout":"col-center","className":"","x":820,"y":1000,"wires":[]},{"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":352,"y":20,"wires":[["a6322c6ec9e50c0b"]]},{"id":"817c228376793ab0","type":"link out","z":"d0c67fe9591b0f00","name":"Reset","mode":"link","links":["7f8dfb7fda07aefd","a0153c0f464fa81f","a83cf60adba131b0","ed45e49178ef6eba","341312aeea340f5e","2fbee8cc1807f776","9381615b436c803c","5516d46184e1fe46","c6312390af4ad993","3f255540050d9b85"],"x":690.7391357421875,"y":20.33698844909668,"wires":[],"l":true},{"id":"a83cf60adba131b0","type":"link in","z":"d0c67fe9591b0f00","name":"Reset-2","links":["817c228376793ab0"],"x":550,"y":300,"wires":[["40a0fca564be2a2b","f5e4f31b317dded8"]],"l":true},{"id":"341312aeea340f5e","type":"link in","z":"d0c67fe9591b0f00","name":"Reset-1","links":["817c228376793ab0"],"x":550,"y":100,"wires":[["457e1e6cf1ab284a","769b622a5cba09b2"]],"l":true},{"id":"2fbee8cc1807f776","type":"link in","z":"d0c67fe9591b0f00","name":"Reset-3","links":["817c228376793ab0"],"x":550,"y":520,"wires":[["784df4903a15fb33","463e39c82e4fcf14"]],"l":true},{"id":"9381615b436c803c","type":"link in","z":"d0c67fe9591b0f00","name":"Reset-4","links":["817c228376793ab0"],"x":550,"y":720,"wires":[["ae4ecf691ef58ce5","36c37917c17515bf"]],"l":true},{"id":"a6322c6ec9e50c0b","type":"change","z":"d0c67fe9591b0f00","name":"","rules":[{"t":"set","p":"timers_on","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520.1358642578125,"y":20.13043212890625,"wires":[["817c228376793ab0"]]},{"id":"fd11a902104f495f","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":610,"y":1000,"wires":[["e80842eabf993d7f"]]},{"id":"16122e11cc008c07","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":6,"width":"3","height":"1","passthru":false,"label":"ON 1","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"num","topic":"on","topicType":"str","x":110,"y":80,"wires":[["ab53647bf7fdd738"]]},{"id":"8d249cb3ada84c9c","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":7,"width":"3","height":"1","passthru":false,"label":"OFF 1","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"0","payloadType":"num","topic":"off","topicType":"str","x":110,"y":200,"wires":[["ab53647bf7fdd738"]]},{"id":"139a8489890bd4ac","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":9,"width":"3","height":"1","passthru":false,"label":"OFF 2","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"0","payloadType":"num","topic":"off","topicType":"str","x":110,"y":400,"wires":[["b48e5058b0a6761b"]]},{"id":"dfb4dd8e2ea61c07","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":11,"width":"3","height":"1","passthru":false,"label":"OFF 3","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"0","payloadType":"num","topic":"off","topicType":"str","x":110,"y":620,"wires":[["5a5e07977c070278"]]},{"id":"476df75c132c93d0","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":13,"width":"3","height":"1","passthru":false,"label":"OFF 4","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"0","payloadType":"num","topic":"off","topicType":"str","x":110,"y":820,"wires":[["d5a9c6f59461680e"]]},{"id":"02d1e8276a681e61","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":8,"width":"3","height":"1","passthru":false,"label":"ON 2","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"num","topic":"on","topicType":"str","x":110,"y":280,"wires":[["b48e5058b0a6761b"]]},{"id":"747d02025294fed3","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":10,"width":"3","height":"1","passthru":false,"label":"ON 3","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"num","topic":"on","topicType":"str","x":110,"y":520,"wires":[["5a5e07977c070278"]]},{"id":"5e2964a630c9b1e2","type":"ui_button","z":"d0c67fe9591b0f00","name":"","group":"338ade4865229a46","order":12,"width":"3","height":"1","passthru":false,"label":"ON 4","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"num","topic":"on","topicType":"str","x":110,"y":720,"wires":[["d5a9c6f59461680e"]]},{"id":"5d4d773cadaf5b41","type":"switch","z":"d0c67fe9591b0f00","name":"","property":"timers_on","propertyType":"flow","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":1000,"wires":[["d457af265922b585"],["98e29725b3f08b3a"]]},{"id":"98e29725b3f08b3a","type":"change","z":"d0c67fe9591b0f00","name":"turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"topic","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1020,"wires":[["fd11a902104f495f"]]},{"id":"d457af265922b585","type":"change","z":"d0c67fe9591b0f00","name":"turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"topic","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":980,"wires":[["fd11a902104f495f"]]},{"id":"9ff481f3d2611166","type":"link out","z":"d0c67fe9591b0f00","name":"to TOTAL","mode":"link","links":["395c3488be7d55d2"],"x":420,"y":200,"wires":[],"l":true},{"id":"395c3488be7d55d2","type":"link in","z":"d0c67fe9591b0f00","name":"TOTAL","links":["9ff481f3d2611166","9d85cc24599368ef","35daa02be44768c5","24376cc1693c09f7"],"x":110,"y":1000,"wires":[["5d4d773cadaf5b41"]],"l":true},{"id":"9d85cc24599368ef","type":"link out","z":"d0c67fe9591b0f00","name":"to TOTAL","mode":"link","links":["395c3488be7d55d2"],"x":420,"y":400,"wires":[],"l":true},{"id":"35daa02be44768c5","type":"link out","z":"d0c67fe9591b0f00","name":"to TOTAL","mode":"link","links":["395c3488be7d55d2"],"x":420,"y":620,"wires":[],"l":true},{"id":"24376cc1693c09f7","type":"link out","z":"d0c67fe9591b0f00","name":"to TOTAL","mode":"link","links":["395c3488be7d55d2"],"x":420,"y":820,"wires":[],"l":true},{"id":"3f255540050d9b85","type":"link in","z":"d0c67fe9591b0f00","name":"Reset-total","links":["817c228376793ab0"],"x":580,"y":960,"wires":[["e80842eabf993d7f","fd11a902104f495f"]],"l":true},{"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}]

Note: I just discovered a bug that if you start timer 1 then stop another timer the total stops but timer 1 keeps running...
I'll take a look later but I'll be busy most of the day (east coast USA)

Hello
Super it works.
For the bug, you don't have to remove it, in my project there will only be GPIOs connected (so no bug).
On the other hand, since I am dealing with a node-red expert, in my project I must install a sensor that counts the packages on a transport chain and I must count the number of packages every 6 min (which I will multiply by 10 to have a cadence per hour). Can you please give me the procedure.
I know I ask a lot of you and I thank you for it.

How do you think it should work? What kind of sensor? How will it connect to NR?

What have you tried? I’m not going to write the flow for you but will be happy to help you along so try some things.

If you get stuck ask some questions and provide the flow that is doing the counting. The best way to learn is try something.