Another way to do it.
[
{
"id": "605950b3904ff015",
"type": "delay",
"z": "d362bb7ca55abaf1",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 500,
"y": 220,
"wires": [
[
"43fbe55cf81bceeb"
]
]
},
{
"id": "bdd566267a971fa4",
"type": "inject",
"z": "d362bb7ca55abaf1",
"name": "1",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1",
"payloadType": "num",
"x": 170,
"y": 180,
"wires": [
[
"f7dcf0d9ada6d747"
]
]
},
{
"id": "0b875c1ee14b9df5",
"type": "inject",
"z": "d362bb7ca55abaf1",
"name": "0",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "0",
"payloadType": "num",
"x": 170,
"y": 220,
"wires": [
[
"f7dcf0d9ada6d747"
]
]
},
{
"id": "f7dcf0d9ada6d747",
"type": "function",
"z": "d362bb7ca55abaf1",
"name": "",
"func": "let msg1 = {}\nlet msg2 = {}\n\nif(msg.payload === 1) {\n msg1.payload = 1\n msg2.reset = 1\n return [msg1, msg2]\n \n} else {\n msg2.payload = 0\n return [null, msg2]\n}\n",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 340,
"y": 200,
"wires": [
[
"43fbe55cf81bceeb"
],
[
"605950b3904ff015"
]
]
},
{
"id": "43fbe55cf81bceeb",
"type": "rpi-gpio out",
"z": "d362bb7ca55abaf1",
"name": "",
"pin": "20",
"set": "",
"level": "0",
"freq": "",
"out": "out",
"bcm": true,
"x": 660,
"y": 180,
"wires": []
},
{
"id": "3ef47bdf1d466261",
"type": "rpi-gpio in",
"z": "d362bb7ca55abaf1",
"name": "",
"pin": "4",
"intype": "tri",
"debounce": "25",
"read": true,
"bcm": true,
"x": 150,
"y": 260,
"wires": [
[
"f7dcf0d9ada6d747"
]
]
}
]
Retrying.
The wrong flow, corrected.