Trigger output once

Hello everyone,

I'm here asking , i currently have an issue when i have multiple true inject nodes going into 1 debug node, however when i inject 3 times it's give me 3 output values , but since the value are the same is it possible to only have 1 output value. eg. it will show only 1 true even i press all the inject node.

thank you all!

Welcome to the Forum.

try rbe (filter) node

[{"id":"d1209353ebd402fe","type":"debug","z":"3f2927b6d28dd94e","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":620,"y":400,"wires":[]},{"id":"e239a1b342ad0716","type":"rbe","z":"3f2927b6d28dd94e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":430,"y":400,"wires":[["d1209353ebd402fe"]]},{"id":"71054283706a0569","type":"inject","z":"3f2927b6d28dd94e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":230,"y":340,"wires":[["e239a1b342ad0716"]]},{"id":"90d22583ba412018","type":"inject","z":"3f2927b6d28dd94e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":230,"y":380,"wires":[["e239a1b342ad0716"]]},{"id":"a93e12f1aa201c02","type":"inject","z":"3f2927b6d28dd94e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":230,"y":420,"wires":[["e239a1b342ad0716"]]},{"id":"f52cda6efc62f122","type":"inject","z":"3f2927b6d28dd94e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":230,"y":460,"wires":[["e239a1b342ad0716"]]}]

rbe

Thank you for the reply, however now i try your solution already it's still give me 3 different output even when i inject all the same time , is it possible to have only 1 output when injected at the same time with the same values being injected.

this is the flow i am working on. thank you

[{"id":"7868b47c0d956332","type":"tab","label":"Flow 14","disabled":false,"info":"","env":[]},{"id":"d1b439a760ebc555","type":"debug","z":"7868b47c0d956332","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":720,"y":160,"wires":[]},{"id":"052870081cdb10a9","type":"rbe","z":"7868b47c0d956332","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":530,"y":160,"wires":[["d1b439a760ebc555"]]},{"id":"a5b90bfcf2c9cd92","type":"inject","z":"7868b47c0d956332","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"a","payload":"true","payloadType":"bool","x":340,"y":100,"wires":[["052870081cdb10a9"]]},{"id":"c210c384c55fd26b","type":"inject","z":"7868b47c0d956332","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"b","payload":"true","payloadType":"bool","x":340,"y":140,"wires":[["052870081cdb10a9"]]},{"id":"01cc1249071cf1d5","type":"inject","z":"7868b47c0d956332","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":330,"y":180,"wires":[["052870081cdb10a9"]]},{"id":"4f477525ce38e77b","type":"inject","z":"7868b47c0d956332","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":330,"y":220,"wires":[["052870081cdb10a9"]]}]

please use proper format for posting flow, Press Ctrl+E and paste the flow inside the backticks

I am not an expert, may be it is because you have a different topic for each message but try removing the tick from the below checkbox in the Filter node

image

Node Red cannot run nodes in parallel, only one at a time. Your inject nodes each output a message one after the other. You could combine 4 consecutive messages into an array, e.g. with a join node. Then in the next step you could compare all array values ​​with a boolean function.

Look at this flow:

[
    {
        "id": "7868b47c0d956332",
        "type": "tab",
        "label": "Flow 14",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "d1b439a760ebc555",
        "type": "debug",
        "z": "7868b47c0d956332",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1180,
        "y": 140,
        "wires": []
    },
    {
        "id": "a5b90bfcf2c9cd92",
        "type": "inject",
        "z": "7868b47c0d956332",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "parts",
                "v": "{\"type\":\"array\",\"count\":4,\"len\":1,\"index\":0}",
                "vt": "json"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "a",
        "payload": "$random()<0.5?false:true\t\t",
        "payloadType": "jsonata",
        "x": 330,
        "y": 180,
        "wires": [
            [
                "9ee55c0334ad28a5"
            ]
        ]
    },
    {
        "id": "c210c384c55fd26b",
        "type": "inject",
        "z": "7868b47c0d956332",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "parts",
                "v": "{\"type\":\"array\",\"count\":4,\"len\":1,\"index\":1}",
                "vt": "json"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "b",
        "payload": "$random()<0.5?false:true\t",
        "payloadType": "jsonata",
        "x": 330,
        "y": 220,
        "wires": [
            [
                "9ee55c0334ad28a5"
            ]
        ]
    },
    {
        "id": "01cc1249071cf1d5",
        "type": "inject",
        "z": "7868b47c0d956332",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "parts",
                "v": "{\"type\":\"array\",\"count\":4,\"len\":1,\"index\":2}",
                "vt": "json"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "$random()<0.5?false:true",
        "payloadType": "jsonata",
        "x": 330,
        "y": 260,
        "wires": [
            [
                "9ee55c0334ad28a5"
            ]
        ]
    },
    {
        "id": "4f477525ce38e77b",
        "type": "inject",
        "z": "7868b47c0d956332",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "parts",
                "v": "{\"type\":\"array\",\"count\":4,\"len\":1,\"index\":3}",
                "vt": "json"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "$random()<0.5?false:true",
        "payloadType": "jsonata",
        "x": 330,
        "y": 300,
        "wires": [
            [
                "9ee55c0334ad28a5"
            ]
        ]
    },
    {
        "id": "9ee55c0334ad28a5",
        "type": "function",
        "z": "7868b47c0d956332",
        "name": "ID Generator",
        "func": "if(msg.topic !== 'generate'){\n    msg.parts.id = context.get('uid');\n    return msg;\n}else{\n    context.set('uid', RED.util.generateId());\n}\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\n\ncontext.set('uid', RED.util.generateId());",
        "finalize": "",
        "libs": [],
        "x": 630,
        "y": 240,
        "wires": [
            [
                "633b3963c716151f"
            ]
        ]
    },
    {
        "id": "1e414061f410229f",
        "type": "change",
        "z": "7868b47c0d956332",
        "name": "generate ID",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "generate",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 360,
        "wires": [
            [
                "9ee55c0334ad28a5"
            ]
        ]
    },
    {
        "id": "633b3963c716151f",
        "type": "join",
        "z": "7868b47c0d956332",
        "name": "",
        "mode": "auto",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": "false",
        "timeout": "",
        "count": "",
        "reduceRight": false,
        "x": 890,
        "y": 240,
        "wires": [
            [
                "1e414061f410229f",
                "45dee4673f86637e",
                "d1b439a760ebc555"
            ]
        ]
    },
    {
        "id": "45dee4673f86637e",
        "type": "function",
        "z": "7868b47c0d956332",
        "name": "AND",
        "func": "msg.payload = msg.payload[0] && msg.payload[1] && msg.payload[2] && msg.payload[3];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1170,
        "y": 240,
        "wires": [
            [
                "d1b439a760ebc555"
            ]
        ]
    }
]

It works for me. After injecting False, I get just one True output.

In the filter node you have the Apply mode separately for each checked and are using msg.topic. This means that msgs are filtered by topic

Now in your flow you have one inject with a topic of a, the second uses a topic of b while the last two have no topic. So when you start up, the first three nodes start sending a msg every second. Since each has a seperate topic, the first msg per topic is sent on. After that they are blocked because msg.payload has not changed.

When you click the fourth inject it has no topic, but the msg.payload has changed so it goes thru, then when inject 3 fires, it is passed because the msg.payload has changed but subsiquent msgs will not be passed because they msg.payload has not changed.
I hope this clears up what is happening.