Skip to content

Instantly share code, notes, and snippets.

@sammachin
Last active April 24, 2023 06:12
Show Gist options
  • Save sammachin/2a4ee34d62c1fc890e87e536cd34897f to your computer and use it in GitHub Desktop.
Save sammachin/2a4ee34d62c1fc890e87e536cd34897f to your computer and use it in GitHub Desktop.
Ping a Host

Flow to ping a given IP address each second and if it is down for 5 seconds send a DOWN message, if the host starts responding the timer is reset and an UP message will be sent once.

[
{
"id": "f4e5cd9e434f5567",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "5d501c6fa918035d",
"type": "ping",
"z": "f4e5cd9e434f5567",
"protocol": "Automatic",
"mode": "timed",
"name": "",
"host": "192.168.1.123",
"timer": "1",
"inputs": 0,
"x": 150,
"y": 380,
"wires": [
[
"c3bcb95c40f50b53"
]
]
},
{
"id": "4a693eafa0c30293",
"type": "trigger",
"z": "f4e5cd9e434f5567",
"name": "",
"op1": "",
"op2": "DOWN",
"op1type": "nul",
"op2type": "str",
"duration": "5",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "UP",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 780,
"y": 360,
"wires": [
[
"bfe05b4d867b334e"
]
]
},
{
"id": "411ee745138899d0",
"type": "change",
"z": "f4e5cd9e434f5567",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "UP",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 600,
"y": 400,
"wires": [
[
"4a693eafa0c30293",
"bfe05b4d867b334e"
]
]
},
{
"id": "c3bcb95c40f50b53",
"type": "switch",
"z": "f4e5cd9e434f5567",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "false"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 350,
"y": 380,
"wires": [
[
"4a693eafa0c30293"
],
[
"411ee745138899d0"
]
]
},
{
"id": "dcac14b4e5def6ab",
"type": "debug",
"z": "f4e5cd9e434f5567",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1270,
"y": 400,
"wires": []
},
{
"id": "bfe05b4d867b334e",
"type": "rbe",
"z": "f4e5cd9e434f5567",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"topi": "topic",
"x": 970,
"y": 400,
"wires": [
[
"dcac14b4e5def6ab"
]
]
}
]
@fribse
Copy link

fribse commented Apr 24, 2023

When trying to use this, I get a DOWN immediately (after 1s) not after 5s?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment