[ { "id": "ca2f6aa3.4cab88", "type": "tab", "label": "PiCam Notification", "disabled": false, "info": "" }, { "id": "7826cafe.e5f8e4", "type": "e-mail", "z": "ca2f6aa3.4cab88", "server": "smtp.gmail.com", "port": "465", "secure": true, "name": "", "dname": "Email Notification", "x": 1270, "y": 460, "wires": [] }, { "id": "f6776f71.3c951", "type": "mqtt out", "z": "ca2f6aa3.4cab88", "name": "Set AI Mode", "topic": "AI/Control/Mode", "qos": "2", "retain": "true", "broker": "ffdaca5.cbbd038", "x": 710, "y": 260, "wires": [] }, { "id": "97ab93ac.32241", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 690, "y": 220, "wires": [] }, { "id": "ea3a5751.4a1bf8", "type": "mqtt in", "z": "ca2f6aa3.4cab88", "name": "Person Detected", "topic": "AI/Detection", "qos": "2", "broker": "ffdaca5.cbbd038", "x": 120, "y": 320, "wires": [ [ "1c9d9398.26b97c", "58946705.64f538", "8528349f.274af8" ] ] }, { "id": "1c9d9398.26b97c", "type": "function", "z": "ca2f6aa3.4cab88", "name": "Notification Filter", "func": "var Idle = context.get('Idle')||0;\nvar Audio = context.get('Audio')||0;\nvar Notify = context.get('Notify')||0;\n\nif (msg.topic === \"AI/Control/Mode\"){\n if(msg.payload.includes(\"Idle\")){\n context.set('Idle',1); \n context.set('Audio',0);\n context.set('Notify',0);\n }else if(msg.payload.includes(\"Audio\")){\n context.set('Idle',0);\n context.set('Audio',1);\n context.set('Notify',0);\n }else if(msg.payload.includes(\"Notify\")){\n context.set('Idle',0);\n context.set('Audio',0);\n context.set('Notify',1);\n }\n return [ msg, null, null ]; // change null to msg for debugging.\n}\n\nif (msg.topic === \"AI/Detection\"){\n if (Idle == 1){\n return [ null, null, null ];\n }\n if (Audio == 1){\n return [ null, msg, null ];\n }\n if (Notify == 1){\n return [ null, null, msg ];\n }\n}\nreturn [ null, null, null ];", "outputs": 3, "noerr": 0, "x": 410, "y": 320, "wires": [ [ "f6776f71.3c951", "97ab93ac.32241" ], [ "ddd405c1.e8cb78" ], [ "8ec0e90c.019b48", "b7245dad.bf622", "e17012a8.5bd0b" ] ] }, { "id": "9599dbca.99d2e8", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 1230, "y": 400, "wires": [] }, { "id": "ddd405c1.e8cb78", "type": "exec", "z": "ca2f6aa3.4cab88", "command": "/usr/bin/espeak-ng \"Person Detected!\"", "addpay": false, "append": "", "useSpawn": "false", "timer": "", "oldrc": false, "name": "Espeak Person Detected", "x": 750, "y": 320, "wires": [ [], [], [] ] }, { "id": "ea763542.4e6a18", "type": "file in", "z": "ca2f6aa3.4cab88", "name": "File Attachment", "filename": "", "format": "", "chunk": false, "sendError": false, "x": 1060, "y": 460, "wires": [ [ "7826cafe.e5f8e4", "9599dbca.99d2e8" ] ] }, { "id": "8ec0e90c.019b48", "type": "change", "z": "ca2f6aa3.4cab88", "name": "Setup Email", "rules": [ { "t": "move", "p": "payload", "pt": "msg", "to": "filename", "tot": "msg" }, { "t": "set", "p": "to", "pt": "msg", "to": "", "tot": "str" }, { "t": "set", "p": "cc", "pt": "msg", "to": "", "tot": "str" }, { "t": "set", "p": "topic", "pt": "msg", "to": "PiCam AI Detection", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 670, "y": 460, "wires": [ [ "3b06a6a3.da246a" ] ] }, { "id": "b7245dad.bf622", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 690, "y": 380, "wires": [] }, { "id": "a6e3c503.935cf8", "type": "change", "z": "ca2f6aa3.4cab88", "name": "Setup SMS", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload", "pt": "msg", "to": "5556667777,6666666666 NoirOne AI Person Detected! Check Email.", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 830, "y": 580, "wires": [ [ "df655a5b.39e878" ] ] }, { "id": "df655a5b.39e878", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 990, "y": 540, "wires": [] }, { "id": "e17012a8.5bd0b", "type": "delay", "z": "ca2f6aa3.4cab88", "name": "", "pauseType": "rate", "timeout": "5", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "minute", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": true, "x": 670, "y": 580, "wires": [ [ "a6e3c503.935cf8" ] ] }, { "id": "6b57db2d.c5aab4", "type": "inject", "z": "ca2f6aa3.4cab88", "name": "Send Test Email", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 140, "y": 460, "wires": [ [ "8923dce7.7b1cf" ] ] }, { "id": "8923dce7.7b1cf", "type": "change", "z": "ca2f6aa3.4cab88", "name": "set file attachment", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "/path/to/test.jpg", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 450, "y": 460, "wires": [ [ "8ec0e90c.019b48" ] ] }, { "id": "d4e4351.29fcfc8", "type": "inject", "z": "ca2f6aa3.4cab88", "name": "Send Test SMS", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 140, "y": 580, "wires": [ [ "e17012a8.5bd0b" ] ] }, { "id": "73a0fde4.a7cb64", "type": "inject", "z": "ca2f6aa3.4cab88", "name": "Set AI Mode Idle", "topic": "AI/Control/Mode", "payload": "Idle", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 140, "y": 200, "wires": [ [ "1c9d9398.26b97c" ] ] }, { "id": "842f01c8.fec12", "type": "inject", "z": "ca2f6aa3.4cab88", "name": "Set AI Mode Audio", "topic": "AI/Control/Mode", "payload": "Audio", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 150, "y": 240, "wires": [ [ "1c9d9398.26b97c" ] ] }, { "id": "296f5bf1.ea6d04", "type": "inject", "z": "ca2f6aa3.4cab88", "name": "Set AI Mode Notify", "topic": "AI/Control/Mode", "payload": "Notify", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "x": 150, "y": 280, "wires": [ [ "1c9d9398.26b97c" ] ] }, { "id": "6df78397.2f749c", "type": "comment", "z": "ca2f6aa3.4cab88", "name": "PiCam Notification", "info": "## Set AI Mode\n1. Idle -- nothing happens, set on startup\n2. Audio -- AI detection plays audio and saves image\n3. Notify -- AI detection saves image and Emails notification\n\n", "x": 130, "y": 40, "wires": [] }, { "id": "fb709c2f.9c249", "type": "ui_dropdown", "z": "ca2f6aa3.4cab88", "name": "Set AI Mode", "label": "", "place": "Select option", "group": "94a3dd6.37bb02", "order": 1, "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": "AI/Control/Mode", "x": 130, "y": 120, "wires": [ [ "1c9d9398.26b97c" ] ] }, { "id": "68c301ac.16cfc", "type": "ui_form", "z": "ca2f6aa3.4cab88", "name": "", "label": "WiFi", "group": "bfa1c24d.0ae3d", "order": 3, "width": 0, "height": 0, "options": [ { "label": "SSID", "value": "ssid", "type": "text", "required": true }, { "label": "WPA2 PSK", "value": "psk", "type": "text", "required": true } ], "formValue": { "ssid": "", "psk": "" }, "payload": "", "topic": "", "x": 370, "y": 1260, "wires": [ [ "cfdd42c0.69c2c" ] ] }, { "id": "cfdd42c0.69c2c", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 530, "y": 1260, "wires": [] }, { "id": "946a415e.b53b4", "type": "exec", "z": "ca2f6aa3.4cab88", "command": "kill -2 `pidof python` ; sleep 5 ; sudo /sbin/shutdown -h now", "addpay": true, "append": "", "useSpawn": "false", "timer": "", "oldrc": false, "name": "shutdown", "x": 580, "y": 1140, "wires": [ [], [], [] ] }, { "id": "877ed180.8efef", "type": "ui_button", "z": "ca2f6aa3.4cab88", "name": "", "group": "bfa1c24d.0ae3d", "order": 2, "width": 0, "height": 0, "passthru": false, "label": "", "color": "", "bgcolor": "#83ed7b", "icon": "", "payload": "", "payloadType": "str", "topic": "", "x": 370, "y": 1200, "wires": [ [] ] }, { "id": "8528349f.274af8", "type": "ui_button", "z": "ca2f6aa3.4cab88", "name": "", "group": "b4071f82.0fe78", "order": 2, "width": 0, "height": 0, "passthru": false, "label": "{{msg.payload}}", "color": "", "bgcolor": "#83ed7b", "icon": "", "payload": "", "payloadType": "str", "topic": "", "x": 390, "y": 520, "wires": [ [] ] }, { "id": "bb581e78.08766", "type": "ui_button", "z": "ca2f6aa3.4cab88", "name": "PowerOff", "group": "bfa1c24d.0ae3d", "order": 1, "width": 0, "height": 0, "passthru": false, "label": "Power Off", "color": "", "bgcolor": "#793042", "icon": "", "payload": "", "payloadType": "date", "topic": "", "x": 380, "y": 1140, "wires": [ [ "946a415e.b53b4" ] ] }, { "id": "d36dfaad.6d0bf8", "type": "inject", "z": "ca2f6aa3.4cab88", "name": "Launch AI", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": true, "onceDelay": "0.5", "x": 130, "y": 780, "wires": [ [ "9b61e901.6b2e98" ] ] }, { "id": "9b61e901.6b2e98", "type": "exec", "z": "ca2f6aa3.4cab88", "command": "/home/pi/startAI.sh ", "addpay": false, "append": "", "useSpawn": "false", "timer": "", "oldrc": false, "name": "", "x": 590, "y": 780, "wires": [ [], [], [] ] }, { "id": "9485608d.e47b7", "type": "mqtt in", "z": "ca2f6aa3.4cab88", "name": "AI Status", "topic": "AI/Status", "qos": "2", "broker": "ffdaca5.cbbd038", "x": 100, "y": 860, "wires": [ [ "b8d6667b.c648a8" ] ] }, { "id": "b8d6667b.c648a8", "type": "switch", "z": "ca2f6aa3.4cab88", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "cont", "v": "died", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 290, "y": 860, "wires": [ [ "9b61e901.6b2e98", "f92e9dae.0cd62" ] ] }, { "id": "f92e9dae.0cd62", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 490, "y": 860, "wires": [] }, { "id": "6936adb3.221774", "type": "comment", "z": "ca2f6aa3.4cab88", "name": "WiFi setup, incomplete.", "info": "This is a work in progress.\nplanning to use the command:\n\n# wpa_passphrase \"testing\" \"testingPassword\" >> /etc/wpa_supplicant/wpa_supplicant.conf\n\nBut am having some issues. Obviously it must already be network connected to use this, so its main purpose is to enter the creds on the current network before moving it to the new one.\n", "x": 720, "y": 1260, "wires": [] }, { "id": "3b06a6a3.da246a", "type": "delay", "z": "ca2f6aa3.4cab88", "name": "", "pauseType": "rate", "timeout": "5", "timeoutUnits": "seconds", "rate": "5", "nbRateUnits": "3", "rateUnits": "minute", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": true, "x": 860, "y": 460, "wires": [ [ "ea763542.4e6a18" ] ] }, { "id": "7239e3bb.80aadc", "type": "comment", "z": "ca2f6aa3.4cab88", "name": "SMS is Incomplete", "info": "SMS is incomplete since it needs to talk to an external MQTT Broker in order to send an SMS text message.\n\nI use node-red running on an Android phone with termux-api and it is listening for a message from the Alarmbone MQTT Broker.\n", "x": 1030, "y": 580, "wires": [] }, { "id": "2e3ad1f0.f4effe", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 1010, "y": 880, "wires": [] }, { "id": "be3ad470.0adb98", "type": "rbe", "z": "ca2f6aa3.4cab88", "name": "", "func": "rbe", "gap": "", "start": "", "inout": "out", "property": "payload", "x": 260, "y": 960, "wires": [ [ "f04a9438.1d7dc8" ] ] }, { "id": "a62226d6.1851e8", "type": "mqtt out", "z": "ca2f6aa3.4cab88", "name": "PiCam PIR sensor", "topic": "PIR", "qos": "0", "retain": "", "broker": "56681894.5e53d8", "x": 1090, "y": 940, "wires": [] }, { "id": "e45ce56.8586118", "type": "change", "z": "ca2f6aa3.4cab88", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "Motion", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 780, "y": 940, "wires": [ [ "2e3ad1f0.f4effe", "a62226d6.1851e8" ] ] }, { "id": "71db76fd.e3e8e8", "type": "change", "z": "ca2f6aa3.4cab88", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "Stopped", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 780, "y": 980, "wires": [ [ "2e3ad1f0.f4effe", "a62226d6.1851e8" ] ] }, { "id": "f04a9438.1d7dc8", "type": "trigger", "z": "ca2f6aa3.4cab88", "op1": "1", "op2": "0", "op1type": "num", "op2type": "num", "duration": "10", "extend": true, "units": "s", "reset": "", "bytopic": "all", "name": "", "x": 430, "y": 960, "wires": [ [ "44760ee.63ddaf" ] ] }, { "id": "44760ee.63ddaf", "type": "switch", "z": "ca2f6aa3.4cab88", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "1", "vt": "num" }, { "t": "eq", "v": "0", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 590, "y": 960, "wires": [ [ "e45ce56.8586118" ], [ "71db76fd.e3e8e8" ] ] }, { "id": "7d77050d.adbf8c", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 530, "y": 160, "wires": [] }, { "id": "df020734.9e2ee8", "type": "catch", "z": "ca2f6aa3.4cab88", "name": "", "scope": null, "x": 360, "y": 160, "wires": [ [ "7d77050d.adbf8c" ] ] }, { "id": "d2cc9b1a.f4c718", "type": "rpi-gpio in", "z": "ca2f6aa3.4cab88", "name": "PIR GPIO", "pin": "7", "intype": "down", "debounce": "25", "read": true, "x": 110, "y": 960, "wires": [ [ "be3ad470.0adb98" ] ] }, { "id": "57eec498.24a8bc", "type": "template", "z": "ca2f6aa3.4cab88", "name": "", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "", "output": "str", "x": 940, "y": 640, "wires": [ [ "51e76c3c.e7fde4" ] ] }, { "id": "51e76c3c.e7fde4", "type": "ui_template", "z": "ca2f6aa3.4cab88", "group": "b4071f82.0fe78", "name": "", "order": 1, "width": "6", "height": "6", "format": "
", "storeOutMessages": true, "fwdInMessages": true, "templateScope": "local", "x": 1120, "y": 640, "wires": [ [] ] }, { "id": "4b0676e3.569e78", "type": "base64", "z": "ca2f6aa3.4cab88", "name": "", "action": "str", "property": "payload", "x": 740, "y": 640, "wires": [ [ "57eec498.24a8bc" ] ] }, { "id": "58946705.64f538", "type": "change", "z": "ca2f6aa3.4cab88", "name": "", "rules": [ { "t": "move", "p": "payload", "pt": "msg", "to": "msg.filename", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 410, "y": 640, "wires": [ [ "453e4d8b.81da04" ] ] }, { "id": "453e4d8b.81da04", "type": "file in", "z": "ca2f6aa3.4cab88", "name": "", "filename": "", "format": "", "chunk": false, "sendError": false, "x": 590, "y": 640, "wires": [ [ "4b0676e3.569e78", "e3c47c8b.6aa76" ] ] }, { "id": "e3c47c8b.6aa76", "type": "debug", "z": "ca2f6aa3.4cab88", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "x": 750, "y": 700, "wires": [] }, { "id": "91bb6979.da7098", "type": "mqtt in", "z": "ca2f6aa3.4cab88", "name": "Idle Image", "topic": "IdleImage", "qos": "2", "broker": "ffdaca5.cbbd038", "x": 100, "y": 640, "wires": [ [ "58946705.64f538", "8528349f.274af8" ] ] }, { "id": "ffdaca5.cbbd038", "type": "mqtt-broker", "z": "", "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": "94a3dd6.37bb02", "type": "ui_group", "z": "", "name": " AI Mode", "tab": "b62a69fa.50af48", "order": 1, "disp": true, "width": "6", "collapse": false }, { "id": "bfa1c24d.0ae3d", "type": "ui_group", "z": "", "name": "Setup", "tab": "b62a69fa.50af48", "order": 3, "disp": true, "width": "6", "collapse": true }, { "id": "b4071f82.0fe78", "type": "ui_group", "z": "", "name": "Person Detection", "tab": "b62a69fa.50af48", "order": 2, "disp": true, "width": "7", "collapse": false }, { "id": "56681894.5e53d8", "type": "mqtt-broker", "z": "", "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": "b62a69fa.50af48", "type": "ui_tab", "z": "", "name": "PiCam AI Controller", "icon": "dashboard" } ]