UNPKG

node-red-subflow-axis-provisioning

Version:
1,844 lines (1,843 loc) 156 kB
{ "id": "6d42dc07fde7a1cc", "type": "subflow", "name": "Provision Axis Devices", "info": "", "category": "", "in": [ { "x": 60, "y": 60, "wires": [ { "id": "0d89bccafa5fc67a" } ] } ], "out": [ { "x": 580, "y": 60, "wires": [ { "id": "ab0de88705f5928e", "port": 0 } ] }, { "x": 580, "y": 120, "wires": [ { "id": "e99455cc43f63f88", "port": 0 } ] }, { "x": 580, "y": 180, "wires": [ { "id": "1288c92df25e4db9", "port": 0 }, { "id": "a078b3a81d2fdcda", "port": 0 } ] } ], "env": [], "meta": {}, "category": "Axis", "color": "#FFCC33", "icon": "font-awesome/fa-gears", "flow": [ { "id": "ab0de88705f5928e", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Status", "links": [ "5e8692de0f04745a", "86dea86e82867012", "806a20e46c8be199", "60d9101a39b4e980", "57496831298e1a7d", "161b25e016f50fa3", "886c0134bc92f6bf", "21d4834648058d9e", "a328953bf81d973e", "c0e63e2b0e8caac6", "071c52e45c343d11", "5994b5fc8ca27421", "9e58ee7279b9d333", "2f2ed863cefd4060", "7972e64eb0ed4c3f", "52df476c353f8a8f", "0728568abda0a7ac" ], "x": 265, "y": 60, "wires": [ [] ] }, { "id": "fddb3534c2517406", "type": "comment", "z": "6d42dc07fde7a1cc", "name": "Status", "info": "", "x": 370, "y": 60, "wires": [] }, { "id": "1288c92df25e4db9", "type": "catch", "z": "6d42dc07fde7a1cc", "name": "", "scope": null, "uncaught": true, "x": 400, "y": 220, "wires": [ [] ] }, { "id": "ac6949d903ee205c", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Complete", "links": [ "287cb6ace8dd5738", "932db199393f0a2d" ], "x": 265, "y": 120, "wires": [ [ "e99455cc43f63f88" ] ] }, { "id": "e99455cc43f63f88", "type": "function", "z": "6d42dc07fde7a1cc", "name": "Complete", "func": "msg.topic = \"complete\";\nmsg.payload = msg.device.serial + \": Complete\";\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 380, "y": 120, "wires": [ [] ] }, { "id": "a078b3a81d2fdcda", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Error", "links": [ "513453f276e3a282", "a046d81f10eda1c3", "a1132cb83f9eb7b6", "b316b11b63286616", "60a1051c99471b64", "2f92d0e0f42d8935", "0a770118f48df09e", "5814c39c90c89a88", "b285ad40911ab7da", "004dce845d45232d", "16b4a91457d2045e", "d09d6605ad808f1f", "c633865739c6a14a", "58f5540be0ce9b09", "360f1c59d0d2a83b", "1c5d0374e6c83aba", "a334af77b4380ea2", "3ef024f5d8a5f052", "04c98396adc5499d" ], "x": 265, "y": 180, "wires": [ [] ] }, { "id": "65b64f2e59d37cef", "type": "comment", "z": "6d42dc07fde7a1cc", "name": "Error", "info": "", "x": 370, "y": 180, "wires": [] }, { "id": "e437846c69820d56", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "Device", "mode": "link", "links": [ "8db313cfcad2d6aa" ], "x": 1325, "y": 540, "wires": [] }, { "id": "2694ca95763e24a2", "type": "comment", "z": "6d42dc07fde7a1cc", "name": "For Each Device", "info": "", "x": 1200, "y": 540, "wires": [] }, { "id": "c1471f737727d07a", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Set Name", "links": [ "c7996c7136a87da7" ], "x": 175, "y": 1060, "wires": [ [ "131edbc69bf7b518" ] ] }, { "id": "b804be045840899a", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 85", "mode": "link", "links": [ "191e5e0998507551" ], "x": 785, "y": 1140, "wires": [] }, { "id": "8db313cfcad2d6aa", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Add accounts", "links": [ "e437846c69820d56" ], "x": 165, "y": 760, "wires": [ [ "3c0225d0216bb766" ] ] }, { "id": "c7996c7136a87da7", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 76", "mode": "link", "links": [ "c1471f737727d07a" ], "x": 1235, "y": 880, "wires": [] }, { "id": "8bc568d811a27608", "type": "function", "z": "6d42dc07fde7a1cc", "name": "Status", "func": "msg.payload = msg.device.serial + \": Account \" + msg.config.accounts[0].name + \" set\";\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 720, "y": 760, "wires": [ [ "acbd4d1e2563f3b4" ] ] }, { "id": "86dea86e82867012", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 90", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 785, "y": 1060, "wires": [] }, { "id": "5e8692de0f04745a", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 89", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1235, "y": 760, "wires": [] }, { "id": "b316b11b63286616", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 122", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1235, "y": 840, "wires": [] }, { "id": "60a1051c99471b64", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 123", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 785, "y": 1100, "wires": [] }, { "id": "c9c7c7b318d48036", "type": "function", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "For Each Cameras", "func": "msg.inventory.forEach(function(device){\n msg.address = device.address;\n msg.properties = device.properties || null;\n node.send(msg);\n});\n", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 570, "y": 420, "wires": [ [ "91a3709e3a1593af" ] ] }, { "id": "91a3709e3a1593af", "type": "function", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "Main Account", "func": "if (!msg.config.hasOwnProperty(\"accounts\") || !msg.config.accounts || !Array.isArray(msg.config.accounts)) {\n node.error(\"Invalid accounts in config config\", msg);\n return;\n}\n\nif( msg.config.accounts.length === 0 ) {\n node.error(\"No accounts defined\", msg);\n return;\n}\n\nif (!msg.config.accounts[0].hasOwnProperty(\"name\") || msg.config.accounts[0].name.length < 2) {\n node.error(\"Invalid account name\", msg);\n return;\n}\n\nif (!msg.config.accounts[0].hasOwnProperty(\"password\") || msg.config.accounts[0].password.length < 5) {\n node.error(\"Invalid account password\", msg);\n return;\n}\n\nmsg.user = msg.config.accounts[0].name;\nmsg.password = msg.config.accounts[0].password;\n\nmsg.payload = {\n \"name\": msg.user,\n \"password\": msg.password,\n \"privileges\": \"Admin\"\n}\n\nreturn msg;", "outputs": 1, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 800, "y": 420, "wires": [ [ "ea562c7b8a1f4275" ] ] }, { "id": "ea562c7b8a1f4275", "type": "Axis Security", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "", "preset": "1af13a1540441ff9", "address": "", "action": "Set account", "data": "", "options": "", "x": 1010, "y": 420, "wires": [ [ "affed36236d1f218" ] ] }, { "id": "affed36236d1f218", "type": "Axis device", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "", "preset": "1af13a1540441ff9", "action": "Device Info", "cgi": "", "data": "", "options": "", "filename": "", "x": 350, "y": 480, "wires": [ [ "769ff43a69fc38a7" ] ] }, { "id": "769ff43a69fc38a7", "type": "change", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "msg.device", "rules": [ { "t": "set", "p": "device", "pt": "msg", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 570, "y": 480, "wires": [ [ "e76f222c6b9b1ea4" ] ] }, { "id": "80f1193e220c911b", "type": "comment", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "Run staging", "info": "", "x": 320, "y": 360, "wires": [] }, { "id": "e76f222c6b9b1ea4", "type": "Axis camera", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "", "preset": "1af13a1540441ff9", "action": "Camera Info", "resolution": "640x360", "output": "Base64", "filename": "", "options": "", "data": "", "x": 350, "y": 540, "wires": [ [ "13caf90fc2de50a9" ] ] }, { "id": "13caf90fc2de50a9", "type": "change", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "msg.camera", "rules": [ { "t": "set", "p": "camera", "pt": "msg", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 570, "y": 540, "wires": [ [ "d836cad2f50a5457" ] ] }, { "id": "9f513e6861088740", "type": "catch", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "", "scope": [ "e76f222c6b9b1ea4" ], "uncaught": false, "x": 340, "y": 580, "wires": [ [ "c2d84c7da4c38380" ] ] }, { "id": "c2d84c7da4c38380", "type": "change", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "msg.camera", "rules": [ { "t": "set", "p": "camera", "pt": "msg", "to": "null", "tot": "json" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 570, "y": 580, "wires": [ [ "d836cad2f50a5457" ] ] }, { "id": "2169731c96098748", "type": "function", "z": "6d42dc07fde7a1cc", "g": "9dfd156e1950cc7f", "name": "Validate", "func": "if(!msg.config || typeof msg.config !== \"object\"){\n node.error(\"Config undefined\", msg);\n return;\n}\n\nif(!msg.inventory || !Array.isArray(msg.inventory) || msg.inventory.length === 0){\n node.error(\"Inventory undefined\", msg);\n return;\n}\n\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 340, "y": 420, "wires": [ [ "c9c7c7b318d48036" ] ] }, { "id": "d1ab771eab9eb53f", "type": "Axis device", "z": "6d42dc07fde7a1cc", "g": "c9792688d8d9aa19", "name": "", "preset": "1af13a1540441ff9", "action": "Set name", "cgi": "", "data": "", "options": "", "filename": "", "x": 480, "y": 1060, "wires": [ [ "50dedcee8b98d13d", "63dfe84fecef5567" ] ] }, { "id": "926d536c882b9c39", "type": "comment", "z": "6d42dc07fde7a1cc", "g": "c9792688d8d9aa19", "name": "Set name for host, PnP and Bonjour", "info": "", "x": 380, "y": 1000, "wires": [] }, { "id": "63dfe84fecef5567", "type": "function", "z": "6d42dc07fde7a1cc", "g": "c9792688d8d9aa19", "name": "Status", "func": "msg.payload = msg.device.serial + \": Name set to \" + msg.properties.name;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 670, "y": 1060, "wires": [ [ "86dea86e82867012" ] ] }, { "id": "131edbc69bf7b518", "type": "function", "z": "6d42dc07fde7a1cc", "g": "c9792688d8d9aa19", "name": "Name", "func": "if( !msg.hasOwnProperty(\"properties\") || !msg.properties ) {\n node.send([null,msg]);\n return;\n}\n\nif( !msg.properties.hasOwnProperty(\"name\") || !msg.properties.name || typeof msg.properties.name !== \"string\" || msg.properties.name.length < 2 ) {\n node.send([null,msg]);\n return;\n}\n\nmsg.payload = msg.properties.name;\nnode.send([msg],null);\n", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 290, "y": 1060, "wires": [ [ "d1ab771eab9eb53f" ], [ "e5ee3b4d153d64d5" ] ] }, { "id": "d6164839df4a17f5", "type": "catch", "z": "6d42dc07fde7a1cc", "g": "c9792688d8d9aa19", "name": "", "scope": [ "d1ab771eab9eb53f" ], "uncaught": false, "x": 480, "y": 1100, "wires": [ [ "60a1051c99471b64", "50dedcee8b98d13d" ] ] }, { "id": "3c0225d0216bb766", "type": "function", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "2:nd Account", "func": "if( msg.config.accounts.length < 2 ) {\n node.send([null,msg]);\n return;\n}\n\nif( !msg.config.accounts[1].hasOwnProperty(\"name\") || !msg.config.accounts[1].name || msg.config.accounts[1].name.length < 2 ) {\n node.send([null,msg]);\n return;\n}\n\nif( !msg.config.accounts[1].hasOwnProperty(\"password\") || !msg.config.accounts[1].password || msg.config.accounts[1].password.length < 2 ) {\n node.send([null,msg]);\n return;\n}\n\n\nmsg.payload = {\n name: msg.config.accounts[1].name,\n password: msg.config.accounts[1].password,\n privileges: msg.config.accounts[1].privileges\n}\nnode.send([msg,null]);", "outputs": 2, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 310, "y": 760, "wires": [ [ "2edb98203af01703" ], [ "89dc8d2d67998f73" ] ] }, { "id": "2edb98203af01703", "type": "Axis Security", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "", "preset": "1af13a1540441ff9", "address": "", "action": "Set account", "data": "", "options": "", "x": 550, "y": 760, "wires": [ [ "4ea6ebd542b86370", "8bc568d811a27608" ] ] }, { "id": "4ea6ebd542b86370", "type": "function", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "3:nd Account", "func": "if( msg.config.accounts.length < 3 ) {\n node.send([null,msg]);\n return;\n}\n\nif( !msg.config.accounts[2].hasOwnProperty(\"name\") || !msg.config.accounts[2].name || msg.config.accounts[2].name.length < 2 ) {\n node.send([null,msg]);\n return;\n}\n\nif( !msg.config.accounts[2].hasOwnProperty(\"password\") || !msg.config.accounts[2].password || msg.config.accounts[2].password.length < 2 ) {\n node.send([null,msg]);\n return;\n}\n\nmsg.payload = {\n name: msg.config.accounts[2].name,\n password: msg.config.accounts[2].password,\n privileges: msg.config.accounts[2].privileges\n}\nnode.send([msg,null]);", "outputs": 2, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 710, "y": 800, "wires": [ [ "eb200af9820293b5" ], [ "288d0df563040762" ] ] }, { "id": "eb200af9820293b5", "type": "Axis Security", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "", "preset": "1af13a1540441ff9", "address": "", "action": "Set account", "data": "", "options": "", "x": 910, "y": 800, "wires": [ [ "f759fcf09dcac666", "53f828d169db79fb" ] ] }, { "id": "be8ea6786bdd3d39", "type": "comment", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "Add additional accounts", "info": "", "x": 340, "y": 700, "wires": [] }, { "id": "53f828d169db79fb", "type": "function", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "Status", "func": "msg.payload = msg.device.serial + \": Account \" + msg.config.accounts[1].name + \" set\";\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1090, "y": 800, "wires": [ [ "acbd4d1e2563f3b4" ] ] }, { "id": "5f694fba9c51a72a", "type": "catch", "z": "6d42dc07fde7a1cc", "g": "5ef259fcb1cdf8e3", "name": "", "scope": [ "2edb98203af01703", "eb200af9820293b5" ], "uncaught": false, "x": 910, "y": 840, "wires": [ [ "b316b11b63286616", "f759fcf09dcac666" ] ] }, { "id": "f661fdf2bf34b1c5", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "SSH", "links": [ "1ad70f1f83167917" ], "x": 175, "y": 3880, "wires": [ [ "679feabbdc4c2c75" ] ] }, { "id": "8d03416383ccd583", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 77", "mode": "link", "links": [ "af454b1b04a6b644" ], "x": 1365, "y": 3960, "wires": [] }, { "id": "3d534640c60e6a85", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "MQTT", "links": [ "5432395a324f6d6b" ], "x": 175, "y": 3460, "wires": [ [ "b475f62b037384e9" ] ] }, { "id": "1ad70f1f83167917", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 78", "mode": "link", "links": [ "f661fdf2bf34b1c5" ], "x": 2165, "y": 3720, "wires": [] }, { "id": "af454b1b04a6b644", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "ACAPS", "links": [ "8d03416383ccd583" ], "x": 175, "y": 4120, "wires": [ [ "cf069fc7b849fdde" ] ] }, { "id": "2f2ed863cefd4060", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 79", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 2065, "y": 4200, "wires": [] }, { "id": "d007bf03b471e4c1", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "TLS", "links": [ "38174e52c149c06d" ], "x": 165, "y": 2080, "wires": [ [ "663a2017c1b1b044" ] ] }, { "id": "e484f5dc92c5eba1", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 80", "mode": "link", "links": [ "727f7885b185355b" ], "x": 1745, "y": 2160, "wires": [] }, { "id": "b62b17d9f455d06a", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Text Overlays", "links": [ "b64a17ac0e500ddc" ], "x": 165, "y": 2940, "wires": [ [ "e08e1844c2ca78fb" ] ] }, { "id": "c7680999c23267ca", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 81", "mode": "link", "links": [ "ba200e8e2941c6d9" ], "x": 1705, "y": 3060, "wires": [] }, { "id": "727f7885b185355b", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "ONVIF", "links": [ "e484f5dc92c5eba1" ], "x": 165, "y": 2340, "wires": [ [ "1589857e7040c711" ] ] }, { "id": "1f48ecb7127e748a", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 82", "mode": "link", "links": [ "b739739b90136125" ], "x": 2305, "y": 2520, "wires": [] }, { "id": "b739739b90136125", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Remove overlays", "links": [ "1f48ecb7127e748a" ], "x": 165, "y": 2700, "wires": [ [ "3dd31cedf03be8b6" ] ] }, { "id": "b64a17ac0e500ddc", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 83", "mode": "link", "links": [ "b62b17d9f455d06a" ], "x": 2255, "y": 2780, "wires": [] }, { "id": "ba200e8e2941c6d9", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Image Overlays", "links": [ "c7680999c23267ca" ], "x": 165, "y": 3220, "wires": [ [ "d6aea0ddd6f87fd4" ] ] }, { "id": "5432395a324f6d6b", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 84", "mode": "link", "links": [ "3d534640c60e6a85" ], "x": 1415, "y": 3300, "wires": [] }, { "id": "191e5e0998507551", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Timezone", "links": [ "b804be045840899a" ], "x": 175, "y": 1300, "wires": [ [ "aefd78b4397260fe" ] ] }, { "id": "47ae6c3fec806929", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 86", "mode": "link", "links": [ "4fa416059885f4ac" ], "x": 815, "y": 1380, "wires": [] }, { "id": "c629be351ef2984f", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "Zipstream", "links": [ "edeb2af62b5c8894" ], "x": 165, "y": 1780, "wires": [ [ "d756c942f3c2f3fe" ] ] }, { "id": "38174e52c149c06d", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 87", "mode": "link", "links": [ "d007bf03b471e4c1" ], "x": 1935, "y": 1920, "wires": [] }, { "id": "57496831298e1a7d", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 93", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1745, "y": 2080, "wires": [] }, { "id": "161b25e016f50fa3", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 94", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 2295, "y": 2340, "wires": [] }, { "id": "21d4834648058d9e", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 95", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1705, "y": 2940, "wires": [] }, { "id": "a328953bf81d973e", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 96", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1415, "y": 3220, "wires": [] }, { "id": "c0e63e2b0e8caac6", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 97", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 2165, "y": 3460, "wires": [] }, { "id": "071c52e45c343d11", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 98", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1365, "y": 3880, "wires": [] }, { "id": "60d9101a39b4e980", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 92", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1935, "y": 1780, "wires": [] }, { "id": "806a20e46c8be199", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 91", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 815, "y": 1300, "wires": [] }, { "id": "c503f405e50a5c52", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 108", "mode": "link", "links": [ "259734a2ea35c73b", "2ff71a0ff5e4e9a2" ], "x": 2065, "y": 4320, "wires": [] }, { "id": "52df476c353f8a8f", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 109", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1455, "y": 4940, "wires": [] }, { "id": "4bb73f307d5961f6", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "link in 32", "links": [ "cc693c5fc7a2061e", "23959cbded70f3a9" ], "x": 155, "y": 4940, "wires": [ [ "8948ca6d5679cc07" ] ] }, { "id": "932db199393f0a2d", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 110", "mode": "link", "links": [ "ac6949d903ee205c" ], "x": 1455, "y": 5040, "wires": [] }, { "id": "7d77a0375c134bc3", "type": "comment", "z": "6d42dc07fde7a1cc", "name": "When Adding more configurations, add them below this comment before potentially device changes to fixed IP", "info": "", "x": 620, "y": 4800, "wires": [] }, { "id": "2ff71a0ff5e4e9a2", "type": "link in", "z": "6d42dc07fde7a1cc", "name": "ACAPS", "links": [ "c503f405e50a5c52" ], "x": 175, "y": 4500, "wires": [ [ "4f2f75bda542e219" ] ] }, { "id": "23959cbded70f3a9", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 114", "mode": "link", "links": [ "4bb73f307d5961f6" ], "x": 1365, "y": 4640, "wires": [] }, { "id": "5994b5fc8ca27421", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 115", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1365, "y": 4440, "wires": [] }, { "id": "58f5540be0ce9b09", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 116", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1365, "y": 4480, "wires": [] }, { "id": "360f1c59d0d2a83b", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 117", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1365, "y": 4560, "wires": [] }, { "id": "9e58ee7279b9d333", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 118", "mode": "link", "links": [ "ab0de88705f5928e" ], "x": 1365, "y": 4520, "wires": [] }, { "id": "c633865739c6a14a", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 119", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1365, "y": 3920, "wires": [] }, { "id": "d09d6605ad808f1f", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 120", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 2165, "y": 3500, "wires": [] }, { "id": "2f92d0e0f42d8935", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 124", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 815, "y": 1340, "wires": [] }, { "id": "0a770118f48df09e", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 125", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1935, "y": 1880, "wires": [] }, { "id": "5814c39c90c89a88", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 126", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1745, "y": 2120, "wires": [] }, { "id": "b285ad40911ab7da", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 127", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 2255, "y": 2740, "wires": [] }, { "id": "004dce845d45232d", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 128", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1705, "y": 3020, "wires": [] }, { "id": "16b4a91457d2045e", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 129", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1415, "y": 3260, "wires": [] }, { "id": "1c5d0374e6c83aba", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 130", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 2065, "y": 4240, "wires": [] }, { "id": "3ef024f5d8a5f052", "type": "link out", "z": "6d42dc07fde7a1cc", "name": "link out 132", "mode": "link", "links": [ "a078b3a81d2fdcda" ], "x": 1455, "y": 5000, "wires": [] }, { "id": "8a98c5949d648bbd", "type": "Axis Security", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "", "preset": "1af13a1540441ff9", "address": "", "action": "Allow SSH", "data": "", "options": "", "x": 490, "y": 3880, "wires": [ [ "8099cb431deb2f71" ] ] }, { "id": "f1258ee2314fd616", "type": "Axis Security", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "", "preset": "1af13a1540441ff9", "address": "", "action": "Set SSH User", "data": "", "options": "", "x": 880, "y": 3880, "wires": [ [ "c317139745f68a20", "5f4c58bb85964adb" ] ] }, { "id": "5101afc97ee05028", "type": "comment", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "Enable SSH", "info": "", "x": 310, "y": 3820, "wires": [] }, { "id": "679feabbdc4c2c75", "type": "function", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "SSH", "func": "if( !msg.config.hasOwnProperty(\"ssh\") ) {\n node.send([null,msg]);\n return;\n}\n\nif( msg.config.ssh === false || msg.config.ssh === null )\n msg.payload = false;\nelse \n msg.payload = true;\nnode.send([msg,null]);\n", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 290, "y": 3880, "wires": [ [ "8a98c5949d648bbd" ], [ "ac87f5fc9f5922f3" ] ] }, { "id": "5f4c58bb85964adb", "type": "function", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "Status", "func": "msg.payload = msg.device.serial + \": SSH user \" + msg.config.ssh.user;\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1230, "y": 3880, "wires": [ [ "071c52e45c343d11" ] ] }, { "id": "8099cb431deb2f71", "type": "function", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "user", "func": "if( !msg.config.ssh.hasOwnProperty(\"user\") || msg.config.ssh.user.length < 3 ) {\n node.send([null,msg]);\n return;\n}\n\nif( !msg.config.ssh.hasOwnProperty(\"password\") || msg.config.ssh.password.length < 3 ) {\n node.send([null,msg]);\n return;\n}\n\nmsg.payload = {\n name: msg.config.ssh.user,\n password: msg.config.ssh.password\n}\nnode.send([msg,null]);\n", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 3880, "wires": [ [ "f1258ee2314fd616" ], [ "73595c38012c7322" ] ] }, { "id": "0b2c3e8b5e4be2ab", "type": "catch", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "", "scope": [ "f1258ee2314fd616" ], "uncaught": false, "x": 860, "y": 3920, "wires": [ [ "79472532c41693b0" ] ] }, { "id": "fea7d448d4978f7d", "type": "catch", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "", "scope": [ "8a98c5949d648bbd" ], "uncaught": false, "x": 480, "y": 3920, "wires": [ [ "73595c38012c7322" ] ] }, { "id": "79472532c41693b0", "type": "switch", "z": "6d42dc07fde7a1cc", "g": "0547b0a6bfac8451", "name": "!409", "property": "payload.statusCode", "propertyType": "msg", "rules": [ { "t": "eq", "v": "409", "vt": "num" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 1070, "y": 3920, "wires": [ [ "261fe59b90fc81fa", "5f4c58bb85964adb" ], [ "261fe59b90fc81fa", "c633865739c6a14a" ] ] }, { "id": "b7939f8c31487dc5", "type": "template", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "MQTT Config", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\n \"apiVersion\":\"1.5\",\n \"method\":\"configureClient\",\n \"params\":{\n \"autoReconnect\":true,\n \"cleanSession\":true,\n \"clientId\": \"{{device.serial}}\",\n \"connectTimeout\":60,\n \"deviceTopicPrefix\":\"axis\",\n \"id\":\"MqttClientConfig\",\n \"keepAliveInterval\":60,\n \"server\":{\n \"host\": \"{{config.mqtt.address}}\",\n \"id\":\"MqttClientServer\",\n \"port\":1883,\n \"protocol\":\"tcp\"\n },\n \"username\": \"{{config.mqtt.user}}\",\n \"password\": \"{{config.mqtt.password}}\",\n \"keepExistingPassword\":false\n }\n}\n\n", "output": "str", "x": 540, "y": 3460, "wires": [ [ "c69b1dd211251243" ] ], "info": "https://www.axis.com/vapix-library/subjects/t10175981/section/t10152603/display?section=t10152603-t10152921\r\n\r\n{\r\n \"apiVersion\": \"<Major>.<Minor>\",\r\n \"context\": <string>,\r\n \"method\": \"configureClient\",\r\n \"params\": {\r\n\r\n \"server\": {\r\n \"protocol\": <string>,\r\n \"host\": <string>,\r\n \"port\": <integer>,\r\n \"basepath\": <string>,\r\n \"alpnProtocol\": <string>\r\n },\r\n\r\n \"httpProxy\": <string>,\r\n \"httpsProxy\": <string>,\r\n \"username\": <string>,\r\n \"password\": <string>,\r\n \"keepExistingPassword\": <boolean>\r\n \"clientId\": <string>,\r\n \"keepAliveInterval\": <int>,\r\n \"connectTimeout\": <int>,\r\n \"cleanSession\": <boolean>,\r\n \"autoReconnect\": <boolean>,\r\n \"deviceTopicPrefix\": <string>,\r\n\r\n \"lastWillTestament\": {\r\n \"useDefault\": <boolean>,\r\n \"topic\": <string>,\r\n \"message\": <string>,\r\n \"retain\": <boolean>,\r\n \"qos\": <int>\r\n },\r\n\r\n \"connectMessage\": {\r\n \"useDefault\": <boolean>,\r\n \"topic\": <string>,\r\n \"message\": <string>,\r\n \"retain\": <boolean>,\r\n \"qos\": <int>\r\n },\r\n\r\n \"disconnectMessage\": {\r\n \"useDefault\": <boolean>,\r\n \"topic\": <string>,\r\n \"message\": <string>,\r\n \"retain\": <boolean>,\r\n \"qos\": <int>\r\n },\r\n \"ssl\": {\r\n \"validateServerCert\": <boolean>,\r\n \"clientCertID\": <string>,\r\n \"CACertID\": <string>\r\n }\r\n }\r\n}\r\n" }, { "id": "c9c75d5877ea8b51", "type": "template", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "Start MQTT", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "{\n \"apiVersion\":\"1.5\",\n \"method\":\"activateClient\"\n}", "output": "str", "x": 990, "y": 3540, "wires": [ [ "8df9b212caea4e6d" ] ] }, { "id": "c69b1dd211251243", "type": "Axis device", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "/axis-cgi/mqtt/client.cgi", "preset": "1af13a1540441ff9", "action": "HTTP Post", "cgi": "/axis-cgi/mqtt/client.cgi", "data": "", "options": "", "filename": "", "x": 770, "y": 3460, "wires": [ [ "c9c75d5877ea8b51", "50b088fc6c0639b8" ] ] }, { "id": "8df9b212caea4e6d", "type": "Axis device", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "/axis-cgi/mqtt/client.cgi", "preset": "1af13a1540441ff9", "action": "HTTP Post", "cgi": "/axis-cgi/mqtt/client.cgi", "data": "", "options": "", "filename": "", "x": 1210, "y": 3540, "wires": [ [ "402bdd2f0b0a4293", "a0b9ca89a432c8b4" ] ] }, { "id": "efb36d54d284127c", "type": "comment", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "MQTT Client setup", "info": "", "x": 330, "y": 3400, "wires": [] }, { "id": "b475f62b037384e9", "type": "function", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "Set MQTT Client", "func": "if (!msg.config.hasOwnProperty(\"mqtt\") || !msg.config.mqtt || typeof msg.config.mqtt !== \"object\" ) {\n node.send([null, msg]);\n return;\n}\n\nif (!msg.config.mqtt.hasOwnProperty(\"address\") || msg.config.mqtt.address.length < 5) {\n node.send([null, msg]);\n return;\n}\n\nif (!msg.config.mqtt.hasOwnProperty(\"port\") )\n msg.config.mqtt.port = \"1880\";\n\nif (!msg.config.mqtt.hasOwnProperty(\"user\"))\n msg.config.mqtt.user = \"\";\n\nif (!msg.config.mqtt.hasOwnProperty(\"password\"))\n msg.config.mqtt.pasword = \"\";\n\nnode.send([msg,null]);", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 330, "y": 3460, "wires": [ [ "b7939f8c31487dc5" ], [ "30754429244e62df" ] ] }, { "id": "402bdd2f0b0a4293", "type": "function", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "Publish", "func": "if (!msg.config.mqtt.hasOwnProperty(\"publish\") || !Array.isArray(msg.config.mqtt.publish) || msg.config.mqtt.publish.length === 0 ) {\n node.send([null,msg]);\n return;\n}\n\nmsg.payload = {\n apiVersion: \"1.2\",\n method: \"configureEventPublication\",\n params: {\n appendEventTopic: true,\n customTopicPrefix: \"event\",\n eventFilterList: msg.config.mqtt.publish,\n includeSerialNumberInPayload: true,\n includeTopicNamespaces: false,\n topicPrefix: \"custom\"\n }\n}\nnode.send([msg,null]);", "outputs": 2, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1460, "y": 3620, "wires": [ [ "bc56cb551d4fa6a5" ], [ "a65438f413dc22b1" ] ] }, { "id": "bc56cb551d4fa6a5", "type": "Axis device", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6", "name": "/axis-cgi/mqtt/event.cgi", "preset": "1af13a1540441ff9", "action": "HTTP Post", "cgi": "/axis-cgi/mqtt/event.cgi", "data": "", "options": "", "filename": "", "x": 1690, "y": 3620, "wires": [ [ "f87da7beee206827", "f8de5588d6daa74f" ] ] }, { "id": "f8de5588d6daa74f", "type": "function", "z": "6d42dc07fde7a1cc", "g": "24c142e5479761b6",