How to filter looping

Hi,

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


image looping message

[
    {
        "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

Maybe the filter (RBE) node?

1 Like

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

thanks this flow working well.

[{"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":[]}]
1 Like

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