Skip to content

Instantly share code, notes, and snippets.

@DanEdens
Last active March 9, 2020 00:50
Show Gist options
  • Save DanEdens/4745732dc1092730f796e7368ec3d006 to your computer and use it in GitHub Desktop.
Save DanEdens/4745732dc1092730f796e7368ec3d006 to your computer and use it in GitHub Desktop.
Fleet controller flow for node-red
[{"id":"ddaf41df.e76d7","type":"tab","label":"Debug","disabled":false,"info":""},{"id":"ef0a1326.ffefe","type":"tab","label":"Event Listener","disabled":false,"info":""},{"id":"620a8013.090dd","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d8072816.202f58","type":"tab","label":"Notepad","disabled":false,"info":""},{"id":"f8b092ce.2f198","type":"tab","label":"Outbox","disabled":false,"info":"Filter and log outgoing traffic"},{"id":"8606dfd5.df337","type":"join-config","z":"","name":"pi4-2","register":true},{"id":"174c9775.d43329","type":"join-server","z":"","name":"pi4-2","port":"1822","joinConfig":"8606dfd5.df337"},{"id":"72ae563e.956af8","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"none","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"4b7726ae.0c5328","type":"google-credentials","z":"","displayName":""},{"id":"8162cbf2.9c3778","type":"link in","z":"ddaf41df.e76d7","name":"debug print","links":["59c41cb3.cf8f34","5ec4ca52.4d0ea4","990f3286.93b7a"],"x":95,"y":180,"wires":[["d71a945f.b51bc8"]]},{"id":"1041c452.095cbc","type":"file","z":"ddaf41df.e76d7","name":"","filename":"debuglog","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":540,"y":260,"wires":[["ff26a49b.a52758"]]},{"id":"ff26a49b.a52758","type":"link out","z":"ddaf41df.e76d7","name":"to log","links":[],"x":795,"y":200,"wires":[]},{"id":"564f63b8.52989c","type":"debug","z":"ddaf41df.e76d7","name":"Console print","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","x":600,"y":160,"wires":[]},{"id":"42b3eb9a.fc6944","type":"switch","z":"ddaf41df.e76d7","name":"Debug Mode","property":"debug","propertyType":"global","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":290,"y":240,"wires":[["ff26a49b.a52758"],["564f63b8.52989c"],["1041c452.095cbc","564f63b8.52989c"],["5f3517ee.482a58","564f63b8.52989c","1041c452.095cbc"]]},{"id":"5f3517ee.482a58","type":"type-detect","z":"ddaf41df.e76d7","name":"","field":"payload","fieldType":"msg","x":510,"y":340,"wires":[["564f63b8.52989c"]]},{"id":"a634c74b.a38bb8","type":"join-receive-message","z":"ef0a1326.ffefe","name":"","command":"status","variables":"","parseNumbers":false,"server":"174c9775.d43329","x":370,"y":160,"wires":[["b1e174b0.7cdfb8"]]},{"id":"472c07d.ba915f8","type":"link out","z":"ef0a1326.ffefe","name":"Events","links":["eb7a2c4.27151d"],"x":775,"y":380,"wires":[]},{"id":"ba401f8b.6b7bd","type":"join-receive-message","z":"ef0a1326.ffefe","name":"","command":"note","variables":"","parseNumbers":false,"server":"174c9775.d43329","x":270,"y":420,"wires":[["85dcb756.63c538"]]},{"id":"48874e2b.14eeb","type":"join-receive-message","z":"ef0a1326.ffefe","name":"","command":"debugmode","variables":"debug","parseNumbers":false,"server":"174c9775.d43329","x":1070,"y":320,"wires":[["8952fbb7.108388"]]},{"id":"1c2193de.b1547c","type":"join-receive-message","z":"ef0a1326.ffefe","name":"","command":"burst","variables":"","parseNumbers":false,"server":"174c9775.d43329","x":370,"y":120,"wires":[["f2ce2159.2e57"]]},{"id":"d1329e7c.ee8a1","type":"join-message","z":"620a8013.090dd","name":"test text to geo","text":"status","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":460,"y":520,"wires":[["5ec4ca52.4d0ea4"]]},{"id":"346b3b99.9b1b74","type":"inject","z":"620a8013.090dd","name":"3 sec test","topic":"","payload":"status","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":460,"y":100,"wires":[["f21b26b3.d287a8"]]},{"id":"2c68c41f.9d93cc","type":"file","z":"620a8013.090dd","name":"statuslog","filename":"statuslog","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":520,"y":340,"wires":[["5ec4ca52.4d0ea4"]]},{"id":"f21b26b3.d287a8","type":"join-message","z":"620a8013.090dd","name":"","text":"status","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":570,"y":240,"wires":[["5ec4ca52.4d0ea4"]]},{"id":"cd6caf6e.ccf73","type":"link in","z":"620a8013.090dd","name":"","links":["990f3286.93b7a"],"x":915,"y":340,"wires":[["5ec4ca52.4d0ea4"]]},{"id":"e6a2c05e.f5bfc","type":"link out","z":"620a8013.090dd","name":"","links":["abdab8db.9d1708"],"x":835,"y":300,"wires":[]},{"id":"5ec4ca52.4d0ea4","type":"link out","z":"620a8013.090dd","name":"print","links":["8162cbf2.9c3778"],"x":1075,"y":520,"wires":[],"info":"Print link\n"},{"id":"eb7a2c4.27151d","type":"link in","z":"620a8013.090dd","name":"Main - Events in","links":["472c07d.ba915f8"],"x":115,"y":420,"wires":[["aa036d93.de649"]]},{"id":"d46f1734.406038","type":"comment","z":"620a8013.090dd","name":"Debug print","info":"","x":1110,"y":460,"wires":[]},{"id":"fca3e5d.4443a18","type":"comment","z":"620a8013.090dd","name":"Outbox","info":"","x":850,"y":240,"wires":[]},{"id":"2f0b835a.6e15bc","type":"link in","z":"d8072816.202f58","name":"Notepad","links":["85dcb756.63c538"],"x":135,"y":300,"wires":[["c9e1bda.6586d4","d58fe7c1.d99898"]]},{"id":"c9e1bda.6586d4","type":"switch","z":"d8072816.202f58","d":true,"name":"Note Sorter","property":"note","propertyType":"global","rules":[{"t":"eq","v":"Python","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":380,"wires":[["d58fe7c1.d99898","9d90b55c.5613c8","9846c9aa.1a9b48","7a5eaa66.b47ae4","13c3a9f4.3d6746"]]},{"id":"39d594e4.0a68dc","type":"python-function","z":"d8072816.202f58","name":"Scan payload for target note ","func":"msg = msg['payload']\nfor x in notes:\n note = msg.find(x)\n\nprint(note)\n\nreturn msg","outputs":1,"x":380,"y":220,"wires":[["59c41cb3.cf8f34"]]},{"id":"6346e0cc.47b04","type":"catch","z":"d8072816.202f58","name":"python errors","scope":["39d594e4.0a68dc"],"uncaught":false,"x":690,"y":40,"wires":[["59c41cb3.cf8f34"]]},{"id":"59c41cb3.cf8f34","type":"link out","z":"d8072816.202f58","name":"notepad - debug","links":["8162cbf2.9c3778"],"x":915,"y":180,"wires":[]},{"id":"bf076e1b.19856","type":"join-message","z":"f8b092ce.2f198","name":"Geoghost","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":980,"y":240,"wires":[["990f3286.93b7a"]]},{"id":"990f3286.93b7a","type":"link out","z":"f8b092ce.2f198","name":"outbox out","links":["8162cbf2.9c3778"],"x":1275,"y":420,"wires":[]},{"id":"abdab8db.9d1708","type":"link in","z":"f8b092ce.2f198","name":"Outbox in","links":["e6a2c05e.f5bfc","91bdfa4b.280f48"],"x":195,"y":140,"wires":[["2bbb9fd9.893d3"]]},{"id":"5a2d32c9.b0887c","type":"switch","z":"f8b092ce.2f198","name":"Fleet traffic control","property":"device","propertyType":"global","rules":[{"t":"eq","v":"ghost","vt":"str"},{"t":"eq","v":"Serverghost","vt":"str"},{"t":"eq","v":"s8","vt":"str"},{"t":"eq","v":"p2","vt":"str"},{"t":"eq","v":"fieldpc","vt":"str"},{"t":"eq","v":"ubuntu","vt":"str"},{"t":"eq","v":"aws","vt":"str"},{"t":"eq","v":"jim's laptop","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":490,"y":400,"wires":[["bf076e1b.19856"],["6ba8e1cf.95331"],["4d4d9a1a.5e5934"],["70140be3.d61754"],["2953e372.29cbac"],["66129324.30c97c"],["8e748a9.a37c478"],["5e47a1f8.d704f"]]},{"id":"6ba8e1cf.95331","type":"join-message","z":"f8b092ce.2f198","name":"serverghost","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":930,"y":180,"wires":[["990f3286.93b7a"]]},{"id":"4d4d9a1a.5e5934","type":"join-message","z":"f8b092ce.2f198","name":"S8","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":1010,"y":300,"wires":[["990f3286.93b7a"]]},{"id":"70140be3.d61754","type":"join-message","z":"f8b092ce.2f198","name":"p2","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":1030,"y":360,"wires":[["990f3286.93b7a"]]},{"id":"2953e372.29cbac","type":"join-message","z":"f8b092ce.2f198","name":"fieldpc","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":970,"y":480,"wires":[["990f3286.93b7a"]]},{"id":"66129324.30c97c","type":"join-message","z":"f8b092ce.2f198","name":"ubuntu","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":1010,"y":420,"wires":[["990f3286.93b7a"]]},{"id":"8e748a9.a37c478","type":"join-message","z":"f8b092ce.2f198","name":"AWS","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":910,"y":540,"wires":[["990f3286.93b7a"]]},{"id":"5e47a1f8.d704f","type":"join-message","z":"f8b092ce.2f198","name":"jim's laptop","text":"$msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":770,"y":580,"wires":[["990f3286.93b7a"]]},{"id":"a99ba26c.a0e05","type":"comment","z":"f8b092ce.2f198","name":"Command Node","info":"","x":360,"y":120,"wires":[]},{"id":"e1bab105.0305","type":"alexa-notifyme","z":"f8b092ce.2f198","name":"Alexa notification","notification":"","x":730,"y":660,"wires":[["990f3286.93b7a"]]},{"id":"c3c999de.1e5d98","type":"facebook-messenger-writer","z":"f8b092ce.2f198","d":true,"name":"Message Holly","x":720,"y":720,"wires":[["990f3286.93b7a"]]},{"id":"2243f5f3.cdb8fa","type":"google calendar out","z":"f8b092ce.2f198","d":true,"google":"4b7726ae.0c5328","name":"","calendar":"","x":730,"y":800,"wires":[]},{"id":"c73d816a.9972e","type":"switch","z":"f8b092ce.2f198","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"alexa","vt":"str"},{"t":"eq","v":"Holly","vt":"str"},{"t":"eq","v":"Calender","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":430,"y":680,"wires":[["e1bab105.0305"],["c3c999de.1e5d98"],["2243f5f3.cdb8fa"]]},{"id":"2e32f884.e4fb98","type":"link in","z":"f8b092ce.2f198","name":"","links":[],"x":315,"y":640,"wires":[["c73d816a.9972e"]]},{"id":"25206160.44ffbe","type":"catch","z":"d8072816.202f58","name":"","scope":null,"uncaught":true,"x":680,"y":80,"wires":[["59c41cb3.cf8f34"]]},{"id":"270a5e3d.a591c2","type":"inject","z":"d8072816.202f58","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":300,"y":120,"wires":[["39d594e4.0a68dc"]]},{"id":"d71a945f.b51bc8","type":"debug","z":"ddaf41df.e76d7","name":"Console print","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","x":300,"y":100,"wires":[]},{"id":"d58fe7c1.d99898","type":"file","z":"d8072816.202f58","name":"note.txt","filename":"note.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":640,"y":300,"wires":[["59c41cb3.cf8f34"]]},{"id":"62018de4.9f3f64","type":"join-receive-message","z":"f8b092ce.2f198","name":"","command":"outboxtest","variables":"","parseNumbers":true,"server":"174c9775.d43329","x":170,"y":180,"wires":[["2bbb9fd9.893d3"]]},{"id":"ef224f91.c7a4d","type":"switch","z":"f8b092ce.2f198","name":"Broadcast","property":"device","propertyType":"global","rules":[{"t":"eq","v":"all","vt":"str"},{"t":"neq","v":"all","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":220,"wires":[["6ba8e1cf.95331","bf076e1b.19856","4d4d9a1a.5e5934","70140be3.d61754","66129324.30c97c","2953e372.29cbac","8e748a9.a37c478"],["5a2d32c9.b0887c"]]},{"id":"7115d39b.d9e5ac","type":"function","z":"ddaf41df.e76d7","name":"","func":"debug=0\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":480,"wires":[[]]},{"id":"ff5da94a.b44548","type":"join-receive-message","z":"ef0a1326.ffefe","name":"","command":"poweroff","variables":"","parseNumbers":false,"server":"174c9775.d43329","x":240,"y":280,"wires":[["74084130.3eb66","d4674d53.0eac5"]]},{"id":"f5ed3816.ee71a8","type":"exec","z":"ef0a1326.ffefe","command":"sudo shutdown now","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":720,"y":320,"wires":[[],[],[]]},{"id":"aa036d93.de649","type":"switch","z":"620a8013.090dd","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":420,"wires":[[]]},{"id":"85dcb756.63c538","type":"link out","z":"ef0a1326.ffefe","name":"","links":["2f0b835a.6e15bc"],"x":335,"y":420,"wires":[]},{"id":"91bdfa4b.280f48","type":"link out","z":"ef0a1326.ffefe","name":"","links":["abdab8db.9d1708"],"x":835,"y":100,"wires":[]},{"id":"f2ce2159.2e57","type":"function","z":"ef0a1326.ffefe","name":"device = all","func":"device = all;\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":120,"wires":[["91bdfa4b.280f48"]]},{"id":"b1e174b0.7cdfb8","type":"function","z":"ef0a1326.ffefe","name":"device = payload","func":"device = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":160,"wires":[["91bdfa4b.280f48"]]},{"id":"8952fbb7.108388","type":"function","z":"ef0a1326.ffefe","name":"Set Debug mode","func":"\ndebug = msg.payload;\ndevice = msg.senderid\nreturn msg;\n","outputs":1,"noerr":0,"x":1250,"y":340,"wires":[[]]},{"id":"b9db7136.bae96","type":"comment","z":"ef0a1326.ffefe","name":"Fleet commands","info":"","x":420,"y":80,"wires":[]},{"id":"1833fdaa.f14fc2","type":"comment","z":"ef0a1326.ffefe","name":"Local functions","info":"","x":1020,"y":140,"wires":[]},{"id":"2bbb9fd9.893d3","type":"switch","z":"f8b092ce.2f198","name":"If SenderID","property":"senderid","propertyType":"msg","rules":[{"t":"nempty"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":160,"wires":[["eec72b74.b6f868"],["ef224f91.c7a4d"]]},{"id":"eec72b74.b6f868","type":"join-message","z":"f8b092ce.2f198","name":"serverghost","text":"msg.payload","title":"","url":"","notificationicon":"","joinConfig":"8606dfd5.df337","x":510,"y":140,"wires":[[]]},{"id":"9d90b55c.5613c8","type":"file","z":"d8072816.202f58","name":"python note","filename":"python_note","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":590,"y":380,"wires":[["59c41cb3.cf8f34"]]},{"id":"9846c9aa.1a9b48","type":"file","z":"d8072816.202f58","name":"JS note","filename":"JS note","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":580,"y":420,"wires":[["59c41cb3.cf8f34"]]},{"id":"7a5eaa66.b47ae4","type":"file","z":"d8072816.202f58","name":"Work notes","filename":"Work notes","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":590,"y":460,"wires":[["59c41cb3.cf8f34"]]},{"id":"13c3a9f4.3d6746","type":"file","z":"d8072816.202f58","name":"filename is set","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":600,"y":340,"wires":[["59c41cb3.cf8f34"]]},{"id":"74084130.3eb66","type":"function","z":"ef0a1326.ffefe","name":"Report Shutdown to Pixel","func":"msg.payload = \"pi4 Shutdown Init\"\ndevice = p2\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":240,"wires":[["91bdfa4b.280f48"]],"info":"Also request plug to be toggled off."},{"id":"d4674d53.0eac5","type":"delay","z":"ef0a1326.ffefe","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":540,"y":320,"wires":[["f5ed3816.ee71a8"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment