-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmist_downgrader.json
More file actions
1 lines (1 loc) · 8.13 KB
/
mist_downgrader.json
File metadata and controls
1 lines (1 loc) · 8.13 KB
1
[{"id":"6e92f1fb.cff84","type":"tab","label":"Mist Webhook Handler","disabled":false,"info":""},{"id":"13d7f886.b3ab07","type":"subflow","name":"Upgrade AP","info":"","category":"","in":[{"x":20,"y":80,"wires":[{"id":"5286d3a8.acca6c"}]}],"out":[{"x":820,"y":200,"wires":[{"id":"6f951637.011e4","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"fbeaba9d.3c9028","type":"subflow","name":"","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"145e2c8b.8fe913"}]}],"out":[{"x":840,"y":580,"wires":[{"id":"e5a98f18.7948a","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"5286d3a8.acca6c","type":"switch","z":"13d7f886.b3ab07","name":"Check if Downgrade is needed","property":"downgrade","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":80,"wires":[["65fe73cc.c8236c"],[]]},{"id":"65fe73cc.c8236c","type":"template","z":"13d7f886.b3ab07","name":"Build Upgrade Payload","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n\"version\": \"{{downgrade}}\"\n}","output":"json","x":520,"y":80,"wires":[["a35650bf.64263"]]},{"id":"6f951637.011e4","type":"http request","z":"13d7f886.b3ab07","name":"Upgrade AP","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/sites/{{site_id}}/devices/{{device_id}}/upgrade","tls":"","persist":false,"proxy":"","authType":"","x":630,"y":400,"wires":[[]]},{"id":"a6dba0e5.418a4","type":"http in","z":"6e92f1fb.cff84","name":"Mist Webhook","url":"/mist","method":"post","upload":false,"swaggerDoc":"","x":70,"y":160,"wires":[["c5efb7b2.2b745","b8934b8e.01d688"]]},{"id":"1ca83b03.dd24fd","type":"http response","z":"6e92f1fb.cff84","name":"Webhook Response","statusCode":"","headers":{},"x":260,"y":320,"wires":[]},{"id":"c5efb7b2.2b745","type":"change","z":"6e92f1fb.cff84","name":"Response","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"status\":\"received\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":240,"wires":[["1ca83b03.dd24fd"]]},{"id":"fc75975b.cac848","type":"switch","z":"6e92f1fb.cff84","name":"Topic Selection","property":"payload.topic","propertyType":"msg","rules":[{"t":"eq","v":"device-events","vt":"str"},{"t":"eq","v":"alarms","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":560,"y":580,"wires":[["3170033e.1fa88c","10db04e4.a2c68b"],["50ca48de.5a7a28"],[]]},{"id":"145e2c8b.8fe913","type":"change","z":"fbeaba9d.3c9028","name":"","rules":[{"t":"set","p":"site_id","pt":"msg","to":"payload.site_id","tot":"msg"},{"t":"set","p":"mac","pt":"msg","to":"payload.mac","tot":"msg"},{"t":"set","p":"ap_name","pt":"msg","to":"payload.ap_name","tot":"msg"},{"t":"set","p":"site_name","pt":"msg","to":"payload.site_name","tot":"msg"},{"t":"set","p":"reason","pt":"msg","to":"payload.reason","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":80,"wires":[["829d9e1b.cf7a8"]]},{"id":"551d6721.7629a8","type":"http request","z":"fbeaba9d.3c9028","name":"Get AP Current Version","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/sites/{{site_id}}/stats/devices?mac={{mac}}","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":280,"wires":[["b56bb508.9ee4d8"]]},{"id":"b8934b8e.01d688","type":"change","z":"6e92f1fb.cff84","name":"REQUIRED: Set API Token HERE","rules":[{"t":"set","p":"api_token","pt":"global","to":"<SET API TOKEN>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":60,"wires":[["fc75975b.cac848"]]},{"id":"829d9e1b.cf7a8","type":"template","z":"fbeaba9d.3c9028","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":390,"y":160,"wires":[["551d6721.7629a8"]]},{"id":"b56bb508.9ee4d8","type":"change","z":"fbeaba9d.3c9028","name":"Set Model/ID/Version","rules":[{"t":"set","p":"model","pt":"msg","to":"payload[0].model","tot":"msg"},{"t":"set","p":"device_id","pt":"msg","to":"payload[0].id","tot":"msg"},{"t":"set","p":"current_version","pt":"msg","to":"payload[0].version","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":280,"wires":[["f6a7e0c6.1084a8"]]},{"id":"f6a7e0c6.1084a8","type":"template","z":"fbeaba9d.3c9028","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":410,"y":360,"wires":[["c265529e.03a4e8"]]},{"id":"c265529e.03a4e8","type":"http request","z":"fbeaba9d.3c9028","name":"Get Site Settings","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/sites/{{site_id}}/setting","tls":"","persist":false,"proxy":"","authType":"","x":450,"y":460,"wires":[["4c9978db.2d526"]]},{"id":"4c9978db.2d526","type":"change","z":"fbeaba9d.3c9028","name":"Set Versions","rules":[{"t":"set","p":"versions","pt":"msg","to":"payload.auto_upgrade.custom_versions","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":460,"wires":[["e5a98f18.7948a"]]},{"id":"e5a98f18.7948a","type":"function","z":"fbeaba9d.3c9028","name":"Compare Firmware","func":"model = msg['model'];\ncurrent_version = msg['current_version'];\ndesired_version = msg['versions'][model];\nreason = msg['reason'];\nif (reason != 'upgrade') {\n if (current_version != desired_version) {\n msg['downgrade'] = desired_version\n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":560,"wires":[[]]},{"id":"a35650bf.64263","type":"template","z":"13d7f886.b3ab07","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":530,"y":260,"wires":[["6f951637.011e4"]]},{"id":"3170033e.1fa88c","type":"splitter","z":"6e92f1fb.cff84","name":"Event Splitter","property":"payload.events","x":850,"y":260,"wires":[["cc460f2e.fde42"]]},{"id":"cc460f2e.fde42","type":"switch","z":"6e92f1fb.cff84","name":"Event Type Filter","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"AP_CONNECTED","vt":"str"},{"t":"eq","v":"AP_RESTARTED","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":1050,"y":260,"wires":[["4dfd5559.58da64","872fa6a2.e4de3"],["4dfd5559.58da64","872fa6a2.e4de3"],[]]},{"id":"4dfd5559.58da64","type":"subflow:fbeaba9d.3c9028","z":"6e92f1fb.cff84","name":"","x":1310,"y":260,"wires":[["74d597af.6aa54","715f0740.bfd61"]]},{"id":"74d597af.6aa54","type":"subflow:13d7f886.b3ab07","z":"6e92f1fb.cff84","name":"","x":1510,"y":240,"wires":[["dd441c7.e9b116"]]},{"id":"c2fc42ea.c65e","type":"comment","z":"6e92f1fb.cff84","name":"Set API token here that has access to the specific org.","info":"Set API token here that has access to the specific org.","x":340,"y":20,"wires":[]},{"id":"10db04e4.a2c68b","type":"debug","z":"6e92f1fb.cff84","d":true,"name":"Pre-Split Device-Events-Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":320,"wires":[]},{"id":"872fa6a2.e4de3","type":"debug","z":"6e92f1fb.cff84","name":"Split-Event-Filter debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1310,"y":200,"wires":[]},{"id":"dd441c7.e9b116","type":"debug","z":"6e92f1fb.cff84","name":"Upgrade-Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1700,"y":220,"wires":[]},{"id":"50ca48de.5a7a28","type":"splitter","z":"6e92f1fb.cff84","name":"Event Splitter","property":"payload.events","x":850,"y":500,"wires":[[]]},{"id":"715f0740.bfd61","type":"debug","z":"6e92f1fb.cff84","name":"Firwmare-Check-Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1550,"y":280,"wires":[]},{"id":"3363efa4.3250a","type":"comment","z":"6e92f1fb.cff84","name":"AP Upgrade/Downgrade Flow","info":"","x":900,"y":220,"wires":[]}]