So, I found some time today, so here is a bit more detail.
Code: Select all
[{"id":"34f442bf.3ae45e","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"6c8a1442.f4537c","type":"debug","z":"34f442bf.3ae45e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":690,"y":200,"wires":[]},{"id":"fb9d0ad8.f7c7a8","type":"file in","z":"34f442bf.3ae45e","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":790,"y":80,"wires":[["bcfc2591.afcca8"]]},{"id":"bcfc2591.afcca8","type":"object-detector","z":"34f442bf.3ae45e","service":"672f334e.0e285c","method":"predict","passthrough":false,"annotated_input":"","predict_body":"","predict_bodyType":"str","predict_threshold":"0.7","predict_thresholdType":"str","name":"","x":240,"y":200,"wires":[["8fab9227.913ea"]]},{"id":"2377db36.2d3734","type":"function","z":"34f442bf.3ae45e","name":"filename","func":"msg.payload = msg.filename\nreturn msg;","outputs":1,"noerr":0,"x":640,"y":80,"wires":[["fb9d0ad8.f7c7a8"]]},{"id":"a309922b.de5ab","type":"watch-directory","z":"34f442bf.3ae45e","folder":"/Terasse","recursive":false,"typeEvent":"create","ignoreInitial":true,"ignoredFiles":"","name":"","x":120,"y":40,"wires":[["b84e224a.968b5"]]},{"id":"80b2f20f.5ef65","type":"watch-directory","z":"34f442bf.3ae45e","folder":"/Einfahrt_hinten","recursive":false,"typeEvent":"create","ignoreInitial":true,"ignoredFiles":"","name":"","x":140,"y":100,"wires":[["496acaa4.9e36e4"]]},{"id":"8fab9227.913ea","type":"function","z":"34f442bf.3ae45e","name":"Filter","func":"var excl = \n[\n\"bird\",\n\"tv\",\n\"chair\",\n\"book\"\n]\n\nvar x = excl.includes(msg.payload)\nif (x === false && msg.payload !== null)\n\n\n{\nreturn msg;\n}","outputs":1,"noerr":0,"x":490,"y":200,"wires":[["6c8a1442.f4537c","724b1aa8.96c6a4","b6a77532.05a598"]]},{"id":"724b1aa8.96c6a4","type":"function","z":"34f442bf.3ae45e","name":"Domoticz message","func":" msg.payload = {\n \"command\": \"sendnotification\",\n \"subject\": \"Object Detection\",\n \"body\": msg.filedir.replace(\"/\", \"\") + \" \" + msg.payload + \" detected\",\n \"priority\": 0}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":640,"y":300,"wires":[["f45dd354.078c2"]]},{"id":"f45dd354.078c2","type":"mqtt out","z":"34f442bf.3ae45e","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"d04b4d92.652e5","x":810,"y":300,"wires":[]},{"id":"b6a77532.05a598","type":"function","z":"34f442bf.3ae45e","name":"Send the snapshot","func":"// sendMediaGroup example: send between 2 and 10 media.\n// Note that type can also be video.\n// and the caption property is optional.\n// see https://core.telegram.org/bots/api#inputmediaphoto\n// see https://core.telegram.org/bots/api#inputmediavideo\nmsg.payload = {}\nmsg.payload.chatId = \"-1001452905938\"\nmsg.payload.type = \"mediaGroup\";\nmsg.payload.content = [\n {\n type : \"photo\",\n media : msg.filename,\n caption : \"Snapshot\"\n }\n];\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":380,"wires":[["89d22f2a.402b7"]]},{"id":"89d22f2a.402b7","type":"telegram sender","z":"34f442bf.3ae45e","name":"","bot":"b416a6a4.700ef8","x":850,"y":380,"wires":[[]]},{"id":"84f0761e.89b638","type":"inject","z":"34f442bf.3ae45e","name":"","topic":"","payload":"{\"command\":\"getdeviceinfo\",\"idx\":374}","payloadType":"json","repeat":"1800","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":460,"wires":[["586c6c8e.cee2f4"]]},{"id":"586c6c8e.cee2f4","type":"mqtt out","z":"34f442bf.3ae45e","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"d04b4d92.652e5","x":350,"y":460,"wires":[]},{"id":"34dac0e5.35db5","type":"mqtt in","z":"34f442bf.3ae45e","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"d04b4d92.652e5","x":140,"y":540,"wires":[["bc102314.a634a"]]},{"id":"78279b44.fc6484","type":"debug","z":"34f442bf.3ae45e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":540,"wires":[]},{"id":"bc102314.a634a","type":"json","z":"34f442bf.3ae45e","name":"","property":"payload","action":"","pretty":false,"x":330,"y":540,"wires":[["618f634c.0fe2ec"]]},{"id":"618f634c.0fe2ec","type":"function","z":"34f442bf.3ae45e","name":"","func":"if(msg.payload.idx == 374)\n{\nflow.set(\"CamTerasse\", msg.payload.nvalue)\n\n}\nif(msg.payload.idx == 375)\n{\nflow.set(\"CamPool\", msg.payload.nvalue)\n\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":540,"wires":[[]]},{"id":"b84e224a.968b5","type":"function","z":"34f442bf.3ae45e","name":"Switch","func":"var on = flow.get(\"CamTerasse\")||0\nif (on == 1)\n{\nreturn msg;\n}","outputs":1,"noerr":0,"x":390,"y":40,"wires":[["2377db36.2d3734"]]},{"id":"496acaa4.9e36e4","type":"function","z":"34f442bf.3ae45e","name":"Switch","func":"var on = flow.get(\"CamPool\")||0\nif (on == 1)\n{\nreturn msg;\n}","outputs":1,"noerr":0,"x":390,"y":100,"wires":[["2377db36.2d3734"]]},{"id":"672f334e.0e285c","type":"object-detector-service","z":"","host":"http://192.168.2.11:5011","name":"TBADS"},{"id":"d04b4d92.652e5","type":"mqtt-broker","z":"","name":"Controlberry","broker":"192.168.2.40","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b416a6a4.700ef8","type":"telegram bot","z":"","botname":"TBA.Domoticz","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]
as for the object detection, you may need to choose not the latest image but a previous one, due to restrictions in the processors command set. start with a high version and if you get an error running it, work your way down.
Configure your cams to upload pics to a directory on the synology upon motion detection. I am using FTP for that, as my cameras all support that.
it will upload a lot of stuff but only those with detected objects will give you a notification.
during testing you may need to adjust the function node named 'filter' to rule out those objects you don't want.
I did it 'trial and error'.