# How to filter looping

**URL:** <https://discourse.nodered.org/t/how-to-filter-looping/88545>\
**Category:** General\
**Created:** [7 June 2024 08:27 UTC](https://discourse.nodered.org/t/how-to-filter-looping/88545 "2024-06-07T08:27:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiwan-wijoyo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wiwan-wijoyo/32/48198_2.png) [@wiwan-wijoyo](https://discourse.nodered.org/u/wiwan-wijoyo)\
**Post date:** [7 June 2024 08:27 UTC](https://discourse.nodered.org/t/how-to-filter-looping/88545/1 "2024-06-07T08:27:24Z")

</div>

Hi,

how to create to the status change only one time send message(connected or disconnected) At the moment looping after 10sc.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9cfdd3a0c2d9b34a2980ca37a859efa0f6e26a66.png)  
image looping message

```auto
[
    {
        "id": "8908298453a7101b",
        "type": "inject",
        "z": "c316ced4bde3414b",
        "name": "QueryStatus 10sc",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 110,
        "y": 180,
        "wires": [
            [
                "59f8f786dc8e47ac"
            ]
        ]
    },
    {
        "id": "59f8f786dc8e47ac",
        "type": "function",
        "z": "c316ced4bde3414b",
        "name": "Ip",
        "func": "msg.payload =\n[\n \n {\n \"host\": \"192.168.16.5\"\n }\n]\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 180,
        "wires": [
            [
                "25ea9c4f735a8ad3"
            ]
        ]
    },
    {
        "id": "25ea9c4f735a8ad3",
        "type": "ping",
        "z": "c316ced4bde3414b",
        "mode": "triggered",
        "name": "",
        "host": "",
        "timer": "20",
        "inputs": 1,
        "x": 390,
        "y": 180,
        "wires": [
            [
                "1c7915fa2aad22cd"
            ]
        ]
    },
    {
        "id": "1c7915fa2aad22cd",
        "type": "function",
        "z": "c316ced4bde3414b",
        "name": "S.Results",
        "func": "let pingResults = flow.get(\"pingResults\") || {}\nlet thisPing = pingResults[msg.topic] || {};\nlet success = msg.payload !== false && msg.payload >= 0;\n\nthisPing.host = msg.ping.host;\nthisPing.timestamp = new Date();\nthisPing.responseTime = success ? msg.payload : null;\nthisPing.state = success ? \"connected\" : \"disconnected\" ;\n\npingResults[msg.topic] = thisPing;\nflow.set(\"pingResults\",pingResults);\n\nmsg.payload = thisPing;\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 520,
        "y": 180,
        "wires": [
            [
                "e016a53d35371d05"
            ]
        ]
    },
    {
        "id": "e016a53d35371d05",
        "type": "change",
        "z": "c316ced4bde3414b",
        "name": "State",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$$.payload.state",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 650,
        "y": 180,
        "wires": [
            [
                "92ef6bcdba454e0a"
            ]
        ]
    },
    {
        "id": "92ef6bcdba454e0a",
        "type": "debug",
        "z": "c316ced4bde3414b",
        "name": "payload",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 800,
        "y": 180,
        "wires": []
    }
]

```

thanks

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 June 2024 08:28 UTC](https://discourse.nodered.org/t/how-to-filter-looping/88545/2 "2024-06-07T08:28:59Z")

</div>

Maybe the `filter` (RBE) node?

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [7 June 2024 08:37 UTC](https://discourse.nodered.org/t/how-to-filter-looping/88545/3 "2024-06-07T08:37:29Z")

</div>

As @Trying_to_learn says ☝  
the Filter/RBE node can block messages, unless its changed from the last time around.

---

<div class="post-metadata">

**Author:** ![wiwan-wijoyo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wiwan-wijoyo/32/48198_2.png) [@wiwan-wijoyo](https://discourse.nodered.org/u/wiwan-wijoyo)\
**Post date:** [7 June 2024 10:21 UTC](https://discourse.nodered.org/t/how-to-filter-looping/88545/4 "2024-06-07T10:21:19Z")

</div>

thanks this flow working well.

```auto
[{"id":"4bae1d4407452f4b","type":"inject","z":"c316ced4bde3414b","name":"QueryStatus 10sc","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":80,"wires":[["41d68b4468eb57b5"]]},{"id":"41d68b4468eb57b5","type":"function","z":"c316ced4bde3414b","name":"Ip","func":"msg.payload =\n[\n \n {\n \"host\": \"192.168.16.187\"\n }\n]\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":80,"wires":[["78e92ca021c3fae4"]]},{"id":"78e92ca021c3fae4","type":"ping","z":"c316ced4bde3414b","mode":"triggered","name":"","host":"","timer":"20","inputs":1,"x":390,"y":80,"wires":[["a362e7ab1e0265c4"]]},{"id":"a362e7ab1e0265c4","type":"function","z":"c316ced4bde3414b","name":"S.Results","func":"let pingResults = flow.get(\"pingResults\") || {}\nlet thisPing = pingResults[msg.topic] || {};\nlet success = msg.payload !== false && msg.payload >= 0;\n\nthisPing.host = msg.ping.host;\nthisPing.timestamp = new Date();\nthisPing.responseTime = success ? msg.payload : null;\nthisPing.state = success ? \"connected\" : \"disconnected\" ;\n\npingResults[msg.topic] = thisPing;\nflow.set(\"pingResults\",pingResults);\n\nmsg.payload = thisPing;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":80,"wires":[["b93215bf118871b3"]]},{"id":"b93215bf118871b3","type":"change","z":"c316ced4bde3414b","name":"State","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.state","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":80,"wires":[["48cd7370a9b48cac"]]},{"id":"48cd7370a9b48cac","type":"rbe","z":"c316ced4bde3414b","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":770,"y":80,"wires":[["8f1b8ebf49ffb9c2"]]},{"id":"8f1b8ebf49ffb9c2","type":"debug","z":"c316ced4bde3414b","name":"payload","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":900,"y":80,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 June 2024 10:21 UTC](https://discourse.nodered.org/t/how-to-filter-looping/88545/5 "2024-06-21T10:21:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
