Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OWSOO cam in node-red
[{"id":"3f7b63ff.3a829c","type":"ui_dropdown","z":"e653f2e3.c8df6","name":"Select PTZ pos (get)","label":"","place":"PTZ pos (GET)","group":"53f0f46d.556d04","order":13,"width":0,"height":0,"passthru":false,"options":[{"label":"PTZ pos (GET)","value":"None","type":"str"},{"label":"Kitchen window","value":"1","type":"str"},{"label":"Living room sofa","value":"2","type":"str"},{"label":"Living room table","value":"3","type":"str"},{"label":"Kitchen table","value":"4","type":"str"},{"label":"Ceiling","value":"5","type":"str"},{"label":"Basement stairs","value":"6","type":"str"}],"payload":"","topic":"","x":200,"y":751.5,"wires":[["414983e1.bc9fc4","a8feb3d2.81fc78"]]},{"id":"9e25601f.ec9f28","type":"ui_dropdown","z":"e653f2e3.c8df6","name":"Select PTZ pos (set)","label":"","place":"PTZ pos (SET)","group":"53f0f46d.556d04","order":14,"width":0,"height":0,"passthru":false,"options":[{"label":"PTZ pos (SET)","value":"None","type":"str"},{"label":"","value":"1","type":"str"},{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"}],"payload":"","topic":"","x":196,"y":706.5,"wires":[["eda9d3b1.69226","a8feb3d2.81fc78"]]},{"id":"5f9b23d1.004844","type":"http request","z":"e653f2e3.c8df6","name":"","method":"POST","ret":"bin","url":"http://admin:admin@IpCam/tmpfs/auto.jpg","tls":"","x":643,"y":936.5,"wires":[["f18b5f6e.f976a"]]},{"id":"b4a22a79.385868","type":"template","z":"e653f2e3.c8df6","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img width=\"305px\" height=\"185px\" src=\"data:image/jpg;base64,{{{payload}}}\">","output":"str","x":939.125,"y":936.125,"wires":[["ec7304ae.b2d238"]]},{"id":"ec7304ae.b2d238","type":"ui_template","z":"e653f2e3.c8df6","group":"fb750ce.a1001f","name":"","order":3,"width":"6","height":"4","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1069.875,"y":935.875,"wires":[[]]},{"id":"f18b5f6e.f976a","type":"base64","z":"e653f2e3.c8df6","name":"","action":"str","property":"payload","x":803.625,"y":936.125,"wires":[["b4a22a79.385868"]]},{"id":"8fa7b2ac.706da8","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":4,"width":"2","height":"1","passthru":false,"label":"Up","color":"","bgcolor":"","icon":"","payload":"up","payloadType":"str","topic":"","x":238.66071319580078,"y":523.3035259246826,"wires":[["1c39fd64.6001e3"]]},{"id":"c34ab2e7.979e08","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":5,"width":"2","height":"1","passthru":false,"label":"Down","color":"","bgcolor":"","icon":"","payload":"down","payloadType":"str","topic":"","x":238.875,"y":559.875,"wires":[["1c39fd64.6001e3"]]},{"id":"8c060c7b.5e5018","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":7,"width":"4","height":"1","passthru":false,"label":"Left","color":"","bgcolor":"","icon":"","payload":"left","payloadType":"str","topic":"","x":237.875,"y":667.875,"wires":[["1c39fd64.6001e3"]]},{"id":"2e531baa.cdd32c","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":8,"width":"4","height":"1","passthru":false,"label":"Right","color":"","bgcolor":"","icon":"","payload":"right","payloadType":"str","topic":"","x":238.875,"y":631.875,"wires":[["1c39fd64.6001e3"]]},{"id":"dc3e02db.2d6d2","type":"delay","z":"e653f2e3.c8df6","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":786.6250610351562,"y":594.375,"wires":[["5f9b23d1.004844","58f0b71.9a0dfc8"]]},{"id":"d1da5f00.c5e298","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":6,"width":"2","height":"1","passthru":false,"label":"Home","color":"","bgcolor":"","icon":"","payload":"home","payloadType":"str","topic":"","x":239.875,"y":595.625,"wires":[["1c39fd64.6001e3"]]},{"id":"414983e1.bc9fc4","type":"function","z":"e653f2e3.c8df6","name":"","func":"var cam1ip = flow.get(\"Cam1Ip\")|| \"\";\nvar pos = msg.payload;\nvar newMsg1 = { payload : \"'http://admin:admin@\"+cam1ip+\"/web/cgi-bin/hi3510/preset.cgi?-act=goto&-number=\"+pos+\"'\" };\nvar cam1ip = \"10.147.20.85\";\nvar cam1port = \"1811\";\nvar newMsg2 = { method: \"GET\", url: \"http://admin:admin@\"+cam1ip+\":\"+cam1port+\"/web/cgi-bin/hi3510/preset.cgi?-act=goto&-number=\"+pos };\nnode.send ([newMsg1,newMsg2]);\n","outputs":2,"noerr":0,"x":393.5,"y":752,"wires":[["7e468801.b8bca"],["cdf50df2.ef28d8"]]},{"id":"eda9d3b1.69226","type":"function","z":"e653f2e3.c8df6","name":"","func":"var cam1ip = flow.get(\"Cam1Ip\")|| \"\";\nvar cmnd = msg.payload;\nvar newMsg1 = { payload : \"'http://admin:admin@\"+cam1ip+\"/web/cgi-bin/hi3510/preset.cgi?-act=set&-status=1&-number=\"+cmnd+\"'\" };\nvar cam1ip = \"10.147.20.85\";\nvar cam1port = \"1811\";\nvar newMsg = { method: \"GET\", url: \"http://admin:admin@\"+cam1ip+\":\"+cam1port+\"/web/cgi-bin/hi3510/preset.cgi?-act=set&-status=1&-number=\"+cmnd };\nnode.send ([newMsg1,newMsg]);\n","outputs":2,"noerr":0,"x":390,"y":706.5,"wires":[["7e468801.b8bca"],["cdf50df2.ef28d8"]]},{"id":"db85b4c5.5b0d7","type":"inject","z":"e653f2e3.c8df6","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":true,"x":78.57147216796875,"y":533.7857971191406,"wires":[["52b158d6.d37e6","514b2246.9acabc","9e25601f.ec9f28","3f7b63ff.3a829c"]]},{"id":"52b158d6.d37e6","type":"function","z":"e653f2e3.c8df6","name":"KkMoon1 Ip","func":"var KkMoonIp1=global.get('mySettings.kkmoonip1');\nif (KkMoonIp1===undefined)\n{\n KkMoonIp1 = \"192.168.3.170\";\n}\nnode.status({fill:\"blue\",shape:\"ring\",text:\"KkMoonIp1: \"+KkMoonIp1});\nmsg.payload=KkMoonIp1;\nreturn msg;\n","outputs":1,"noerr":0,"x":341.57147216796875,"y":341.5357666015625,"wires":[["98715867.333608"]]},{"id":"98715867.333608","type":"function","z":"e653f2e3.c8df6","name":"Set Cam1 Ip","func":"flow.set(\"Cam1Ip\", msg.payload);\n","outputs":1,"noerr":0,"x":505.14288330078125,"y":341.357177734375,"wires":[[]]},{"id":"eb5548fe.17856","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":11,"width":0,"height":0,"passthru":false,"label":"Save","color":"","bgcolor":"","icon":"","payload":"Cam1Ip","payloadType":"flow","topic":"","x":206.00001525878906,"y":1113.357177734375,"wires":[["1ea8eb14.533425"]]},{"id":"1ea8eb14.533425","type":"function","z":"e653f2e3.c8df6","name":"Save mySettings","func":"global.set(\"mySettings.kkmoonip1\",msg.payload);\nmsg.payload=\"module.exports = \"+JSON.stringify(global.get(\"mySettings\"));\nreturn msg;\n","outputs":1,"noerr":0,"x":375.2857666015625,"y":1113.5,"wires":[["c2f7d2c6.96ee4"]]},{"id":"c2f7d2c6.96ee4","type":"file","z":"e653f2e3.c8df6","name":"~/.node-red/redvars.js","filename":"/home/gerardo/.node-red/redvars.js","appendNewline":false,"createDir":false,"overwriteFile":"true","x":585.2857666015625,"y":1113.5,"wires":[]},{"id":"1c39fd64.6001e3","type":"function","z":"e653f2e3.c8df6","name":"","func":"var cam1ip = flow.get(\"Cam1Ip\")|| \"\";\nvar cmnd = msg.payload;\nvar newMsg1 = { payload : \"'http://admin:admin@\"+cam1ip+\"/web/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=\"+cmnd+\"&-speed=45'\" };\nvar cam1ip = \"10.147.20.85\";\nvar cam1port = \"1811\";\nvar newMsg2 = { method: \"GET\", url: \"http://admin:admin@\"+cam1ip+\":\"+cam1port+\"/web/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=\"+cmnd+\"&-speed=45\" };\nnode.send ([newMsg1,newMsg2]);\n","outputs":2,"noerr":0,"x":424.25006103515625,"y":595.7499389648438,"wires":[["7e468801.b8bca"],["cdf50df2.ef28d8"]]},{"id":"6ff3ea0a.aeda7c","type":"function","z":"e653f2e3.c8df6","name":"","func":"var cam1ip = flow.get(\"Cam1Ip\")|| \"\";\nvar action = msg.payload;\nif (action !== \"None\")\n{\n msg.payload = \"'http://admin:admin@\"+cam1ip+\"/web/cgi-bin/hi3510/param.cgi?cmd=setinfrared&-infraredstat=\"+action+\"'\";\n var cam1ip = \"10.147.20.85\";\n var cam1port = \"1811\";\n var newMsg = { method: \"GET\", url: \"http://admin:admin@\"+cam1ip+\":\"+cam1port+\"/web/cgi-bin/hi3510/param.cgi?cmd=setinfrared&-infraredstat=\"+action };\n node.send ([msg, newMsg]);\n}\n","outputs":2,"noerr":0,"x":430.25,"y":466.75,"wires":[["7e468801.b8bca"],["cdf50df2.ef28d8"]]},{"id":"7e468801.b8bca","type":"function","z":"e653f2e3.c8df6","name":"","func":"var newPayload = \"curl \"+msg.payload+\" -o /mnt/usb/curl_result_log.txt 2>/dev/null\"\nvar newMsg = { topic: \"gvf/to_petin/sendcmd\", payload: newPayload };\nnode.send(newMsg);\nnewMsg = { topic: \"mcc/to_petin/sendcmd\", payload: newPayload };\nnode.send(newMsg);\n","outputs":1,"noerr":0,"x":594.375,"y":596.625,"wires":[["6519f23d.b3f6a4","dc3e02db.2d6d2"]]},{"id":"96bef1b0.a0347","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":1,"width":0,"height":0,"passthru":false,"label":"Refresh Image","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":139,"y":937.5,"wires":[["a08592d3.068f2"]]},{"id":"6519f23d.b3f6a4","type":"link out","z":"e653f2e3.c8df6","name":"","links":["33626eaf.973a2a","37bdc31c.f07d84"],"x":1150.2501220703125,"y":371,"wires":[]},{"id":"d04171ff.560738","type":"function","z":"e653f2e3.c8df6","name":"Set Device to None","func":"var newMsg = { topic: \"\", payload: \"None\" };\nreturn newMsg;\n","outputs":1,"noerr":0,"x":151,"y":803,"wires":[["3f7b63ff.3a829c","9e25601f.ec9f28"]]},{"id":"a8feb3d2.81fc78","type":"trigger","z":"e653f2e3.c8df6","op1":"None","op2":"None","op1type":"str","op2type":"str","duration":"15","extend":false,"units":"s","reset":"","name":"","x":265.11670303344727,"y":866.7499599456787,"wires":[["d04171ff.560738"]]},{"id":"cdf50df2.ef28d8","type":"http request","z":"e653f2e3.c8df6","name":"Send HTTP Cmnd","method":"use","ret":"txt","url":"","tls":"","x":730,"y":644,"wires":[[]]},{"id":"514b2246.9acabc","type":"ui_button","z":"e653f2e3.c8df6","name":"","group":"fb750ce.a1001f","order":9,"width":0,"height":0,"passthru":false,"label":"Get Infrared","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":171,"y":391,"wires":[["3dc6859c.c58252"]]},{"id":"3dc6859c.c58252","type":"http request","z":"e653f2e3.c8df6","name":"","method":"GET","ret":"txt","url":"http://admin:admin@IpCam/cgi-bin/hi3510/param.cgi?cmd=getinfrared","tls":"","x":347,"y":392,"wires":[["db28d2d2.f3b828"]]},{"id":"db28d2d2.f3b828","type":"function","z":"e653f2e3.c8df6","name":"","func":"var auxStr = \"var infraredstat=\";\nvar szString = msg.payload.trim();\nvar n = szString.indexOf(auxStr);\nif (n===0)\n{\n var len = szString.length;\n var newMsg = { payload: szString.substring(auxStr.length +1, len -2) };\n node.send(newMsg);\n}","outputs":1,"noerr":0,"x":548,"y":396,"wires":[["55e82811.d62aa8","dc3e02db.2d6d2"]]},{"id":"55e82811.d62aa8","type":"ui_dropdown","z":"e653f2e3.c8df6","name":"Select IR state","label":"","place":"Select IR state","group":"fb750ce.a1001f","order":10,"width":0,"height":0,"passthru":false,"options":[{"label":"Select IR state","value":"None","type":"str"},{"label":"Auto","value":"auto","type":"str"},{"label":"On","value":"open","type":"str"},{"label":"Off","value":"close","type":"str"}],"payload":"","topic":"","x":269,"y":466,"wires":[["6ff3ea0a.aeda7c"]]},{"id":"d690300d.646aa","type":"trigger","z":"e653f2e3.c8df6","op1":"","op2":"false","op1type":"nul","op2type":"bool","duration":"5","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":369,"y":937,"wires":[["a08592d3.068f2"]]},{"id":"a08592d3.068f2","type":"ui_switch","z":"e653f2e3.c8df6","name":"","label":"Enable Cam update","group":"fb750ce.a1001f","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"gate","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":309,"y":997,"wires":[["77653a41.749ca4","d690300d.646aa"]]},{"id":"77653a41.749ca4","type":"function","z":"e653f2e3.c8df6","name":"control","func":"if (msg.topic === \"gate\") {\n context.pass = (msg.payload === true) ? true : false;\n return null; // exit out early as it's just the control\n}\nif (context.pass) {\n return msg; // if enabled pass msg\n}\nreturn null; // or drop it","outputs":1,"noerr":0,"x":504,"y":1026,"wires":[["5f9b23d1.004844"]]},{"id":"4c7803a4.89659c","type":"inject","z":"e653f2e3.c8df6","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"10","crontab":"","once":false,"onceDelay":"","x":261.5,"y":1059,"wires":[["77653a41.749ca4"]]},{"id":"153a9864.bf1f38","type":"inject","z":"e653f2e3.c8df6","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":"","x":106,"y":1009,"wires":[["a08592d3.068f2"]]},{"id":"58f0b71.9a0dfc8","type":"function","z":"e653f2e3.c8df6","name":"","func":"var newMsg = { payload: true };\nnode.send(newMsg);\n","outputs":1,"noerr":0,"x":608,"y":758,"wires":[["a08592d3.068f2"]]},{"id":"53f0f46d.556d04","type":"ui_group","z":"","name":"PTZ","tab":"40b3f722.3328d8","order":3,"disp":true,"width":"8","collapse":false},{"id":"fb750ce.a1001f","type":"ui_group","z":"","name":"KkMoon1","tab":"40b3f722.3328d8","order":2,"disp":true,"width":"8","collapse":false},{"id":"40b3f722.3328d8","type":"ui_tab","z":"","name":"Petin","icon":"dashboard","order":5}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.