[{"id":"8b9a1993739b6995","type":"split","z":"4bfe5e028f0a64b7","name":"Split array","splt":"","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":420,"wires":[["789a8624b3a3d18c"]]},{"id":"79dde4c9664017e0","type":"ping","z":"4bfe5e028f0a64b7","mode":"triggered","name":"Ping IP","host":"","timer":"20","inputs":1,"x":250,"y":520,"wires":[["21d76c0559716722"]]},{"id":"789a8624b3a3d18c","type":"change","z":"4bfe5e028f0a64b7","name":"","rules":[{"t":"set","p":"mac","pt":"msg","to":"payload.addrMAC","tot":"msg"},{"t":"set","p":"name","pt":"msg","to":"payload.description","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.addrIP","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":420,"wires":[["79dde4c9664017e0"]]},{"id":"a1963de586b19610","type":"change","z":"4bfe5e028f0a64b7","name":"PingOutFinal","rules":[{"t":"set","p":"delay","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"ip","pt":"msg","to":"ip","tot":"msg"},{"t":"set","p":"name","pt":"msg","to":"name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":520,"wires":[["c034ce78c423e0de"]]},{"id":"d619fce5bb5949f0","type":"change","z":"4bfe5e028f0a64b7","name":"Extract required properties","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"name\": msg.name,\t \"topic\": msg.topic,\t \"mac\": msg.mac,\t \"delay\": msg.delay\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":620,"wires":[["75305fb994dec31c"]]},{"id":"75305fb994dec31c","type":"function","z":"4bfe5e028f0a64b7","name":"Color Name","func":"if (msg.delay > 250) {\n msg.payload.name = '<span style=\"color: red;\">' + msg.payload.name + '</span>';\n }else{\n if (msg.delay >50) {\n msg.payload.name = '<span style=\"color: orange;\">' + msg.payload.name + '</span>';\n }\n if (msg.delay > 25) {\n msg.payload.name = '<span style=\"color: yellow;\">' + msg.payload.name + '</span>';\n }\n} \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":620,"wires":[["c3ee3717cb540a90"]]},{"id":"c3ee3717cb540a90","type":"join","z":"4bfe5e028f0a64b7","name":"Join into array","mode":"auto","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"[ ]","joinerType":"json","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":690,"y":620,"wires":[["aa58ac129176e06b","37aac33cb4c544f7"]]},{"id":"c034ce78c423e0de","type":"function","z":"4bfe5e028f0a64b7","name":"function 24","func":"msg.topic = \"<a href=http:\\\\\" + msg.topic + \" target=_blank rel=noopener noreferrer>\" + msg.topic + \"</a>\"\nif (msg.payload.delay = 99999) {\n msg.offlineIndex = msg.offlineIndex+1\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":520,"wires":[["d619fce5bb5949f0"]]},{"id":"21d76c0559716722","type":"change","z":"4bfe5e028f0a64b7","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"99999","tot":"num"},{"t":"set","p":"arrayLength","pt":"flow","to":"length","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":520,"wires":[["a1963de586b19610"]]},{"id":"bdae06b3a5baa2a3","type":"ui_table","z":"4bfe5e028f0a64b7","group":"bf8b56c718798e2a","name":"V2","order":2,"width":11,"height":16,"columns":[{"field":"name","title":"Name","width":"40%","align":"left","formatter":"html","formatterParams":{"target":"_blank"}},{"field":"topic","title":"Topic","width":"20%","align":"left","formatter":"html","formatterParams":{"target":"_blank"}},{"field":"mac","title":"MAC","width":"24%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"delay","title":"Delay","width":"16%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":0,"cts":false,"x":1110,"y":640,"wires":[]},{"id":"882721aa09be1e9d","type":"function","z":"4bfe5e028f0a64b7","name":"sql1","func":"msg.sql1 = \"SELECT [addrIP],[addrMAC],[description] FROM OpTechAttendance order by addrIP desc;\"\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":420,"wires":[["cc54ac40d6a7fff7"]]},{"id":"cc54ac40d6a7fff7","type":"MSSQL","z":"4bfe5e028f0a64b7","mssqlCN":"c785e70192feda74","name":"","outField":"payload","returnType":"0","throwErrors":"0","query":"{{{sql1}}}","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"queryParams","paramsOptType":"msg","rows":"","rowsType":"msg","params":[],"x":620,"y":420,"wires":[["d91537cb49c6b001"]]},{"id":"993bb529d379d282","type":"inject","z":"4bfe5e028f0a64b7","name":"Start","props":[],"repeat":"600","crontab":"","once":true,"onceDelay":"2","topic":"","x":90,"y":420,"wires":[["303b70b3213530f8"]]},{"id":"d91537cb49c6b001","type":"function","z":"4bfe5e028f0a64b7","name":"function 25","func":"// Assuming msg.payload contains the result of the SQL query\n// msg.payload is an array of objects where each object represents a row\n\n// Convert the output to the desired array format\nlet outputArray = msg.payload.map(row => ({\n addrIP: row.addrIP,\n addrMAC: row.addrMAC,\n description: row.description\n}));\n\n// Set the new array to msg.payload\nmsg.payload = outputArray;\n\nmsg.length = outputArray.length\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":420,"wires":[["8b9a1993739b6995","55afd039055b89cc"]]},{"id":"303b70b3213530f8","type":"ui_button","z":"4bfe5e028f0a64b7","name":"","group":"5eaca1a3.15e28","order":4,"width":10,"height":2,"passthru":true,"label":"Table Refresh","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"date","topic":"topic","topicType":"msg","x":260,"y":420,"wires":[["882721aa09be1e9d"]]},{"id":"55afd039055b89cc","type":"debug","z":"4bfe5e028f0a64b7","name":"debug 21","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":380,"wires":[]},{"id":"b16b51d54b5f2087","type":"ui_text","z":"4bfe5e028f0a64b7","group":"bf8b56c718798e2a","order":1,"width":"12","height":"1","name":"","label":"<b>Devices Scanned/Offline: </b> ","format":"{{msg.length}} / {{msg.count}}","layout":"row-left","className":"","x":1200,"y":600,"wires":[]},{"id":"aa58ac129176e06b","type":"function","z":"4bfe5e028f0a64b7","name":"Count Offline Nodes","func":"// Assume the array of objects is in msg.payload\nlet array = msg.payload;\n\n// Initialize a counter\nlet count = 0;\n\n// Loop through the array and count the entries where delay equals 99999\nfor (let i = 0; i < array.length; i++) {\n if (array[i].delay === 99999) {\n count++;\n }\n}\n\n// Set the count in msg.count\nmsg.count = count;\n\n// Return the message object\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":620,"wires":[["bdae06b3a5baa2a3","b16b51d54b5f2087"]]},{"id":"37aac33cb4c544f7","type":"debug","z":"4bfe5e028f0a64b7","name":"debug 22","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":660,"wires":[]},{"id":"bf8b56c718798e2a","type":"ui_group","name":"Device Statistics","tab":"2806402b.f11e7","order":1,"disp":false,"width":"12","collapse":false,"className":""},{"id":"c785e70192feda74","type":"MSSQL-CN","tdsVersion":"7_4","name":"OTA","server":"database.windows.net","port":"1433","encyption":true,"trustServerCertificate":true,"database":"ProductionEnvironmentData - DEV","useUTC":true,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5","parseJSON":false,"enableArithAbort":true},{"id":"5eaca1a3.15e28","type":"ui_group","name":"Availability / Time","tab":"2806402b.f11e7","order":1,"disp":false,"width":"12","collapse":false,"className":""},{"id":"2806402b.f11e7","type":"ui_tab","name":"Networking","icon":"dashboard","order":1,"disabled":false,"hidden":false}]