Help with PING flow

Hi there,

I am trying to use the ping component to trigger a GPIO output on my Raspberry PI.

Using the PING component, I want to trigger the output when the device is unreachable, (false)
Then, turn the output off again if the device is reachable.

This will happen for around x20 devices being pinged.

I am using the Toggle option to toggle the GPIO, however I seem to have an issue where I cannot turn the toggle offf when the ping is reporting the response time.

When the ping is unreachable, it returns "false", when the ping is reachable it returns its response time.

The problem is, I cant choose anywhere to turn my toggle off based on "number is <100". I can only seem to set a static number.

Here is my flow, not sure if there is an easier way to do this, but im also trying to use the change function to change the response times from anything <100 to true,

Then setting in the toggle Toggle ON = falase and toggle OFF = true.

But again, I cannot set the value range in the change function for the number <100, only a static number.

Thanks

[
    {
        "id": "21745817fbfd18be",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "07369c56759dbef9",
        "type": "rpi-gpio out",
        "z": "21745817fbfd18be",
        "name": "",
        "pin": "23",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1100,
        "y": 240,
        "wires": []
    },
    {
        "id": "997431fe224c9b30",
        "type": "ping",
        "z": "21745817fbfd18be",
        "protocol": "IPv4",
        "mode": "timed",
        "name": "",
        "host": "192.168.1.1",
        "timer": "5",
        "inputs": 0,
        "x": 430,
        "y": 240,
        "wires": [
            [
                "5daad88e96e03a20",
                "41dcfe812b855d0d",
                "b654c738e9d99f54"
            ]
        ]
    },
    {
        "id": "5daad88e96e03a20",
        "type": "change",
        "z": "21745817fbfd18be",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "true",
                "fromt": "bool",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 320,
        "wires": [
            [
                "41dcfe812b855d0d"
            ]
        ]
    },
    {
        "id": "41dcfe812b855d0d",
        "type": "toggle",
        "z": "21745817fbfd18be",
        "name": "",
        "onOffTopic": "",
        "onValue": "false",
        "onType": "bool",
        "offValue": "true",
        "offType": "bool",
        "toggleTopic": "",
        "toggleValue": "",
        "toggleType": "str",
        "passOnOff": "",
        "x": 870,
        "y": 240,
        "wires": [
            [
                "07369c56759dbef9"
            ]
        ]
    },
    {
        "id": "b654c738e9d99f54",
        "type": "debug",
        "z": "21745817fbfd18be",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 700,
        "y": 140,
        "wires": []
    }
]

I do a ping to the device (allowing 30 seconds) then use a switch node where msg.payload is greater than 0 and an otherwise to detect a connection or not.

[{"id":"e7318fec9ac526c4","type":"switch","z":"43cc98e87cd1e2cb","name":"Check if found","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":420,"wires":[["02ce8a2e8b5849b4"],["064cb829573a3595"]]}]

From this I then branch to the success or failed path setting the payload to true or false.

[{"id":"e7318fec9ac526c4","type":"switch","z":"43cc98e87cd1e2cb","name":"Check if found","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":420,"wires":[["02ce8a2e8b5849b4"],["064cb829573a3595"]]},{"id":"02ce8a2e8b5849b4","type":"change","z":"43cc98e87cd1e2cb","name":"Kermit Up","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":380,"wires":[["11db2d99c6b03bd2","02a37cc6be3e07ee"]]},{"id":"064cb829573a3595","type":"change","z":"43cc98e87cd1e2cb","name":"Kermit Down","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":460,"wires":[["11db2d99c6b03bd2","ed996b7955e5e0e9"]]}]

To cut down on repeated messages (i.e. the box is down for a long time) I use the filter node:

[{"id":"6d1d0c7131267df0","type":"rbe","z":"c4db8f1a788a25fe","name":"Filter status changes only","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":510,"y":280,"wires":[["52c7f4a0d68608d4","9ffafa5b141e74ff"]]}]

This only lets changes come through - you may want to rate limit messages after this if you have systems that are 'bouncing' a lot and do not want to get woken up by lots of change notifications.

( Kermit is my NAS and no it was named after the protocol not the frog - the smaller box Robin on the other hand was named after the frog :slight_smile: )

Hmmm ok thanks, I have that working, right up until the filter changes,

However, I am not seeing a restore or (true) sent after the false is sent,

It sends multiple True's to the GPIO which is good, when I inject a False the GPIO state changes to False. Correct.

But then, it should change back to true as it receives sucessful pings?

How can I make it so it only restores when that device is back online,

Damn this is harden than I thought haha.

I don't see the value in your toggle node and your change node seems to be searching for true and replacing it with true.

Does this not work? (probably it's the same as @AndrewBeasley offers.)

[{"id":"07369c56759dbef9","type":"rpi-gpio out","z":"21745817fbfd18be","name":"","pin":"23","set":"","level":"0","freq":"","out":"out","bcm":true,"x":620,"y":160,"wires":[]},{"id":"997431fe224c9b30","type":"ping","z":"21745817fbfd18be","protocol":"IPv4","mode":"timed","name":"","host":"192.168.1.1","timer":"5","inputs":0,"x":110,"y":160,"wires":[["b24b2ab677a19de3"]]},{"id":"b24b2ab677a19de3","type":"switch","z":"21745817fbfd18be","name":"Is false?","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":160,"wires":[["f490527e21967936"],["7d9b8b3dd37f7e49"]]},{"id":"f490527e21967936","type":"change","z":"21745817fbfd18be","name":"payload = 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":140,"wires":[["07369c56759dbef9"]]},{"id":"7d9b8b3dd37f7e49","type":"change","z":"21745817fbfd18be","name":"payload = 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":180,"wires":[["07369c56759dbef9"]]}]