-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAI2_AI_Controller.json
1 lines (1 loc) · 29.4 KB
/
AI2_AI_Controller.json
1
[{"id":"5890de58.d0635","type":"tab","label":"AI2.py and AI.py Controller","disabled":false,"info":""},{"id":"6cc4bcbe.07cdf4","type":"mqtt in","z":"5890de58.d0635","name":"AIdetection","topic":"AIdetection/#","qos":"0","datatype":"buffer","broker":"9c6af07a.2627c","x":80,"y":240,"wires":[["22b4c506.1db44a"]]},{"id":"22b4c506.1db44a","type":"change","z":"5890de58.d0635","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"image","tot":"msg"},{"t":"move","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":240,"wires":[["53d05e4a.75e64"]]},{"id":"a548d9d6.cbc5d8","type":"file","z":"5890de58.d0635","name":"","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","x":505,"y":240,"wires":[["fa9536fa.d83eb8"]]},{"id":"fa9536fa.d83eb8","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":630,"y":240,"wires":[]},{"id":"82f2b7ba.dbfbc8","type":"e-mail","z":"5890de58.d0635","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"","dname":"Email Notification","x":1250,"y":300,"wires":[]},{"id":"8be161e7.81d8","type":"mqtt out","z":"5890de58.d0635","name":"Alarm/MODE","topic":"Alarm/MODE","qos":"2","retain":"true","broker":"246d3fc2.0a7a3","x":980,"y":40,"wires":[]},{"id":"5d2168a9.085348","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1225,"y":265,"wires":[]},{"id":"371de7c4.83ee08","type":"file in","z":"5890de58.d0635","name":"get file ","filename":"","format":"","chunk":false,"sendError":false,"x":1170,"y":355,"wires":[["f064a734.bfd5e8"]]},{"id":"f064a734.bfd5e8","type":"change","z":"5890de58.d0635","name":"Setup Email","rules":[{"t":"set","p":"to","pt":"msg","to":"2817489274@mms.cricketwireless.net","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"AI Detection Alert!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":300,"wires":[["3ae6d488.7e2b9c"]]},{"id":"a428f2c6.ff7a7","type":"inject","z":"5890de58.d0635","name":"Send Test Email","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":850,"y":355,"wires":[["5c941212.5447bc"]]},{"id":"5c941212.5447bc","type":"change","z":"5890de58.d0635","name":"attachment","rules":[{"t":"set","p":"msg.filename","pt":"msg","to":"/home/ai/AI/TestDetection.jpg","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1025,"y":355,"wires":[["371de7c4.83ee08"]]},{"id":"77468520.7cec7c","type":"inject","z":"5890de58.d0635","name":"Set AI Mode Idle","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"Alarm/MODE","payload":"Idle","payloadType":"str","x":120,"y":40,"wires":[["fac05224.f15b7"]]},{"id":"6b4c1881.d1e8d8","type":"inject","z":"5890de58.d0635","name":"Set AI Mode Audio","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"2.0","topic":"Alarm/MODE","payload":"Audio","payloadType":"str","x":130,"y":80,"wires":[["fac05224.f15b7"]]},{"id":"83fa3340.5d474","type":"inject","z":"5890de58.d0635","name":"Set AI Mode Notify","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"2","topic":"Alarm/MODE","payload":"Notify","payloadType":"str","x":130,"y":120,"wires":[["fac05224.f15b7"]]},{"id":"fac05224.f15b7","type":"ui_dropdown","z":"5890de58.d0635","name":"Set AI Mode","label":"","tooltip":"Set AI Mode","place":"Select option","group":"ab50e227.03924","order":3,"width":0,"height":0,"passthru":true,"options":[{"label":"Idle","value":"Idle","type":"str"},{"label":"Audio Alerts","value":"Audio","type":"str"},{"label":"Email Alerts","value":"Notify","type":"str"}],"payload":"","topic":"Alarm/MODE","x":360,"y":80,"wires":[["40639e1d.10de2"]]},{"id":"3ae6d488.7e2b9c","type":"delay","z":"5890de58.d0635","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"6","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1020,"y":300,"wires":[["5d2168a9.085348","82f2b7ba.dbfbc8"]]},{"id":"6b8b1757.f058b8","type":"base64","z":"5890de58.d0635","name":"","action":"str","property":"payload","x":455,"y":460,"wires":[["97a0562d.0f7908","77fbb6f6.335e08"]]},{"id":"6fa4ae7e.22e55","type":"mqtt in","z":"5890de58.d0635","name":"espeak","topic":"Espeak","qos":"2","broker":"e08d50df.8107c","x":1160,"y":100,"wires":[["40a395e9.88c15c","1364159d.60478a"]]},{"id":"db63d3be.bd6d6","type":"inject","z":"5890de58.d0635","name":"speak test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Espeak","payload":"MultiWordTest","payloadType":"str","x":1210,"y":40,"wires":[["1364159d.60478a","40a395e9.88c15c"]]},{"id":"40a395e9.88c15c","type":"exec","z":"5890de58.d0635","command":"/usr/bin/espeak","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":true,"name":"Espeak","x":1310,"y":160,"wires":[["710d8786.f9d4e8"],["710d8786.f9d4e8"],[]]},{"id":"aa940a62.fd6f78","type":"delay","z":"5890de58.d0635","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1130,"y":160,"wires":[["1364159d.60478a","40a395e9.88c15c"]]},{"id":"aa8cb681.cc2bb8","type":"ui_dropdown","z":"5890de58.d0635","name":"Set UI View","label":"","tooltip":"Enable/Disable Camera Live View","place":"Camera Viewing","group":"ab50e227.03924","order":1,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Disable","value":"0","type":"str"},{"label":"Live","value":"1","type":"str"},{"label":"Detections","value":"3","type":"str"}],"payload":"","topic":"Alarm/UImode","x":350,"y":980,"wires":[["51a906a4.11cbb8"]]},{"id":"51a906a4.11cbb8","type":"mqtt out","z":"5890de58.d0635","name":"Alarm/UImode","topic":"Alarm/UImode","qos":"2","retain":"true","broker":"246d3fc2.0a7a3","x":540,"y":980,"wires":[]},{"id":"fe77220a.a7683","type":"mqtt in","z":"5890de58.d0635","name":"ImageBuffer","topic":"ImageBuffer/#","qos":"0","datatype":"buffer","broker":"246d3fc2.0a7a3","x":95,"y":515,"wires":[["5b1660dd.c3a53"]]},{"id":"fba09ca9.023f","type":"rbe","z":"5890de58.d0635","name":"loop breaker","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":780,"y":40,"wires":[["8be161e7.81d8"]]},{"id":"26fd3247.2e1f2e","type":"inject","z":"5890de58.d0635","name":"Alarm/UImode","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"3","topic":"Alarm/UImode","payload":"3","payloadType":"str","x":135,"y":980,"wires":[["aa8cb681.cc2bb8"]]},{"id":"1364159d.60478a","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1420,"y":100,"wires":[]},{"id":"5b1660dd.c3a53","type":"change","z":"5890de58.d0635","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"image","tot":"msg"},{"t":"move","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":305,"y":515,"wires":[["2f998ed0.a825b2"]]},{"id":"2f998ed0.a825b2","type":"csv","z":"5890de58.d0635","name":"","sep":"!","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"topic,filename","skip":"0","x":90,"y":460,"wires":[["58ad3058.ed1ad"]]},{"id":"58ad3058.ed1ad","type":"change","z":"5890de58.d0635","name":"","rules":[{"t":"move","p":"payload.filename","pt":"msg","to":"filename","tot":"msg"},{"t":"move","p":"image","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"ImageBuffer","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":460,"wires":[["6b8b1757.f058b8"]]},{"id":"53d05e4a.75e64","type":"csv","z":"5890de58.d0635","name":"","sep":"!","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"topic,filename,startX,startY,endX,endY,Xcenter,Ycenter,Xlength,Ylength","skip":"0","strings":true,"x":90,"y":180,"wires":[["e1e8f1d5.494be"]]},{"id":"e1e8f1d5.494be","type":"change","z":"5890de58.d0635","name":"","rules":[{"t":"move","p":"payload.filename","pt":"msg","to":"filename","tot":"msg"},{"t":"move","p":"payload.startX","pt":"msg","to":"startX","tot":"msg"},{"t":"move","p":"payload.startY","pt":"msg","to":"startY","tot":"msg"},{"t":"move","p":"payload.endX","pt":"msg","to":"endX","tot":"msg"},{"t":"move","p":"payload.endY","pt":"msg","to":"endY","tot":"msg"},{"t":"move","p":"payload.Xcenter","pt":"msg","to":"Xcenter","tot":"msg"},{"t":"move","p":"payload.Ycenter","pt":"msg","to":"Ycenter","tot":"msg"},{"t":"move","p":"payload.Xlength","pt":"msg","to":"Xlength","tot":"msg"},{"t":"move","p":"payload.Ylength","pt":"msg","to":"Ylength","tot":"msg"},{"t":"move","p":"image","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"AIdetection","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":180,"wires":[["c816c5f2.e0ec78"]]},{"id":"710d8786.f9d4e8","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1460,"y":160,"wires":[]},{"id":"edcfaafa.6759d8","type":"inject","z":"5890de58.d0635","name":"Alarm/ViewCamera","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1.2","topic":"Alarm/ViewCamera","payload":"0","payloadType":"str","x":145,"y":1040,"wires":[["934f7a1f.86e2f8"]]},{"id":"934f7a1f.86e2f8","type":"ui_dropdown","z":"5890de58.d0635","name":"Select Camera","label":"","tooltip":"Select Camera for Live View or Detection","place":"Select Camera","group":"ab50e227.03924","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Cam 0","value":"0","type":"str"},{"label":"Cam 1","value":"1","type":"str"},{"label":"Cam 2","value":"2","type":"str"},{"label":"Cam 3","value":"3","type":"str"},{"label":"Cam 4","value":"4","type":"str"},{"label":"Cam 5","value":"5","type":"str"},{"label":"Cam 6","value":"6","type":"str"},{"label":"Cam 7","value":"7","type":"str"}],"payload":"","topic":"ViewCamera","x":390,"y":1040,"wires":[["f5ed8d48.c97b3"]]},{"id":"f5ed8d48.c97b3","type":"mqtt out","z":"5890de58.d0635","name":"Alarm/ViewCamera","topic":"Alarm/ViewCamera","qos":"2","retain":"true","broker":"246d3fc2.0a7a3","x":620,"y":1040,"wires":[]},{"id":"f1a7be6a.fc1f5","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":460,"y":1160,"wires":[]},{"id":"ed1b9fd2.b6423","type":"ui_button","z":"5890de58.d0635","name":"PowerOff","group":"b97a8de5.94bb","order":5,"width":"0","height":"0","passthru":false,"label":"Power Off","tooltip":"","color":"","bgcolor":"#793042","icon":"","payload":"Powering Down","payloadType":"str","topic":"","x":95,"y":1160,"wires":[["1d052604.550e8a","6fc93b89.8a4d24"]]},{"id":"1d052604.550e8a","type":"exec","z":"5890de58.d0635","command":" sudo /home/ai/AI2/PowerOff.sh","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"shutdown","x":275,"y":1160,"wires":[["f1a7be6a.fc1f5"],["f1a7be6a.fc1f5"],["f1a7be6a.fc1f5"]]},{"id":"d93a7452.703098","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":460,"y":1220,"wires":[]},{"id":"8a3c5c9c.7c9d6","type":"exec","z":"5890de58.d0635","command":" sudo /home/ai/AI2/Reboot.sh","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"reboot","x":265,"y":1220,"wires":[["d93a7452.703098"],["d93a7452.703098"],["d93a7452.703098"]]},{"id":"628d4863.b404c8","type":"ui_button","z":"5890de58.d0635","name":"Reboot","group":"b97a8de5.94bb","order":4,"width":"0","height":"0","passthru":false,"label":"Reboot","tooltip":"","color":"","bgcolor":"#808080","icon":"","payload":"Rebooting","payloadType":"str","topic":"","x":95,"y":1220,"wires":[["8a3c5c9c.7c9d6","6fc93b89.8a4d24"]]},{"id":"2577839c.684ebc","type":"inject","z":"5890de58.d0635","name":"Daily Cleanup","repeat":"","crontab":"00 01 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":125,"y":300,"wires":[["fa61317b.3d51b"]]},{"id":"fa61317b.3d51b","type":"exec","z":"5890de58.d0635","command":"/home/ai/AI2/Cleanup.sh ","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"disk cleanup","x":330,"y":300,"wires":[["e214547a.22fdf8"],["e214547a.22fdf8"],["e214547a.22fdf8"]]},{"id":"e214547a.22fdf8","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":300,"wires":[]},{"id":"92547314.afdfb","type":"mqtt in","z":"5890de58.d0635","name":"AI/Status","topic":"AI/Status","qos":"2","broker":"246d3fc2.0a7a3","x":80,"y":360,"wires":[["33df5888.0ab078","1e739047.6405d"]]},{"id":"33df5888.0ab078","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":390,"y":360,"wires":[]},{"id":"3f6adb3e.83d5e4","type":"ui_button","z":"5890de58.d0635","name":"StopAI","group":"b97a8de5.94bb","order":3,"width":"0","height":"0","passthru":false,"label":"Stop AI","tooltip":"Stop the Python AI code","color":"","bgcolor":"#d02020","icon":"","payload":"Stopping AI","payloadType":"str","topic":"","x":100,"y":900,"wires":[["6fc93b89.8a4d24"]]},{"id":"7121c2fb.b76c5c","type":"exec","z":"5890de58.d0635","command":"/home/ai/AI2/StopAI.sh ","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"StopAI","x":440,"y":900,"wires":[["49e55f83.d69b6"],["49e55f83.d69b6"],["49e55f83.d69b6"]]},{"id":"40639e1d.10de2","type":"function","z":"5890de58.d0635","name":"Notification Filter","func":"var Idle = flow.get('Idle')||0;\nvar Audio = flow.get('Audio')||0;\nvar Notify = flow.get('Notify')||0;\nvar alertAnyway;\n\nif (msg.topic === \"Alarm/MODE\"){\n if(msg.payload.includes(\"Idle\")){\n flow.set('Idle',1); \n flow.set('Audio',0);\n flow.set('Notify',0);\n }else if(msg.payload.includes(\"Audio\")){\n flow.set('Idle',0);\n flow.set('Audio',1);\n flow.set('Notify',0);\n }else if(msg.payload.includes(\"Notify\")){\n flow.set('Idle',0);\n flow.set('Audio',0);\n flow.set('Notify',1);\n }\n return [ msg, null, null ]; // change null to msg for debugging.\n}\n\n\nif (msg.topic.includes(\"AIdetection\")){\n // without this dog walkers on Hummingbird cause alerts\n if (msg.InAlertRegion === false){ // inRegionFilter sets this.\n return [ null, null, null ];\n }\n if (Idle == 1){\n /*\n This is an example to enable audio alerts on certain cameras\n even if in idle mode where there woould normally be no notification.\n Normally people are not in the alert region of these cameras\n */\n alertAnyway=0;\n if( msg.filename.includes(\"Mail\")|| msg.filename.includes(\"Front\") || \n msg.filename.includes(\"Humming\") || msg.filename.includes(\"South\") ||\n msg.filename.includes(\"North\") || msg.filename.includes(\"Side\")){\n alertAnyway=1;\n }\n if (alertAnyway == 1){\n return [ null, msg, null ];\n }else{\n return [ null, null, null ];\n }\n }\n if (Audio == 1){\n return [ null, msg, null ];\n }\n if (Notify == 1){\n if (msg.startY>= 30)\n return [ null, msg, msg ];\n else // don't email images with head cut off, wait for better one\n return [ null, msg, null ];\n }\n}\n\nreturn [ null, null, null ];","outputs":3,"noerr":0,"initialize":"","finalize":"","x":580,"y":80,"wires":[["fba09ca9.023f"],["fa8b5761.f2c4b8","f238f55b.280248"],["f064a734.bfd5e8"]],"outputLabels":["Status","AudioAlert","EmailAlert"]},{"id":"c816c5f2.e0ec78","type":"function","z":"5890de58.d0635","name":"In Region Filter","func":"/* LorexAI \"in alert region\" filter.\n Install point-in-polygon with:\n cd ~/.node-red\n npm install point-in-polygon\n var inside = require('point-in-polygon'); // doesn't work in node-red.\n So must edit .node-red/settings.js and add:\n functionGlobalContext: {\n insidePolygon:require('point-in-polygon')\n }\n Requires a node-red restart when finished.\n*/\n\nvar inside = global.get('insidePolygon');\nmsg.InAlertRegion=true; // default is to accept detection anywhere in image\n\n// extract Camera Name from filename.\nvar str = msg.filename\nmsg.CameraName = str.split(/[--]/)[3];\n\n// screen for LR box point in polygonal region\nvar poly=[[]];\n/*\n// polygon points picked from image using GIMP\nif(msg.filename.includes(\"DriveWay\"))\n poly=[ [500,1600], [1550,1200], [2200,700], [3841,500], [3841,1500], [2200, 2161], [1400,2161] ];\nelse if(msg.filename.includes(\"CliffwoodNorth\"))\n poly=[ [-1,1980], [3500,400], [3840,380], [3840, 2160],[-1,2160] ];\nelse if(msg.filename.includes(\"CliffwoodSouth\"))\n poly=[ [50,250], [250,750], [3840,1900], [50,1900] ];\n//else if(msg.filename.includes(\"Intersection\"))\n// poly=[ [-1,1000], [900,1100], [3841,1500], [3841,2161], [-1,2161] ];\nelse if(msg.filename.includes(\"HummingbirdRight\"))\n poly=[ [-1,1100], [2400,900], [3841,1650], [3841,2161], [-1, 2161] ];\nelse if(msg.filename.includes(\"FrontDoor\"))\n poly=[[-1,900], [600,1100], [600,900], [3841,1100], [3841,2161], [-1,2161], ];\nelse if(msg.filename.includes(\"HummingbirdLeft\"))\n poly=[[1200,850], [500,1600], [-1,2161], [3841,2161], [3841,1000], [3000,1000]];\n*/ \nif(poly.length > 2)\n msg.InAlertRegion = inside([msg.endX, msg.endY], poly); // returns false if point not inside polygon\nif(msg.InAlertRegion === false)\n return msg; // no need to test for bogus object if out of the alert region.\n\n\n\n// filter for box points matching bogus detection of static object\n// var bogus=[[ ULx.ULy, LRx,LRy, tol ]];\n//\n// UL,LR of reject object obtained from bogus AI detection image overlay text\n// CamBogus = [ [ startX,startY, endX,endY, tolerence] ]; // multiple bogus detections can be in a frame, so 2D array, N by 5.\nvar bogus= [ [] ]; // empty 2D array is 1 by 0\n\n/* Idea is that -y8v option makes these no longer necessary\nif(msg.filename.includes(\"PoolEquipment\")){\n bogus=[ [1300,670, 1420,790, 0.8], // plumbing pipes/valves\n [636,621, 1091,1078, 0.3], // pool filter tank\n [806,535, 1260,1083, 0.3], // pool filter tank\n [441,198, 908,810, 0.3] ]; // pool chemical storage cans\n}else if(msg.filename.includes(\"KitchenDoor\"))\n bogus=[ [870,255, 1490,650, 0.2] ]; // table on patio\nelse if(msg.filename.includes(\"HummingbirdLeft\"))\n bogus=[ [2918,235, 3343,916, 0.3] ]; // tree trunk, so far only see these with CPU or NCS AI\nelse if(msg.filename.includes(\"MailBox\"))\n bogus=[ [883,117, 1606,122, 0.2] ]; // morning shadows on mailbox\nelse if(msg.filename.includes(\"SideYard\"))\n bogus=[ [864,136, 864,674, 0.2] ]; // afternoon shadows on tarp, so far only see these with CPU or NCS AI\n*/\nvar xtol, ytol;\nif(bogus[0].length == 5){\n for (var i=0; i<bogus.length; i++){\n xtol=(bogus[i][2]-bogus[i][0])*bogus[i][4];\n if(Math.abs(msg.startX-bogus[i][0])>xtol){continue}\n if(Math.abs(msg.endX-bogus[i][2])>xtol){continue}\n ytol=(bogus[i][3]-bogus[i][1])*bogus[i][4];\n if(Math.abs(msg.startY-bogus[i][1])>ytol){continue}\n if(Math.abs(msg.endY-bogus[i][3])>ytol){continue}\n msg.InAlertRegion=false;\n }\n}\n\n// screen cameras I don't want alerts from for now.\nif( msg.filename.includes(\"Inter\")|| msg.filename.includes(\"Plate\") || msg.filename.includes(\"Reo\") ){\n msg.InAlertRegion=false;\n}\n\n\n\nif(msg.InAlertRegion === true)\n msg.filename=msg.filename.replace(\"AI\", \"AI.alert\"); // for QA/QC want to know what would trigger alerts.\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":180,"wires":[["40639e1d.10de2","a548d9d6.cbc5d8","a53e907b.67034"]]},{"id":"49e55f83.d69b6","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":900,"wires":[]},{"id":"97a0562d.0f7908","type":"ui_button","z":"5890de58.d0635","name":"filename","group":"a211cbf8.2a6268","order":2,"width":"12","height":"1","passthru":true,"label":"{{msg.filename}}","tooltip":"","color":"#101010","bgcolor":"#83ed7b","icon":"","payload":"","payloadType":"str","topic":"","x":615,"y":500,"wires":[[]]},{"id":"9a8e4a89.fbc9f8","type":"comment","z":"5890de58.d0635","name":"Sound might not be working.","info":"Ubuntu on Intel sometimes has issues with espeak\nworking in terminal but not node-red exec node.\nAdd this:\n\noptions snd_hda_intel index=1\n\nto /etc/modprobe.d/alsa-base.conf \n(or default.conf in there is no alsa config file)\nand reboot.","x":1450,"y":40,"wires":[]},{"id":"77fbb6f6.335e08","type":"template","z":"5890de58.d0635","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img height=\"360px\" src=\"data:image/jpg;base64,{{{payload}}}\">","output":"str","x":620,"y":460,"wires":[["ef434a04.7e3e68"]]},{"id":"ef434a04.7e3e68","type":"ui_template","z":"5890de58.d0635","group":"a211cbf8.2a6268","name":"Viewer","order":1,"width":"13","height":"7","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":770,"y":460,"wires":[[]]},{"id":"a53e907b.67034","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":630,"y":180,"wires":[]},{"id":"fa8b5761.f2c4b8","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":790,"y":80,"wires":[]},{"id":"f238f55b.280248","type":"change","z":"5890de58.d0635","name":"Camera Name","rules":[{"t":"set","p":"payload","pt":"msg","to":"CameraName","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Espeak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":160,"wires":[["aa940a62.fd6f78"]]},{"id":"51d09ab3.74a934","type":"inject","z":"5890de58.d0635","name":"Launch AI","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"","payloadType":"date","x":110,"y":760,"wires":[[]]},{"id":"9e930e7b.57cdd","type":"mqtt in","z":"5890de58.d0635","name":"AmAlive","topic":"AmAlive","qos":"0","broker":"feaef1cb.8cc59","x":80,"y":820,"wires":[["d630d85.349a828"]]},{"id":"d630d85.349a828","type":"trigger","z":"5890de58.d0635","name":"watchdog","op1":"","op2":"Watchdog Timeout Onvif AI Restart!","op1type":"nul","op2type":"str","duration":"5","extend":true,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":240,"y":820,"wires":[[]]},{"id":"acac247f.0c30c8","type":"exec","z":"5890de58.d0635","command":"/home/ai/AI2/StartAI.sh ","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"StartAI","x":480,"y":760,"wires":[["e86ae093.62c86"],["e86ae093.62c86"],["e86ae093.62c86"]]},{"id":"e86ae093.62c86","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":700,"y":760,"wires":[]},{"id":"6bd5605e.bb387","type":"comment","z":"5890de58.d0635","name":"Auto Start","info":"Wire \"LaunchAI\" node to \"StartAI\" node \nto have the AI start when system is booted.\n\nWire \"watchdog\" node to \"StartAI\" to restart\nthe Python AI if it crashes. This will also\ncause the AI to start after system boots up\nwhen the watchdog times out in 5 minutes\nafter node-red is running.\n","x":80,"y":580,"wires":[]},{"id":"aa917052.b2d14","type":"ui_button","z":"5890de58.d0635","name":"StartAI","group":"b97a8de5.94bb","order":1,"width":"0","height":"0","passthru":false,"label":"Start AI","tooltip":"Launch the Python AI2 code","color":"","bgcolor":"#20d020","icon":"","payload":"Launching AI2 python code","payloadType":"str","topic":"filename","x":70,"y":700,"wires":[["c2904807.e5e0b8"]]},{"id":"c2904807.e5e0b8","type":"delay","z":"5890de58.d0635","name":"one shot","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":240,"y":700,"wires":[["7329c87b.823ba8","acac247f.0c30c8","f3e1129e.d874a"]]},{"id":"8cc315c9.f77038","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":590,"y":700,"wires":[]},{"id":"7329c87b.823ba8","type":"change","z":"5890de58.d0635","name":"feedback","rules":[{"t":"move","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":700,"wires":[["8cc315c9.f77038","97a0562d.0f7908"]]},{"id":"817226fd.af9718","type":"debug","z":"5890de58.d0635","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":605,"y":1100,"wires":[]},{"id":"1e02c7d9.949dd8","type":"mqtt in","z":"5890de58.d0635","name":"Set Camera Names","topic":"dynamic","qos":"0","datatype":"utf8","broker":"feaef1cb.8cc59","x":125,"y":1100,"wires":[["a2f4f646.bd75b8"]]},{"id":"9fc64401.ce0ee8","type":"change","z":"5890de58.d0635","name":"options","rules":[{"t":"move","p":"payload","pt":"msg","to":"options","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":455,"y":1100,"wires":[["817226fd.af9718","934f7a1f.86e2f8"]]},{"id":"a2f4f646.bd75b8","type":"json","z":"5890de58.d0635","name":"","property":"payload","action":"obj","pretty":false,"x":305,"y":1100,"wires":[["9fc64401.ce0ee8"]]},{"id":"1e739047.6405d","type":"change","z":"5890de58.d0635","name":"feedback","rules":[{"t":"move","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":400,"wires":[["97a0562d.0f7908"]]},{"id":"f3e1129e.d874a","type":"mqtt out","z":"5890de58.d0635","name":"Alarm/QUIT","topic":"Alarm/QUIT","qos":"1","retain":"false","broker":"246d3fc2.0a7a3","x":500,"y":840,"wires":[]},{"id":"5e32cb67.e24bc4","type":"ui_button","z":"5890de58.d0635","name":"StartObsoleteAI","group":"b97a8de5.94bb","order":2,"width":"0","height":"0","passthru":false,"label":"Start Obsolete AI","tooltip":"Launch the Python AI code","color":"","bgcolor":"#400030","icon":"","payload":"Launching Obsolete AI python code","payloadType":"str","topic":"filename","x":100,"y":640,"wires":[["8aec3ed1.db9cf"]]},{"id":"a8f6020a.a2241","type":"exec","z":"5890de58.d0635","command":"/home/ai/AI/StartAI.sh ","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Start Obsolete AI","x":470,"y":640,"wires":[["4aa90979.90cda8"],["4aa90979.90cda8"],["4aa90979.90cda8"]]},{"id":"4aa90979.90cda8","type":"debug","z":"5890de58.d0635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":640,"wires":[]},{"id":"8aec3ed1.db9cf","type":"delay","z":"5890de58.d0635","name":"one shot","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":280,"y":640,"wires":[["a8f6020a.a2241","7329c87b.823ba8"]]},{"id":"6fc93b89.8a4d24","type":"delay","z":"5890de58.d0635","name":"one shot","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":260,"y":900,"wires":[["f3e1129e.d874a","7121c2fb.b76c5c","7329c87b.823ba8"]]},{"id":"9c6af07a.2627c","type":"mqtt-broker","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"246d3fc2.0a7a3","type":"mqtt-broker","name":"localhost:1883","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"ab50e227.03924","type":"ui_group","name":" AI Mode","tab":"ccd01d21.1142d","order":1,"disp":true,"width":"4","collapse":false},{"id":"e08d50df.8107c","type":"mqtt-broker","name":"localhost:1883","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"b97a8de5.94bb","type":"ui_group","z":"","name":"System Controls","tab":"ccd01d21.1142d","order":4,"disp":true,"width":"5","collapse":true},{"id":"a211cbf8.2a6268","type":"ui_group","name":"Camera Viewer","tab":"ccd01d21.1142d","order":2,"disp":true,"width":"13","collapse":false},{"id":"feaef1cb.8cc59","type":"mqtt-broker","name":"localhost:1883","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"ccd01d21.1142d","type":"ui_tab","z":"","name":"AI2-AI Controller","icon":"dashboard","disabled":false,"hidden":false}]