Showing Ping results

Trying to get a nice display of ping results.
I tried this suggestion from @Steve-Mcl Build automatic hyperlink in html table - #3 by Steve-Mcl but get an error in the 'convert pingResults to array' function.

[
    {
        "id": "6a22dd6e.c56fc4",
        "type": "inject",
        "z": "3d4dade1618a72c7",
        "name": "*** Setup devices to ping here ***",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "20",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"name\":\"router\",\"host\":\"192.168.1.1\",\"link\":\"http://192.168.1.1/router.html\"},{\"name\":\"tv\",\"host\":\"192.168.1.46\",\"link\":\"http://192.168.1.46/channels.html\"},{\"name\":\"Pi 4 Green\",\"host\":\"192.168.1.23\"},{\"name\":\"bad device\",\"host\":\"192.168.2.99\"}]",
        "payloadType": "json",
        "x": 420,
        "y": 220,
        "wires": [
            [
                "4a46702f.96858"
            ]
        ]
    },
    {
        "id": "3539c581.74c1aa",
        "type": "template",
        "z": "3d4dade1618a72c7",
        "name": "build html table",
        "field": "html",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "\n<table width=\"100%\">\n  <tr>\n    <th>Name</th>\n    <th>Host</th> \n    <th>Status</th> \n  </tr>\n  {{#tableData}}\n  <tr class='{{rowclass}}'>\n    <td>{{{name}}}</td>\n    {{#link}}\n    <td><a href=\"{{link}}\" target=\"_blank\">{{host}}</a> </td>\n    {{/link}}\n    {{^link}}\n    <td>{{host}}</td>\n    {{/link}}  \n    <td>{{{stateInfo}}}</i></td> \n  </tr>\n  {{/tableData}}\n</table>",
        "x": 760,
        "y": 280,
        "wires": [
            [
                "db2a0a6.457cef8",
                "83b23a6b.400778"
            ]
        ]
    },
    {
        "id": "db2a0a6.457cef8",
        "type": "debug",
        "z": "3d4dade1618a72c7",
        "name": "msg_2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 320,
        "wires": []
    },
    {
        "id": "df081fcf.27c53",
        "type": "inject",
        "z": "3d4dade1618a72c7",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"name\":\"router\",\"ip\":\"192.168.1.1\"},{\"name\":\"tv\",\"ip\":\"192.168.1.23\"},{\"name\":\"smart speaker\",\"ip\":\"192.168.1.35\"},{\"name\":\"bad device\",\"ip\":\"192.168.1.99\"}]",
        "payloadType": "json",
        "x": 330,
        "y": 280,
        "wires": [
            [
                "823e24a1.87a718"
            ]
        ]
    },
    {
        "id": "823e24a1.87a718",
        "type": "function",
        "z": "3d4dade1618a72c7",
        "name": "convert pingResults to array",
        "func": "let pingResults = flow.get(\"pingResults\") || {}\nlet now = new Date();\n\nlet tableData = [];\nfor (let k in pingResults) {\n    let r = pingResults[k];\n    r.age = now - r.timestamp\n    if(r.age > 18000){\n        r.state = \"old\"\n    }\n    if(r.state == \"ok\"){\n        r.rowclass = \"good\";\n        r.stateInfo = '<i class=\"fa fa-thumbs-up\" aria-hidden=\"true\"></i> OK'\n    } else if(r.state == \"ng\") {\n         r.rowclass = \"bad\";\n        r.stateInfo = '<i class=\"fa fa-thumbs-down\" aria-hidden=\"true\"></i> NG'\n    } else {\n        r.rowclass = \"unknown\";\n        r.stateInfo = '<i class=\"fa question\" aria-hidden=\"true\"></i> ' + r.state\n    }\n    tableData.push(r);\n}\n\nmsg.tableData = tableData\n\nreturn msg;",
        "outputs": 1,
        "noerr": 1,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 540,
        "y": 280,
        "wires": [
            [
                "3539c581.74c1aa",
                "793afa09.1583c4"
            ]
        ]
    },
    {
        "id": "4a46702f.96858",
        "type": "ping",
        "z": "3d4dade1618a72c7",
        "mode": "triggered",
        "name": "",
        "host": "",
        "timer": "20",
        "inputs": 1,
        "x": 630,
        "y": 220,
        "wires": [
            [
                "fecfa19a.356ee"
            ]
        ]
    },
    {
        "id": "1b75c1a7.006c3e",
        "type": "debug",
        "z": "3d4dade1618a72c7",
        "name": "msg_1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 220,
        "wires": []
    },
    {
        "id": "fecfa19a.356ee",
        "type": "function",
        "z": "3d4dade1618a72c7",
        "name": "Store Results",
        "func": "let pingResults = flow.get(\"pingResults\") || {}\nlet thisPing = pingResults[msg.topic] || {};\nlet success = msg.payload !== false && msg.payload >= 0;\n\nthisPing.name = msg.ping.name;\nthisPing.host = msg.ping.host;\nthisPing.link = msg.ping.link;\nthisPing.timestamp = new Date();\nthisPing.responseTime = success ? msg.payload : null;\nthisPing.state = success ? \"ok\" : \"ng\" ;\n\npingResults[msg.topic] = thisPing;//store ping obj in pingResults\nflow.set(\"pingResults\",pingResults);//save pingResults in flow context\n\nmsg.payload = thisPing;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 780,
        "y": 220,
        "wires": [
            [
                "1b75c1a7.006c3e"
            ]
        ]
    },
    {
        "id": "83b23a6b.400778",
        "type": "ui_template",
        "z": "3d4dade1618a72c7",
        "group": "9f4f9ffc.07f2a",
        "name": "",
        "order": 3,
        "width": "6",
        "height": "5",
        "format": "<style>\ntable {\n    color: #333;\n    font-family: Helvetica, Arial, sans-serif;\n    width: 100%;\n    border-collapse: collapse;\n    border-spacing: 0;\n}\ntd, th {\n    border: 1px solid transparent;\n    /* No more visible border */\n    height: 30px;\n    transition: all 0.3s;\n    /* Simple transition for hover effect */\n}\nth {\n    background: #DFDFDF;\n    /* Darken header a bit */\n    font-weight: bold;\n}\ntd {\n    background: #FAFAFA;\n    text-align: center;\n}\n\n/* Cells in even rows (2,4,6...) are one color */\n\ntr:nth-child(even) td {\n    background: #F1F1F1;\n}\n\n/* Cells in odd rows (1,3,5...) are another (excludes header cells)  */\n\ntr:nth-child(odd) td {\n    background: #FEFEFE;\n}\ntr td:hover {\n    background: #666;\n    color: #FFF;\n}\n\n/* Hover cell effect! */    \n\ntr.good {\n    color: green;\n}\n\ntr.bad {\n    color: red;\n}\n\ntr.unknown {\n    color: orange;\n}\n\n    \n</style>\n<div ng-bind-html=\"msg.html\"></div>\n",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 940,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "793afa09.1583c4",
        "type": "debug",
        "z": "3d4dade1618a72c7",
        "name": "msg_3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 690,
        "y": 360,
        "wires": []
    },
    {
        "id": "9f4f9ffc.07f2a",
        "type": "ui_group",
        "name": "Default",
        "tab": "5132060d.4cde48",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "5132060d.4cde48",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

Hopeless as I am at javascript, I cannot figure out what the error is.

Now that is a blast from the past.

the function will work, the error is most likely due to recent improvements in the code editor highlighting things that should be done better

here is an updated version of the function that should not show any warnings:

const pingResults = flow.get('pingResults') || {}
const now = new Date()

const tableData = []
for (const k in pingResults) {
    const r = pingResults[k]
    r.age = now.valueOf() - r.timestamp
    if (r.age > 18000) {
        r.state = 'old'
    }
    if (r.state === 'ok') {
        r.rowclass = 'good'
        r.stateInfo = '<i class="fa fa-thumbs-up" aria-hidden="true"></i> OK'
    } else if (r.state === 'ng') {
        r.rowclass = 'bad'
        r.stateInfo = '<i class="fa fa-thumbs-down" aria-hidden="true"></i> NG'
    } else {
        r.rowclass = 'unknown'
        r.stateInfo = '<i class="fa question" aria-hidden="true"></i> ' + r.state
    }
    tableData.push(r)
}

msg.tableData = tableData

return msg;

(untested)

That's a super-fast fix-n-reply, thank you! :slight_smile:

Error has gone, but it's not showing on my dashboard.
I reckon that's because I've forgotten how to use it, although the nodes are on a tab which is showing on the dashboard.

Found it, it's in "Home", I'll try figure out how to move it to "Dashboard".

image


How do I remove .99 (it's not in the ping list), and increase refresh frequency to reduce "old"?

Thank you.

delete the flow context variable named pingResults then run it again.

(look where debug sidebar is, chose the context viewer tab)

Got this working almost brilliantly, one nagging thing is that despite deleting the flow, the old, dummy/test pings till show. They're only there for a few seconds after hitting deploy, but they're still there.

Tried F12 console " localStorage.clear(); "
Also tried viewing dashboard in completely different browser.

Any ideas as to where it's perhaps caching that data?

Thank you.

Just tried on my phone - same thing there too....!

Share your flow and I'll take a look.

hold on, did you delete the flow or the flow context variable?

Show me a screenshot of your flow context (expanded) as well as sharing your flow export.

Try unchecking Add output messages to stored state in ui template node.

Flow context image:

Tried that, but no difference.

:point_down:

:point_down:

Cant really help if you dont share your flows or answer the questions.

[
    {
        "id": "6a22dd6e.c56fc4",
        "type": "inject",
        "z": "3c4bf0a06f560726",
        "name": "*** Setup devices to ping here ***",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "20",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"name\":\"Greenhouse\",\"host\":\"192.168.1.41\"},{\"name\":\"TV\",\"host\":\"192.168.1.46\"},{\"name\":\"Pi 4 Green\",\"host\":\"192.168.1.23\"},{\"name\":\"Pi Garage\",\"host\":\"192.168.1.35\"},{\"name\":\"Pi Mote\",\"host\":\"192.168.1.15\"},{\"name\":\"Pi - ISS\",\"host\":\"192.168.1.40\"},{\"name\":\"8x8 Scroller\",\"host\":\"192.168.1.11\"},{\"name\":\"Pi Loft\",\"host\":\"192.168.1.42\"},{\"name\":\"Plane Spotter\",\"host\":\"192.168.1.29\"},{\"name\":\"Magic Mirror\",\"host\":\"192.168.1.21\"},{\"name\":\"Pi Hole\",\"host\":\"192.168.1.14\"},{\"name\":\"Hue\",\"host\":\"192.168.1.33\"},{\"name\":\"Pico O/S Temp\",\"host\":\"192.168.1.17\"},{\"name\":\"Cube\",\"host\":\"192.168.1.36\"},{\"name\":\"Pi 4 Blue\",\"host\":\"192.168.1.18\"},{\"name\":\"Pi 5\",\"host\":\"192.168.1.51\"},{\"name\":\"Pi DB Server\",\"host\":\"192.168.1.23\"},{\"name\":\"Pi Inky\",\"host\":\"192.168.1.26\"},{\"name\":\"Pi 3a/Piano\",\"host\":\"192.168.1.32\"},{\"name\":\"Printer\",\"host\":\"192.168.1.6\"},{\"name\":\"NAS\",\"host\":\"192.168.1.25\"},{\"name\":\"Music Streamer\",\"host\":\"192.168.1.36\"},{\"name\":\"WiFi AP\",\"host\":\"192.168.1.50\"}]",
        "payloadType": "json",
        "x": 240,
        "y": 1800,
        "wires": [
            [
                "4a46702f.96858"
            ]
        ]
    },
    {
        "id": "3539c581.74c1aa",
        "type": "template",
        "z": "3c4bf0a06f560726",
        "name": "build html table",
        "field": "html",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "\n<table width=\"100%\">\n  <tr>\n    <th>Name</th>\n    <th>Host</th> \n    <th>Status</th> \n  </tr>\n  {{#tableData}}\n  <tr class='{{rowclass}}'>\n    <td>{{{name}}}</td>\n    {{#link}}\n    <td><a href=\"{{link}}\" target=\"_blank\">{{host}}</a> </td>\n    {{/link}}\n    {{^link}}\n    <td>{{host}}</td>\n    {{/link}}  \n    <td>{{{stateInfo}}}</i></td> \n  </tr>\n  {{/tableData}}\n</table>",
        "x": 580,
        "y": 1860,
        "wires": [
            [
                "db2a0a6.457cef8",
                "83b23a6b.400778"
            ]
        ]
    },
    {
        "id": "db2a0a6.457cef8",
        "type": "debug",
        "z": "3c4bf0a06f560726",
        "name": "msg_2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 1920,
        "wires": []
    },
    {
        "id": "df081fcf.27c53",
        "type": "inject",
        "z": "3c4bf0a06f560726",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"name\":\"router\",\"ip\":\"192.168.1.1\"},{\"name\":\"tv\",\"ip\":\"192.168.1.23\"},{\"name\":\"smart speaker\",\"ip\":\"192.168.1.35\"},{\"name\":\"bad device\",\"ip\":\"192.168.1.99\"}]",
        "payloadType": "json",
        "x": 150,
        "y": 1860,
        "wires": [
            [
                "823e24a1.87a718"
            ]
        ]
    },
    {
        "id": "823e24a1.87a718",
        "type": "function",
        "z": "3c4bf0a06f560726",
        "name": "convert pingResults to array",
        "func": "const pingResults = flow.get('pingResults') || {}\nconst now = new Date()\n\nconst tableData = []\nfor (const k in pingResults) {\n    const r = pingResults[k]\n    r.age = now.valueOf() - r.timestamp\n    if (r.age > 21000) {\n        r.state = 'old'\n    }\n    if (r.state === 'ok') {\n        r.rowclass = 'good'\n        r.stateInfo = '<i class=\"fa fa-thumbs-up\" aria-hidden=\"true\"></i> OK'\n    } else if (r.state === 'ng') {\n        r.rowclass = 'bad'\n        r.stateInfo = '<i class=\"fa fa-thumbs-down\" aria-hidden=\"true\"></i> NG'\n    } else {\n        r.rowclass = 'unknown'\n        r.stateInfo = '<i class=\"fa question\" aria-hidden=\"true\"></i> ' + r.state\n    }\n    tableData.push(r)\n}\n\nmsg.tableData = tableData\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 1860,
        "wires": [
            [
                "3539c581.74c1aa",
                "793afa09.1583c4"
            ]
        ]
    },
    {
        "id": "4a46702f.96858",
        "type": "ping",
        "z": "3c4bf0a06f560726",
        "mode": "triggered",
        "name": "",
        "host": "",
        "timer": "20",
        "inputs": 1,
        "x": 450,
        "y": 1800,
        "wires": [
            [
                "fecfa19a.356ee"
            ]
        ]
    },
    {
        "id": "1b75c1a7.006c3e",
        "type": "debug",
        "z": "3c4bf0a06f560726",
        "name": "msg_1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 1780,
        "wires": []
    },
    {
        "id": "fecfa19a.356ee",
        "type": "function",
        "z": "3c4bf0a06f560726",
        "name": "Store Results",
        "func": "let pingResults = flow.get(\"pingResults\") || {}\nlet thisPing = pingResults[msg.topic] || {};\nlet success = msg.payload !== false && msg.payload >= 0;\n\nthisPing.name = msg.ping.name;\nthisPing.host = msg.ping.host;\nthisPing.link = msg.ping.link;\nthisPing.timestamp = new Date();\nthisPing.responseTime = success ? msg.payload : null;\nthisPing.state = success ? \"ok\" : \"ng\" ;\n\npingResults[msg.topic] = thisPing;//store ping obj in pingResults\nflow.set(\"pingResults\",pingResults);//save pingResults in flow context\n\nmsg.payload = thisPing;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 1800,
        "wires": [
            [
                "1b75c1a7.006c3e"
            ]
        ]
    },
    {
        "id": "83b23a6b.400778",
        "type": "ui_template",
        "z": "3c4bf0a06f560726",
        "group": "8ff6ebdf94641931",
        "name": "",
        "order": 3,
        "width": "6",
        "height": "20",
        "format": "<style>\ntable {\n    color: #333;\n    font-family: Helvetica, Arial, sans-serif;\n    width: 100%;\n    border-collapse: collapse;\n    border-spacing: 0;\n}\ntd, th {\n    border: 1px solid transparent;\n    /* No more visible border */\n    height: 30px;\n    transition: all 0.3s;\n    /* Simple transition for hover effect */\n}\nth {\n    background: #DFDFDF;\n    /* Darken header a bit */\n    font-weight: bold;\n}\ntd {\n    background: #FAFAFA;\n    text-align: center;\n}\n\n/* Cells in even rows (2,4,6...) are one color */\n\ntr:nth-child(even) td {\n    background: #F1F1F1;\n}\n\n/* Cells in odd rows (1,3,5...) are another (excludes header cells)  */\n\ntr:nth-child(odd) td {\n    background: #FEFEFE;\n}\ntr td:hover {\n    background: #666;\n    color: #FFF;\n}\n\n/* Hover cell effect! */    \n\ntr.good {\n    color: green;\n}\n\ntr.bad {\n    color: red;\n}\n\ntr.unknown {\n    color: orange;\n}\n\n    \n</style>\n<div ng-bind-html=\"msg.html\"></div>\n",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 760,
        "y": 1860,
        "wires": [
            []
        ]
    },
    {
        "id": "793afa09.1583c4",
        "type": "debug",
        "z": "3c4bf0a06f560726",
        "name": "msg_3",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 1980,
        "wires": []
    },
    {
        "id": "8ff6ebdf94641931",
        "type": "ui_group",
        "name": "Pinging",
        "tab": "717f2583d4cd909d",
        "order": 6,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "717f2583d4cd909d",
        "type": "ui_tab",
        "name": "Dashboard ",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

I deleted this
image

Not sure but about timing with two injects. Would it not be better to do it all with one inject and split and auto join.
example with no function nodes and joining ping results.

You can add links and any other properties to the input inject

[{"id":"ce7b4fcf0cdafcc2","type":"inject","z":"d1395164b4eec73e","name":"*** Setup devices to ping here ***","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Greenhouse\",\"host\":\"192.168.1.41\",\"link\":\"http://google.com\"},{\"name\":\"TV\",\"host\":\"192.168.1.46\",\"link\":false},{\"name\":\"Pi 4 Green\",\"host\":\"192.168.1.23\",\"link\":false},{\"name\":\"Pi Garage\",\"host\":\"192.168.1.35\",\"link\":false},{\"name\":\"Pi Mote\",\"host\":\"192.168.1.15\",\"link\":false},{\"name\":\"Pi - ISS\",\"host\":\"192.168.1.40\",\"link\":false},{\"name\":\"8x8 Scroller\",\"host\":\"192.168.1.11\",\"link\":false},{\"name\":\"Pi Loft\",\"host\":\"192.168.1.42\",\"link\":false},{\"name\":\"Plane Spotter\",\"host\":\"192.168.1.29\",\"link\":false},{\"name\":\"Magic Mirror\",\"host\":\"192.168.1.21\"},{\"name\":\"Pi Hole\",\"host\":\"192.168.1.14\",\"link\":false},{\"name\":\"Hue\",\"host\":\"192.168.1.33\",\"link\":false},{\"name\":\"Pico O/S Temp\",\"host\":\"192.168.1.17\",\"link\":false},{\"name\":\"Cube\",\"host\":\"192.168.1.36\",\"link\":false},{\"name\":\"Pi 4 Blue\",\"host\":\"192.168.1.18\",\"link\":false},{\"name\":\"Pi 5\",\"host\":\"192.168.1.51\",\"link\":false},{\"name\":\"Pi DB Server\",\"host\":\"192.168.1.23\",\"link\":false},{\"name\":\"Pi Inky\",\"host\":\"192.168.1.26\",\"link\":false},{\"name\":\"Pi 3a/Piano\",\"host\":\"192.168.1.32\",\"link\":false},{\"name\":\"Printer\",\"host\":\"192.168.1.6\",\"link\":false},{\"name\":\"NAS\",\"host\":\"192.168.1.25\",\"link\":false},{\"name\":\"Music Streamer\",\"host\":\"192.168.1.36\",\"link\":false},{\"name\":\"WiFi AP\",\"host\":\"192.168.1.50\",\"link\":false}]","payloadType":"json","x":370,"y":7540,"wires":[["1ccc69be794889a3"]]},{"id":"1ccc69be794889a3","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":610,"y":7540,"wires":[["9aa68795d91a320e"]]},{"id":"9aa68795d91a320e","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":7540,"wires":[["4a46702f.96858"]]},{"id":"4a46702f.96858","type":"ping","z":"d1395164b4eec73e","mode":"triggered","name":"","host":"","timer":"20","inputs":1,"x":310,"y":7600,"wires":[["5878a4fa2f1a22c9"]]},{"id":"5878a4fa2f1a22c9","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"temp","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"ping","tot":"msg"},{"t":"set","p":"payload.timestamp","pt":"msg","to":"$now()","tot":"jsonata"},{"t":"move","p":"temp","pt":"msg","to":"payload.responseTime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":7600,"wires":[["bb78407a3825e84a"]]},{"id":"bb78407a3825e84a","type":"join","z":"d1395164b4eec73e","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":390,"y":7660,"wires":[["238261fadd4b5b9b","1b75c1a7.006c3e"]]},{"id":"238261fadd4b5b9b","type":"change","z":"d1395164b4eec73e","name":"save pingResponse and create  tableData","rules":[{"t":"set","p":"pingResults","pt":"flow","to":"payload","tot":"msg","dc":true},{"t":"set","p":"tableData","pt":"msg","to":"$$.payload","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":7660,"wires":[["3539c581.74c1aa"]]},{"id":"1b75c1a7.006c3e","type":"debug","z":"d1395164b4eec73e","name":"msg_1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":7620,"wires":[]},{"id":"3539c581.74c1aa","type":"template","z":"d1395164b4eec73e","name":"build html table","field":"html","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\n<table width=\"100%\">\n  <tr>\n    <th>Name</th>\n    <th>Host</th> \n    <th>Status</th> \n  </tr>\n  {{#tableData}}\n  <tr class='{{#responseTime}}good{{/responseTime}}{{^responseTime}}bad{{/responseTime}}'>\n    <td>\n      {{{name}}}\n    </td>\n    <td>\n      {{#link}}<a href=\"{{link}}\" target=\"_blank\">{{host}}</a>{{/link}}{{^link}}{{host}}{{/link}}\n    </td> \n    <td>\n      {{#responseTime}}<i class=\"fa fa-thumbs-up\" aria-hidden=\"true\"></i> OK</i>{{/responseTime}}{{^responseTime}}<i class=\"fa fa-thumbs-down\" aria-hidden=\"true\"></i> NG</i>{{/responseTime}}\n    </td> \n  </tr>\n  {{/tableData}}\n</table>","x":600,"y":7720,"wires":[["db2a0a6.457cef8","83b23a6b.400778"]]},{"id":"e86fc4d62c2b1d72","type":"inject","z":"d1395164b4eec73e","name":"reload at startup","props":[{"p":"tableData","v":"pingResults","vt":"flow"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":350,"y":7720,"wires":[["3539c581.74c1aa"]]},{"id":"db2a0a6.457cef8","type":"debug","z":"d1395164b4eec73e","name":"msg_2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":7760,"wires":[]},{"id":"83b23a6b.400778","type":"ui_template","z":"d1395164b4eec73e","group":"8ff6ebdf94641931","name":"","order":3,"width":"6","height":"20","format":"<style>\ntable {\n    color: #333;\n    font-family: Helvetica, Arial, sans-serif;\n    width: 100%;\n    border-collapse: collapse;\n    border-spacing: 0;\n}\ntd, th {\n    border: 1px solid transparent;\n    /* No more visible border */\n    height: 30px;\n    transition: all 0.3s;\n    /* Simple transition for hover effect */\n}\nth {\n    background: #DFDFDF;\n    /* Darken header a bit */\n    font-weight: bold;\n}\ntd {\n    background: #FAFAFA;\n    text-align: center;\n}\n\n/* Cells in even rows (2,4,6...) are one color */\n\ntr:nth-child(even) td {\n    background: #F1F1F1;\n}\n\n/* Cells in odd rows (1,3,5...) are another (excludes header cells)  */\n\ntr:nth-child(odd) td {\n    background: #FEFEFE;\n}\ntr td:hover {\n    background: #666;\n    color: #FFF;\n}\n\n/* Hover cell effect! */    \n\ntr.good {\n    color: green;\n}\n\ntr.bad {\n    color: red;\n}\n\ntr.unknown {\n    color: orange;\n}\n\n    \n</style>\n<div ng-bind-html=\"msg.html\"></div>\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":860,"y":7720,"wires":[[]]},{"id":"8ff6ebdf94641931","type":"ui_group","name":"Pinging","tab":"717f2583d4cd909d","order":6,"disp":true,"width":"6","collapse":false,"className":""},{"id":"717f2583d4cd909d","type":"ui_tab","name":"Dashboard ","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Where am I now?
Well, the list became too long so I have split it into Pi and non Pi devices.
I also found that the default/dummy IPs and the 30 second delay are in the second inject, so changed this to just ping my router and wait for only 3 seconds.

It's working well, and I am certainly interested in trying the suggestion from @E1cid , which I will do when I get a moment.

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