Moin Matze,
ich habe da mal was rumgespielt.
2 Versionen mit 3 bzw. 4 mal klicken.
Du möchtest ja sicher nicht 2 und 3 ausschalten wenn du nur 1 ausschalten möchtest. Über die delays kannst du die Zeiten anpassen bei 4x klicken steht die Zeit auf 1200ms.(mit der injektnode funktioniert das in der Zeit)
Du müstest die mcp input und output die du benutzt auf der Relayseite deaktivieren.
Es gibt da noch einen Reset button, den braucht du wenn du in der Zeit mehr als 4 x gedückt hast, um den Zähler auf 0 zu setzen, geht sicher auch anders, fällt mir aber im Moment nicht ein wie 
Das ist das was ich mit meinen bescheidenen Kenntnissen hinbekomme 
Die Debugs und die true injektnode kannst du löschen, die sind nur zum testen.
Grüße
Arno
[
{
"id": "b3f96651a445db09",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "b9360aeeb7600af5",
"type": "inject",
"z": "b3f96651a445db09",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 270,
"y": 400,
"wires": [
[
"3202334c49aea6bc"
]
]
},
{
"id": "0eac236237821d06",
"type": "mcp23017input",
"z": "b3f96651a445db09",
"name": "mcpinput1",
"chip": "4e9949f3b6e19991",
"bitNum": "0",
"pullUp": true,
"invert": true,
"debounce": "100",
"onMsg": true,
"offMsg": true,
"x": 260,
"y": 340,
"wires": [
[
"3202334c49aea6bc"
]
]
},
{
"id": "67408f158dc67eeb",
"type": "function",
"z": "b3f96651a445db09",
"name": "Zähler mit reset",
"func": "var zahl = msg.payload\nvar num = flow.get(\"schalter\") || 0;\n\nif(zahl == true){\n var num1 = num + 1;\n flow.set(\"schalter\", num1);\n}\nreturn msg;\n\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 640,
"y": 320,
"wires": [
[
"a749749e2d4ba421",
"e377dbb718852d89"
]
]
},
{
"id": "d34b276eea748a80",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 718",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1330,
"y": 320,
"wires": []
},
{
"id": "e377dbb718852d89",
"type": "delay",
"z": "b3f96651a445db09",
"name": "",
"pauseType": "delay",
"timeout": "1000",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 660,
"y": 360,
"wires": [
[
"ed1c5787c4185c29",
"76a12b0ff6da5c37"
]
]
},
{
"id": "ed1c5787c4185c29",
"type": "function",
"z": "b3f96651a445db09",
"name": "RELAY 1 oder 2",
"func": "var check = msg.payload\nvar num = flow.get(\"schalter\")\n\nif (check == true && num == 1 ){\n msg.payload = true\n flow.set(\"schalter\", 0)\n return [msg,null,null]\n \n}\n if (check == true && num==2){\n msg.payload = true\n flow.set(\"schalter\", 0)\n return([null,msg,null]);\n \n}\nif(check == true && num == 3) \n{\n msg.payload = false\n flow.set(\"schalter\", 0);\n return([null,null,msg]);\n \n}\n",
"outputs": 3,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 880,
"y": 360,
"wires": [
[
"d34b276eea748a80",
"8cb26753d183fb0e"
],
[
"c8afdb47a1faaa14",
"b1145cdc2124c476",
"c7430e1fade6ae6c"
],
[
"a884d127f6673cad",
"8cb26753d183fb0e",
"b1145cdc2124c476",
"c7430e1fade6ae6c"
]
]
},
{
"id": "a749749e2d4ba421",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 719",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 810,
"y": 260,
"wires": []
},
{
"id": "c8afdb47a1faaa14",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 720",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1310,
"y": 400,
"wires": []
},
{
"id": "a884d127f6673cad",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 721",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1130,
"y": 480,
"wires": []
},
{
"id": "ecb41e01ae50015c",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 722",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 810,
"y": 200,
"wires": []
},
{
"id": "76a12b0ff6da5c37",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 724",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 300,
"wires": []
},
{
"id": "3202334c49aea6bc",
"type": "switch",
"z": "b3f96651a445db09",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 450,
"y": 340,
"wires": [
[
"ecb41e01ae50015c",
"67408f158dc67eeb"
]
]
},
{
"id": "d419b009b0fb074b",
"type": "inject",
"z": "b3f96651a445db09",
"name": "reset",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "1",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 270,
"y": 300,
"wires": [
[
"b96804101837737d"
]
]
},
{
"id": "b96804101837737d",
"type": "function",
"z": "b3f96651a445db09",
"name": "function 115",
"func": "flow.set(\"schalter\", 0);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 300,
"wires": [
[]
]
},
{
"id": "d75f2c0f57aadc84",
"type": "ui_button",
"z": "b3f96651a445db09",
"name": "",
"group": "38b0d3a980d68bfa",
"order": 7,
"width": 0,
"height": 0,
"passthru": false,
"label": "Reset",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "date",
"topic": "topic",
"topicType": "msg",
"x": 250,
"y": 260,
"wires": [
[
"b96804101837737d"
]
]
},
{
"id": "8cb26753d183fb0e",
"type": "mcp23017output",
"z": "b3f96651a445db09",
"name": "",
"chip": "4e9949f3b6e19991",
"bitNum": "8",
"invert": true,
"x": 1130,
"y": 320,
"wires": [
[]
]
},
{
"id": "b1145cdc2124c476",
"type": "mcp23017output",
"z": "b3f96651a445db09",
"name": "",
"chip": "4e9949f3b6e19991",
"bitNum": "9",
"invert": true,
"x": 1130,
"y": 380,
"wires": [
[]
]
},
{
"id": "c7430e1fade6ae6c",
"type": "mcp23017output",
"z": "b3f96651a445db09",
"name": "",
"chip": "4e9949f3b6e19991",
"bitNum": "10",
"invert": true,
"x": 1130,
"y": 420,
"wires": [
[]
]
},
{
"id": "060be061ecd25e2d",
"type": "inject",
"z": "b3f96651a445db09",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 190,
"y": 720,
"wires": [
[
"0153c9d754856f88"
]
]
},
{
"id": "69ed0c5a8cf7da04",
"type": "mcp23017input",
"z": "b3f96651a445db09",
"name": "mcpinput1",
"chip": "4e9949f3b6e19991",
"bitNum": "0",
"pullUp": true,
"invert": true,
"debounce": "100",
"onMsg": true,
"offMsg": true,
"x": 180,
"y": 660,
"wires": [
[
"0153c9d754856f88"
]
]
},
{
"id": "574e2cd387af84d5",
"type": "function",
"z": "b3f96651a445db09",
"name": "Zähler mit reset",
"func": "var zahl = msg.payload\nvar num = flow.get(\"schalter\") || 0;\n\nif(zahl == true){\n var num1 = num + 1;\n flow.set(\"schalter\", num1);\n}\nreturn msg;\n\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 640,
"wires": [
[
"41f1b87bf8dcc7a6"
]
]
},
{
"id": "759160bff391bb6e",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 725",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1250,
"y": 600,
"wires": []
},
{
"id": "41f1b87bf8dcc7a6",
"type": "delay",
"z": "b3f96651a445db09",
"name": "",
"pauseType": "delay",
"timeout": "1200",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 580,
"y": 680,
"wires": [
[
"a1c8104a7130dd8c"
]
]
},
{
"id": "a1c8104a7130dd8c",
"type": "function",
"z": "b3f96651a445db09",
"name": "RELAY 1 oder 2",
"func": "var check = msg.payload\nvar num = flow.get(\"schalter\")\n\nif (check == true && num == 1 ){\n msg.payload = true\n flow.set(\"schalter\", 0)\n return [msg,null,null,null]\n \n}\n if (check == true && num==2){\n msg.payload = true\n flow.set(\"schalter\", 0)\n return[null,msg,null,null];\n \n}\nif(check == true && num == 3) \n{\n msg.payload = false\n flow.set(\"schalter\", 0);\n return[null,null,msg,null];\n \n}\nif(check == true && num == 4) \n{\n msg.payload = false\n flow.set(\"schalter\", 0);\n return([null,null,null,msg]);\n \n}",
"outputs": 4,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 800,
"y": 680,
"wires": [
[
"759160bff391bb6e",
"2d61b264ed494f36"
],
[
"4becf544d88055f2",
"fe03e9b5e1366ccc",
"22a41880fbef399d"
],
[
"2d61b264ed494f36",
"608d9018a425b724"
],
[
"fe03e9b5e1366ccc",
"22a41880fbef399d",
"ef0f3d838cb1b5d3"
]
]
},
{
"id": "4becf544d88055f2",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 727",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1250,
"y": 720,
"wires": []
},
{
"id": "608d9018a425b724",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 728",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1250,
"y": 660,
"wires": []
},
{
"id": "0153c9d754856f88",
"type": "switch",
"z": "b3f96651a445db09",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 370,
"y": 660,
"wires": [
[
"574e2cd387af84d5"
]
]
},
{
"id": "ab6e9b77ab4557ac",
"type": "inject",
"z": "b3f96651a445db09",
"name": "reset",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "1",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 620,
"wires": [
[
"2104252b8c8334a2"
]
]
},
{
"id": "2104252b8c8334a2",
"type": "function",
"z": "b3f96651a445db09",
"name": "function 116",
"func": "flow.set(\"schalter\", 0);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 620,
"wires": [
[]
]
},
{
"id": "9a907cf374d3688a",
"type": "ui_button",
"z": "b3f96651a445db09",
"name": "",
"group": "38b0d3a980d68bfa",
"order": 7,
"width": 0,
"height": 0,
"passthru": false,
"label": "Reset",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "date",
"topic": "topic",
"topicType": "msg",
"x": 170,
"y": 580,
"wires": [
[
"2104252b8c8334a2"
]
]
},
{
"id": "2d61b264ed494f36",
"type": "mcp23017output",
"z": "b3f96651a445db09",
"name": "",
"chip": "4e9949f3b6e19991",
"bitNum": "8",
"invert": true,
"x": 1050,
"y": 640,
"wires": [
[]
]
},
{
"id": "fe03e9b5e1366ccc",
"type": "mcp23017output",
"z": "b3f96651a445db09",
"name": "",
"chip": "4e9949f3b6e19991",
"bitNum": "9",
"invert": true,
"x": 1050,
"y": 700,
"wires": [
[]
]
},
{
"id": "22a41880fbef399d",
"type": "mcp23017output",
"z": "b3f96651a445db09",
"name": "",
"chip": "4e9949f3b6e19991",
"bitNum": "10",
"invert": true,
"x": 1050,
"y": 740,
"wires": [
[]
]
},
{
"id": "ef0f3d838cb1b5d3",
"type": "debug",
"z": "b3f96651a445db09",
"name": "debug 731",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1250,
"y": 780,
"wires": []
},
{
"id": "9373daea3806b0b1",
"type": "comment",
"z": "b3f96651a445db09",
"name": "1x klicken relay 1 an, 2x klicken relay 2,3 an 3x klicken alles aus",
"info": "",
"x": 550,
"y": 160,
"wires": []
},
{
"id": "6a59d1395781e887",
"type": "comment",
"z": "b3f96651a445db09",
"name": "1x klicken relay 1 an, 2x klicken relay 2,3 an 3x klicken 1 aus, 4x klicken 2,3 aus",
"info": "",
"x": 720,
"y": 480,
"wires": []
},
{
"id": "4e9949f3b6e19991",
"type": "mcp23017chip",
"addr": "0x20",
"interval": "100"
},
{
"id": "38b0d3a980d68bfa",
"type": "ui_group",
"name": "Test",
"tab": "71bad5b741d68215",
"order": 3,
"disp": true,
"width": "12",
"collapse": false,
"className": ""
},
{
"id": "71bad5b741d68215",
"type": "ui_tab",
"name": "Test",
"icon": "build",
"order": 47,
"disabled": false,
"hidden": false
}
]