Created
October 8, 2018 13:42
-
-
Save dexterlabora/a01bf143b4728b3a61506057af4c40c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "6b02c4a0.a0d1ac", | |
"type": "tab", | |
"label": "Alerts", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "def605c1.7fb328", | |
"type": "http in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"url": "/alerts", | |
"method": "post", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 130, | |
"y": 80, | |
"wires": [ | |
[ | |
"63a53d58.8010f4", | |
"5ce30475.68c43c" | |
] | |
] | |
}, | |
{ | |
"id": "e8130c2c.a8e5c", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Alerts", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 890, | |
"y": 120, | |
"wires": [] | |
}, | |
{ | |
"id": "63a53d58.8010f4", | |
"type": "http response", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"statusCode": "201", | |
"headers": {}, | |
"x": 360, | |
"y": 60, | |
"wires": [] | |
}, | |
{ | |
"id": "6b096442.9fca2c", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Alert Counter", | |
"func": "// initialise the counter to 0 if it doesn't exist already\nvar count = context.get('count')||0;\ncount += 1;\n// store the value back\ncontext.set('count',count);\n// make it part of the outgoing msg object\nmsg.count = count;\n\nnode.status({text:msg.count});\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 750, | |
"y": 80, | |
"wires": [ | |
[ | |
"e8130c2c.a8e5c", | |
"3cc0f382.9d3ddc" | |
] | |
] | |
}, | |
{ | |
"id": "d94d8eb2.69338", | |
"type": "firebase modify", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"firebaseconfig": "", | |
"childpath": "msg.childpath", | |
"method": "set", | |
"value": "msg.payload", | |
"priority": "msg.priority", | |
"x": 440, | |
"y": 340, | |
"wires": [ | |
[ | |
"e5e824ed.ad8728" | |
] | |
] | |
}, | |
{ | |
"id": "e5e824ed.ad8728", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Firebase Set", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 590, | |
"y": 380, | |
"wires": [] | |
}, | |
{ | |
"id": "25d7cd8d.c26fd2", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "TEST - Motion Alert", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 150, | |
"y": 120, | |
"wires": [ | |
[ | |
"11f39210.ec3c9e" | |
] | |
] | |
}, | |
{ | |
"id": "89194097.1c29", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "path", | |
"func": "\nfunction camelize(str) {\n return str.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function(match, index) {\n if (+match === 0) return \"\"; // or if (/\\s+/.test(match)) for white spaces\n return index === 0 ? match.toLowerCase() : match.toUpperCase();\n });\n}\n\nfunction format(str){\n return str.replace(/\\s+/g, '-').toLowerCase();\n}\n\nif(msg.payload.alertType && msg.payload.occurredAt){\n msg.childpath = \"/alerts/\"+format(msg.payload.alertType)+\"/\"+Math.floor(msg.payload.occurredAt);\n}else{\n msg.childpath = \"/catchAll/\"+Math.floor(Date.now() / 1000);\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 150, | |
"y": 340, | |
"wires": [ | |
[ | |
"d94d8eb2.69338" | |
] | |
] | |
}, | |
{ | |
"id": "3cc0f382.9d3ddc", | |
"type": "link out", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Alerts", | |
"links": [ | |
"d5c7b31c.501f5", | |
"e18c08af.2dc2f8", | |
"4629e728.0bbec8", | |
"54ff3ddc.ca4264", | |
"4c71e000.409c1", | |
"5d45b2a3.4b965c", | |
"3e8c9452.59b2ac", | |
"df01343d.3582a8", | |
"4da77a7e.8faf24", | |
"12ed1b4a.d8fbd5" | |
], | |
"x": 895, | |
"y": 80, | |
"wires": [] | |
}, | |
{ | |
"id": "861bff90.9a5b1", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Meraki Webhook Alerts", | |
"info": "", | |
"x": 120, | |
"y": 40, | |
"wires": [] | |
}, | |
{ | |
"id": "993d7274.d1fe1", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Store Alerts in Google Firebase Database", | |
"info": "", | |
"x": 180, | |
"y": 300, | |
"wires": [] | |
}, | |
{ | |
"id": "1868f19.d33430e", | |
"type": "http in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"url": "/alerts", | |
"method": "get", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 100, | |
"y": 480, | |
"wires": [ | |
[ | |
"5f4e6494.f4c95c" | |
] | |
] | |
}, | |
{ | |
"id": "78165ff3.748ae", | |
"type": "http response", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"x": 550, | |
"y": 480, | |
"wires": [] | |
}, | |
{ | |
"id": "1a544ccb.c18c73", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "VueJS App", | |
"info": "", | |
"x": 80, | |
"y": 440, | |
"wires": [] | |
}, | |
{ | |
"id": "5f4e6494.f4c95c", | |
"type": "template", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "VueJS SocketIO", | |
"field": "payload", | |
"fieldType": "msg", | |
"format": "html", | |
"syntax": "plain", | |
"template": "\n<html>\n\n<head>\n\n</head>\n\n<body>\n\n <div id=\"container\" class=\"container\">\n <div class=\"page-header\">\n <h1>VueJS + SocketIO <small>Real-time server communication</small></h1>\n </div>\n <p>Connected: <b :style=\"{ color: isConnected ? 'green' : 'red'}\">{{ isConnected }}</b></p>\n \n <br>\n <input type=\"text\" id=\"container\" placeholder=\"enter text\" v-model=\"form.input1\">\n <button @click=\"onSubmit()\">Send</button>\n \n <br>\n \n <div class=\"well\">\n <div v-if=\"typeof value === 'object'\">\n <h4>Message - JSON</h4>\n <json-tree :data=\"value\"></json-tree>\n </div>\n <div v-else>\n <h4>Message</h4>\n <p>{{ value }}</p>\n </div>\n </div> \n\n\n </div>\n\n <script src=\"https://unpkg.com/vue\"></script>\n <script type=\"text/javascript\" src=\"https://unpkg.com/v-json-tree/dist/v-json-tree.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js\"></script>\n <!-- Bootstrap Latest compiled and minified CSS -->\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\">\n\n <script>\n Vue.use(JsonTree)\n var app = new Vue({\n el: '#container',\n data() {\n return {\n form: {\n input1: '',\n },\n value: 'hello world',\n isConnected: false,\n\n }\n },\n computed: {\n socket() {\n return socket = io();\n }\n },\n methods: {\n onSubmit() {\n let data = this.form;\n console.log('submitting data', data);\n //this.socket.send(data);\n this.socket.send(data);\n\n },\n updateMsg(msg) {\n this.value = msg;\n }\n },\n mounted() {\n\n this.socket.on('connect', function (s) {\n console.log('connect');\n app.updateMsg('connected');\n app.isConnected = true;\n });\n this.socket.on('disconnect', function (s) {\n console.log('disconnected');\n app.isConnected = false;\n });\n this.socket.on('message', function (data) {\n console.log('message:', data);\n app.value = data;\n });\n\n }\n });\n\n\n\n </script>\n\n\n</body>\n\n</html>", | |
"output": "str", | |
"x": 360, | |
"y": 480, | |
"wires": [ | |
[ | |
"78165ff3.748ae" | |
] | |
] | |
}, | |
{ | |
"id": "2d56ce38.5dd092", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "socket", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 610, | |
"y": 640, | |
"wires": [] | |
}, | |
{ | |
"id": "590ab927.3d5368", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 160, | |
"y": 600, | |
"wires": [ | |
[ | |
"fe872bd0.332e98" | |
] | |
] | |
}, | |
{ | |
"id": "bb2ed95c.f017d8", | |
"type": "socketio-in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"path": "message", | |
"output": "payload", | |
"pathType": "str", | |
"x": 160, | |
"y": 640, | |
"wires": [ | |
[ | |
"2d56ce38.5dd092", | |
"fe872bd0.332e98" | |
] | |
] | |
}, | |
{ | |
"id": "fe872bd0.332e98", | |
"type": "socketio-out", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "message", | |
"path": "message", | |
"pathType": "str", | |
"value": "payload", | |
"valueType": "msg", | |
"x": 360, | |
"y": 600, | |
"wires": [] | |
}, | |
{ | |
"id": "4c71e000.409c1", | |
"type": "link in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"links": [ | |
"3cc0f382.9d3ddc" | |
], | |
"x": 115, | |
"y": 560, | |
"wires": [ | |
[ | |
"fe872bd0.332e98" | |
] | |
] | |
}, | |
{ | |
"id": "6119627a.37f98c", | |
"type": "http request", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"method": "POST", | |
"ret": "txt", | |
"url": "https://script.google.com/macros/s/AKfycbxfw9SRW5qGfJjhsmVgsq-LWQsieogbH4glfg_12341234/exec", | |
"tls": "", | |
"x": 430, | |
"y": 740, | |
"wires": [ | |
[ | |
"745878a1.890cf8" | |
] | |
] | |
}, | |
{ | |
"id": "6527cc0a.d96034", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Test", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 110, | |
"y": 780, | |
"wires": [ | |
[ | |
"17748c4f.72cf54" | |
] | |
] | |
}, | |
{ | |
"id": "17748c4f.72cf54", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Sample Alert", | |
"func": "msg.payload = {\"alertData\":{\"timestamp\":msg.payload,\"roi\":{\"top\":0,\"left\":0,\"width\":60,\"height\":33}},\"alertId\":\"643451796765275003\",\"alertType\":\"Motion detected\",\"occurredAt\":1536127340.8236248,\"sentAt\":1536127344.593023,\"organizationId\":\"306267\",\"organizationName\":\"Dexter's Laboratory\",\"organizationUrl\":\"https://n143.meraki.com/o/3ZZIub/manage/organization/overview\",\"networkId\":\"L_643451796760561218\",\"networkName\":\"Dexter LaBora - Home\",\"networkUrl\":\"https://n143.meraki.com/Dexter-LaBora-Ho/n/RSv2xapc/manage/nodes/list\",\"deviceSerial\":\"Q2GV-658H-XUKP\",\"deviceMac\":\"34:56:fe:a3:24:06\",\"deviceName\":\"MV12w-desk-06\",\"deviceUrl\":\"https://n143.meraki.com/Dexter-LaBora-Ho/n/RSv2xapc/manage/nodes/new_list/57548243936262\"}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 250, | |
"y": 780, | |
"wires": [ | |
[ | |
"6119627a.37f98c" | |
] | |
] | |
}, | |
{ | |
"id": "745878a1.890cf8", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "false", | |
"x": 600, | |
"y": 740, | |
"wires": [] | |
}, | |
{ | |
"id": "3e8c9452.59b2ac", | |
"type": "link in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"links": [ | |
"3cc0f382.9d3ddc" | |
], | |
"x": 75, | |
"y": 740, | |
"wires": [ | |
[ | |
"6119627a.37f98c" | |
] | |
] | |
}, | |
{ | |
"id": "6449e9bb.f847c8", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "SocketIO - Realtime communication with web app", | |
"info": "", | |
"x": 350, | |
"y": 540, | |
"wires": [] | |
}, | |
{ | |
"id": "2b38752a.82d06a", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Send to Google Sheet", | |
"info": "", | |
"x": 120, | |
"y": 700, | |
"wires": [] | |
}, | |
{ | |
"id": "df01343d.3582a8", | |
"type": "link in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Photon", | |
"links": [ | |
"3cc0f382.9d3ddc" | |
], | |
"x": 55, | |
"y": 340, | |
"wires": [ | |
[ | |
"89194097.1c29" | |
] | |
] | |
}, | |
{ | |
"id": "11f39210.ec3c9e", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Sample Motion Alert", | |
"func": "msg.payload = {\n \"alertData\": {\n \"timestamp\": 1536127239.706,\n \"roi\": { \"top\": 0, \"left\": 0, \"width\": 60, \"height\": 33 }\n },\n \"alertId\": \"643451796765275003\",\n \"alertType\": \"Motion detected\",\n \"occurredAt\": 1536127340.8236248,\n \"sentAt\": 1536127344.593023,\n \"organizationId\": \"123456\",\n \"organizationName\": \"Organization\",\n \"organizationUrl\": \"https://n1.meraki.com/o/.../organization/overview\",\n \"networkId\": \"L_123456789123456789\",\n \"networkName\": \"Network - 1\",\n \"networkUrl\": \"https://n1.meraki.com/...\",\n \"deviceSerial\": \"AAAA-BBBB-CCCC\",\n \"deviceMac\": \"00:11:22:33:44:55\",\n \"deviceName\": \"MV12w-06\",\n \"deviceUrl\": \"https://n1.meraki.com/.../manage/nodes/new_list/...\"\n};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 520, | |
"y": 120, | |
"wires": [ | |
[ | |
"6b096442.9fca2c" | |
] | |
] | |
}, | |
{ | |
"id": "d3e57d06.1915e", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Network Automation - Dynamic Port Configuration", | |
"info": "", | |
"x": 210, | |
"y": 860, | |
"wires": [] | |
}, | |
{ | |
"id": "61b046ef.6dca48", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Check for MAC if in list - modify list here", | |
"func": "var macs = [\n \"00:18:0a:32:cc:34\"\n]\n\nvar clients = msg.payload;\nfor(var c in clients){\n if(macs.includes(msg.payload[c].mac)){\n msg.authorized = true;\n }else{\n msg.authorized = false;\n }\n}\n\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 540, | |
"y": 1040, | |
"wires": [ | |
[ | |
"47a5f887.539bc8", | |
"8989b029.ed062" | |
] | |
] | |
}, | |
{ | |
"id": "4da77a7e.8faf24", | |
"type": "link in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"links": [ | |
"3cc0f382.9d3ddc" | |
], | |
"x": 75, | |
"y": 960, | |
"wires": [ | |
[ | |
"22e49352.d824dc" | |
] | |
] | |
}, | |
{ | |
"id": "22e49352.d824dc", | |
"type": "switch", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Switch port connected", | |
"property": "payload.alertType", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "eq", | |
"v": "Switch port connected", | |
"vt": "str" | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 1, | |
"x": 220, | |
"y": 960, | |
"wires": [ | |
[ | |
"ef3ccdc8.9a89e" | |
] | |
] | |
}, | |
{ | |
"id": "783ecf0a.bb9df", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Meraki API: Change Port", | |
"func": "// Set Variables\nvar apiKey = flow.get('apiKey');\nvar serial = msg.alert.deviceSerial;\nvar port = msg.alert.alertData.portNum;\nvar data = {\n \"name\": \"NAC device\",\n \"tags\": \"API Node-RED\",\n \"enabled\": true,\n \"poeEnabled\": true,\n \"type\": \"trunk\",\n \"vlan\": 1,\n \"voiceVlan\": null,\n \"allowedVlans\": \"all\",\n \"isolationEnabled\": false,\n \"rstpEnabled\": true,\n \"stpGuard\": \"disabled\",\n \"accessPolicyNumber\": null\n}\nmsg.headers = {\n \"X-Cisco-Meraki-API-Key\": apiKey,\n \"Content-Type\":\"application/json\"\n};\nmsg.url = \"https://n143.meraki.com/api/v0/devices/\"+serial+\"/switchPorts/\"+port;\nmsg.method = 'put';\nmsg.payload = data;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 490, | |
"y": 1120, | |
"wires": [ | |
[ | |
"bb21325e.233f8" | |
] | |
] | |
}, | |
{ | |
"id": "ef3ccdc8.9a89e", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Meraki API: Get Clients of Switch Device", | |
"func": "// Set Variables\nvar apiKey = flow.get('apiKey');\nvar serial = msg.payload.deviceSerial;\nmsg.alert = msg.payload; // make a copy for use later \nmsg.headers = {\n \"X-Cisco-Meraki-API-Key\": apiKey\n};\nmsg.url = \"https://api.meraki.com/api/v0/devices/\"+serial+\"/clients?timespan=7200\";\nmsg.method = 'get';\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 540, | |
"y": 960, | |
"wires": [ | |
[ | |
"992219c8.68a8e8" | |
] | |
] | |
}, | |
{ | |
"id": "17c1214e.eea4af", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Dynamic Port Automation: Sample", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 560, | |
"y": 920, | |
"wires": [] | |
}, | |
{ | |
"id": "bb21325e.233f8", | |
"type": "http request", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"method": "use", | |
"ret": "obj", | |
"url": "", | |
"tls": "", | |
"x": 710, | |
"y": 1120, | |
"wires": [ | |
[ | |
"2ddbc1a5.ee5b7e" | |
] | |
] | |
}, | |
{ | |
"id": "992219c8.68a8e8", | |
"type": "http request", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"method": "use", | |
"ret": "obj", | |
"url": "", | |
"tls": "", | |
"x": 810, | |
"y": 960, | |
"wires": [ | |
[ | |
"a8aa561f.95a0c8", | |
"d8a45bfe.899538", | |
"b022029d.72915" | |
] | |
] | |
}, | |
{ | |
"id": "a8aa561f.95a0c8", | |
"type": "http response", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"x": 1030, | |
"y": 960, | |
"wires": [] | |
}, | |
{ | |
"id": "3815f034.c2635", | |
"type": "credentials", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Meraki API Demo", | |
"props": [ | |
{ | |
"value": "apiKey", | |
"type": "flow" | |
} | |
], | |
"x": 170, | |
"y": 1040, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "d8a45bfe.899538", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Meraki API: Get Clients", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"x": 970, | |
"y": 920, | |
"wires": [] | |
}, | |
{ | |
"id": "4e9c710b.0232a", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Set Flow Variables", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": true, | |
"onceDelay": 0.1, | |
"x": 170, | |
"y": 1000, | |
"wires": [ | |
[ | |
"3815f034.c2635" | |
] | |
] | |
}, | |
{ | |
"id": "f9a143c0.247c9", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Test", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 110, | |
"y": 920, | |
"wires": [ | |
[ | |
"ef050f72.34a9e" | |
] | |
] | |
}, | |
{ | |
"id": "ef050f72.34a9e", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Sample Alert", | |
"func": "msg.payload = {\n \"alertData\" : {\n \"description\" : \"\",\n \"portDesc\" : \"Office / 7 (BLACK HOLE) Access port on VLAN 99\",\n \"portNum\" : 7,\n \"prevStatus\" : 0,\n \"status\" : 66067\n },\n \"alertId\" : \"643451796765277070\",\n \"alertType\" : \"Switch port connected\",\n \"deviceMac\" : \"88:15:44:11:11:11\",\n \"deviceName\" : \"Office\",\n \"deviceSerial\" : \"Q2HP-6Z82-AAAA\",\n \"deviceUrl\" : \"https://n143.meraki.com/Miles-Ho/n/-FqWScpc/manage/nodes/new_list/149624931440683\",\n \"networkId\" : \"L_64345179676012345\",\n \"networkName\" : \"Miles - Home\",\n \"networkUrl\" : \"https://n143.meraki.com/Miles-Ho/n/-FqWScpc/manage/nodes/list\",\n \"occurredAt\" : 1536157718,\n \"organizationId\" : \"123123\",\n \"organizationName\" : \"Miles's Laboratory\",\n \"organizationUrl\" : \"https://n143.meraki.com/o/123123/manage/organization/overview\",\n \"sentAt\" : 1.5361577879050448E9\n}\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 250, | |
"y": 920, | |
"wires": [ | |
[ | |
"22e49352.d824dc", | |
"17c1214e.eea4af" | |
] | |
] | |
}, | |
{ | |
"id": "b022029d.72915", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Filter Clients on Device Port", | |
"func": "var clients = msg.payload;\nvar alert = msg.alert.alertData;\n\nvar portClients = clients.filter(function(c){\n return c.switchport == alert.portNum\n});\n\nmsg.payload = portClients;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 500, | |
"y": 1000, | |
"wires": [ | |
[ | |
"753e2122.99f89", | |
"61b046ef.6dca48" | |
] | |
] | |
}, | |
{ | |
"id": "753e2122.99f89", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Clients on Port", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 1000, | |
"y": 1000, | |
"wires": [] | |
}, | |
{ | |
"id": "47a5f887.539bc8", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Check MAC", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"x": 1010, | |
"y": 1040, | |
"wires": [] | |
}, | |
{ | |
"id": "2ddbc1a5.ee5b7e", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Meraki API: Change Port Settings", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"x": 940, | |
"y": 1120, | |
"wires": [] | |
}, | |
{ | |
"id": "144ce508.4fefbb", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Test", | |
"topic": "", | |
"payload": "[{\"usage\":{\"sent\":0,\"recv\":282},\"id\":\"k0fc956\",\"description\":\"mr16-desk-00180a32cc34\",\"mdnsName\":null,\"dhcpHostname\":\"mr16-desk-00180a32cc34\",\"mac\":\"00:18:0a:32:aa:aa\",\"ip\":\"192.168.0.252\",\"vlan\":99,\"switchport\":\"7\"}]", | |
"payloadType": "json", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 250, | |
"y": 1080, | |
"wires": [ | |
[ | |
"61b046ef.6dca48" | |
] | |
] | |
}, | |
{ | |
"id": "8989b029.ed062", | |
"type": "switch", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Device Found?", | |
"property": "authorized", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "true" | |
} | |
], | |
"checkall": "true", | |
"repair": true, | |
"outputs": 1, | |
"x": 460, | |
"y": 1080, | |
"wires": [ | |
[ | |
"783ecf0a.bb9df" | |
] | |
] | |
}, | |
{ | |
"id": "95db5944.da8d48", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Sample - Switch Port Connected", | |
"func": "msg.payload = {\n \"alertData\" : {\n \"description\" : \"\",\n \"portDesc\" : \"Office / 3 Trunk port on VLAN 1\",\n \"portNum\" : 3,\n \"prevStatus\" : 0,\n \"status\" : 590355\n },\n \"alertId\" : \"643451796765250686\",\n \"alertType\" : \"Switch port connected\",\n \"deviceMac\" : \"00:11:22:33:aa:aa\",\n \"deviceName\" : \"Office\",\n \"deviceSerial\" : \"AAAA-BBBB-CCCC\",\n \"deviceUrl\" : \"https://n1.meraki.com/.../manage/nodes/new_list/...\",\n \"networkId\" : \"L_123456789123456789\",\n \"networkName\" : \"Network - 1\",\n \"networkUrl\" : \"https://n1.meraki.com/...\",\n \"occurredAt\" : 1535710029,\n \"organizationId\" : \"123456\",\n \"organizationName\" : \"Organization\",\n \"organizationUrl\" : \"https://n1.meraki.com/o/.../organization/overview\",\n \"sentAt\" : 1.5357100936038907E9\n}\n;\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 560, | |
"y": 160, | |
"wires": [ | |
[ | |
"6b096442.9fca2c" | |
] | |
] | |
}, | |
{ | |
"id": "920c5392.9951c", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "TEST - Switch Port Connected", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 190, | |
"y": 160, | |
"wires": [ | |
[ | |
"95db5944.da8d48" | |
] | |
] | |
}, | |
{ | |
"id": "140332d4.cd4e4d", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Sample - Settings Changed: Alerts for VPN", | |
"func": "msg.payload = {\n \"alertData\": {\n \"changes\": {\n \"vpnConnectivityChange\": {\n \"changedBy\": \"User ([email protected])\",\n \"label\": \"A VPN connection comes up or goes down\",\n \"newText\": \"{\\\"enabled\\\":false}\",\n \"oldText\": \"{\\\"enabled\\\":true}\"\n }\n },\n \"name\": \"Alerts\",\n \"url\": \"/manage/configure/alerts\",\n \"userId\": 500692\n },\n \"alertId\": \"643451796765252351\",\n \"alertType\": \"Settings changed\",\n \"networkId\": \"L_123456789123456789\",\n \"networkName\": \"Network - 1\",\n \"networkUrl\": \"https://n1.meraki.com/...\",\n \"occurredAt\": 1535729605.588459,\n \"organizationId\": \"123456\",\n \"organizationName\": \"Organization\",\n \"organizationUrl\": \"https://n143.meraki.com/o/.../organization/overview\",\n \"sentAt\": 1535730205.9500165,\n \"id\": 4\n};\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 590, | |
"y": 200, | |
"wires": [ | |
[ | |
"6b096442.9fca2c" | |
] | |
] | |
}, | |
{ | |
"id": "2b525e26.52b072", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "TEST - Settings Changed", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 170, | |
"y": 200, | |
"wires": [ | |
[ | |
"140332d4.cd4e4d" | |
] | |
] | |
}, | |
{ | |
"id": "5ce30475.68c43c", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "clean msg object", | |
"func": "// resets msg object to avoid extended flows from responding to HTTP request\n\nvar payload = msg.payload;\nmsg = {};\nmsg.payload = payload;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 550, | |
"y": 80, | |
"wires": [ | |
[ | |
"6b096442.9fca2c" | |
] | |
] | |
}, | |
{ | |
"id": "beae7f11.7f444", | |
"type": "firebase modify", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "", | |
"firebaseconfig": "", | |
"childpath": "msg.childpath", | |
"method": "remove", | |
"value": "msg.payload", | |
"priority": "msg.priority", | |
"x": 300, | |
"y": 2000, | |
"wires": [ | |
[ | |
"b1351557.a0d9a8" | |
] | |
] | |
}, | |
{ | |
"id": "bff8021d.be918", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "DELETE ALL DATABASE RECORDS", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 200, | |
"y": 1960, | |
"wires": [ | |
[ | |
"ae7531e9.9405b" | |
] | |
] | |
}, | |
{ | |
"id": "ae7531e9.9405b", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "msg.childpath = \"/alerts/\";", | |
"func": "msg.childpath = \"/alerts/\";\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 480, | |
"y": 1960, | |
"wires": [ | |
[ | |
"beae7f11.7f444" | |
] | |
] | |
}, | |
{ | |
"id": "b1351557.a0d9a8", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Database data DELETE", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 700, | |
"y": 2000, | |
"wires": [] | |
}, | |
{ | |
"id": "3f8b9d2e.2a9062", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Sample - VPN connectivity changed", | |
"func": "msg.payload = {\n \"alertData\": {\n \"connectivity\": \"true\",\n \"peerContact\": \"34.251.167.98:39105\",\n \"peerIdent\": \"9233acc6d2a2f38172c6b49bb14b4071\",\n \"vpnType\": \"site-to-site\"\n },\n \"alertId\": \"643451796765320915\",\n \"alertType\": \"VPN connectivity changed\",\n \"deviceMac\": \"00:11:22:33:44:55\",\n \"deviceName\": \"MX65 – 1\",\n \"deviceSerial\": \"AAAA-BBBB-CCCC\",\n \"deviceUrl\": \"https://n1.meraki.com/.../manage/nodes/new_wired_status\",\n \"networkId\": \"L_123456789123456789\",\n \"networkName\": \"Network - 1\",\n \"networkUrl\": \"https://n1.meraki.com/...\",\n \"occurredAt\": 1536915561.607,\n \"organizationId\": \"123456\",\n \"organizationName\": \"Organization\",\n \"organizationUrl\": \"https://n1.meraki.com/o/.../organization/overview\",\n \"sentAt\": 1536915613.3600955,\n \"id\": 3\n};\n\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 570, | |
"y": 240, | |
"wires": [ | |
[ | |
"6b096442.9fca2c" | |
] | |
] | |
}, | |
{ | |
"id": "3ea35a3a.12a876", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "TEST - VPN connectivity changed", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 200, | |
"y": 240, | |
"wires": [ | |
[ | |
"3f8b9d2e.2a9062" | |
] | |
] | |
}, | |
{ | |
"id": "4f500752.fd06c8", | |
"type": "http request", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Photon2", | |
"method": "POST", | |
"ret": "obj", | |
"url": "https://api.particle.io/v1/devices/1f0025001947343438323536/led?access_token=", | |
"tls": "", | |
"x": 400, | |
"y": 1300, | |
"wires": [ | |
[ | |
"2d611c5d.da3094" | |
] | |
] | |
}, | |
{ | |
"id": "796a5378.f0a7bc", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "On", | |
"topic": "", | |
"payload": "", | |
"payloadType": "str", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 110, | |
"y": 1300, | |
"wires": [ | |
[ | |
"dfcd85ac.88c828" | |
] | |
] | |
}, | |
{ | |
"id": "f4482212.c1133", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Off", | |
"topic": "", | |
"payload": "", | |
"payloadType": "str", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 110, | |
"y": 1340, | |
"wires": [ | |
[ | |
"965ce4ac.623df8" | |
] | |
] | |
}, | |
{ | |
"id": "2d611c5d.da3094", | |
"type": "debug", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "photon response", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"x": 570, | |
"y": 1300, | |
"wires": [] | |
}, | |
{ | |
"id": "dfcd85ac.88c828", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "on", | |
"func": "msg.payload = {\"arg\":\"on\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 230, | |
"y": 1300, | |
"wires": [ | |
[ | |
"4f500752.fd06c8" | |
] | |
] | |
}, | |
{ | |
"id": "965ce4ac.623df8", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "off", | |
"func": "msg.payload = {\"arg\":\"off\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 230, | |
"y": 1340, | |
"wires": [ | |
[ | |
"4f500752.fd06c8" | |
] | |
] | |
}, | |
{ | |
"id": "12ed1b4a.d8fbd5", | |
"type": "link in", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Photon", | |
"links": [ | |
"3cc0f382.9d3ddc" | |
], | |
"x": 75, | |
"y": 1220, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "5623bcba.84c0d4", | |
"type": "comment", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "IoT Alarm - Particle Photon with LED and Buzzer", | |
"info": "", | |
"x": 200, | |
"y": 1180, | |
"wires": [] | |
}, | |
{ | |
"id": "b2b0b95.6351948", | |
"type": "inject", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Trigger", | |
"topic": "", | |
"payload": "", | |
"payloadType": "str", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 110, | |
"y": 1260, | |
"wires": [ | |
[ | |
"9975d456.328f28" | |
] | |
] | |
}, | |
{ | |
"id": "9975d456.328f28", | |
"type": "function", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "trigger", | |
"func": "msg.payload = {\"arg\":\"trigger\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 230, | |
"y": 1260, | |
"wires": [ | |
[ | |
"4f500752.fd06c8" | |
] | |
] | |
}, | |
{ | |
"id": "6a49cfba.76cf3", | |
"type": "switch", | |
"z": "6b02c4a0.a0d1ac", | |
"name": "Trigger on Motion detected", | |
"property": "payload.alertType", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "eq", | |
"v": "Motion detected", | |
"vt": "str" | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 1, | |
"x": 300, | |
"y": 1220, | |
"wires": [ | |
[ | |
"9975d456.328f28" | |
] | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment