Snapshot (instantanea) desde teclado Telegram.

Cuando iniciamos el bot de Telegram, se crea el teclado desde el cual podemos obtener una instantánea de cualquiera de nuestras camaras ip incluidas en el flujo node red que ejecutamos en nuestra raspberry pi, y al cual accedemos desde Telegram.

[{"id":"a86e4a75.58b618","type":"tab","label":"Snapshot con teclado Telegram","disabled":false,"info":""},{"id":"356cc717.c5e028","type":"telegram sender","z":"a86e4a75.58b618","name":"raspi_foto","bot":"c3dd3387.d10c1","x":1000,"y":400,"wires":[[]]},{"id":"6ba751b1.3a90c","type":"function","z":"a86e4a75.58b618","name":"chatId","func":"msg.payload = { chatId : xxxxxx , type : 'photo' , content : msg.payload }\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":400,"wires":[["356cc717.c5e028"]]},{"id":"bdcd5fc6.4ffed","type":"base64","z":"a86e4a75.58b618","name":"","action":"","property":"payload","x":800,"y":480,"wires":[["cf6825a3.b144c8","8adefbe.8667b08"]]},{"id":"8adefbe.8667b08","type":"image","z":"a86e4a75.58b618","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":false,"active":true,"outputs":0,"x":1020,"y":540,"wires":[]},{"id":"76cec987.e577c8","type":"http request","z":"a86e4a75.58b618","name":"","method":"GET","ret":"bin","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":610,"y":480,"wires":[["bdcd5fc6.4ffed","b940605.7fbada","6ba751b1.3a90c","fb9046f4.a3a2b8"]]},{"id":"7f1f6c03.79cab4","type":"inject","z":"a86e4a75.58b618","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":480,"wires":[["229a12ac.ffebbe"]]},{"id":"b940605.7fbada","type":"function","z":"a86e4a75.58b618","name":"nombre archivo","func":"if(msg.payload === 'undefined' ||  null){return null;}\nvar str = (new Date).toISOString().slice(0,19).replace(/:/g,\"_\");\nmsg.filename = \"/media/pi/KINGSTON/Camaras/\"+msg.carpeta+\"/\" + str;\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":320,"wires":[["3c326e2b.3ca9a2"]]},{"id":"229a12ac.ffebbe","type":"function","z":"a86e4a75.58b618","name":"ip_cam_Fon","func":"msg.url = \"http://ip_camara/snapshot.cgi?user=admin&pwd=xxxxxx\";\nmsg.opcion = \"imagen\";\nmsg.carpeta = \"Fondo\";\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":480,"wires":[["76cec987.e577c8"]]},{"id":"3c326e2b.3ca9a2","type":"file","z":"a86e4a75.58b618","name":"","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":990,"y":320,"wires":[[]]},{"id":"cf6825a3.b144c8","type":"ui_template","z":"a86e4a75.58b618","group":"b7e7a258.d64a6","name":"Display image","order":1,"width":10,"height":7,"format":"<style>\n\nbody.nr-dashboard-theme md-content{\n    background-image: url(\"/home/pi/Santorini.jpg\");\n    background-repeat: no-repeat;\n    background-size: cover;\n}\n#imagen{\n    border: 1px solid blue;\n    border-radius: 8px;\n    padding: 2px;\n    width : 100%;\n    height : 100%;\n}\n\n</style>\n\n<div ng-if=\"msg.opcion=='imagen'\">\n   <img id=imagen src=\"data:image/jpg;base64,{{msg.payload}}\" />\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":955,"y":480,"wires":[[]],"l":false},{"id":"7c5dcb1e.939444","type":"ui_button","z":"a86e4a75.58b618","name":"","group":"b7e7a258.d64a6","order":3,"width":5,"height":1,"passthru":false,"label":"Fondo","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":190,"y":540,"wires":[["229a12ac.ffebbe"]]},{"id":"2d6f2f3d.87c0d","type":"function","z":"a86e4a75.58b618","name":"ip_cam_Com","func":"msg.url = \"http://ip_camara/snapshot.cgi?user=admin&pwd=xxxxxx\";\nmsg.opcion = \"imagen\";\nmsg.carpeta = \"Comedor\";\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":360,"wires":[["76cec987.e577c8"]]},{"id":"6cb1247b.9b206c","type":"inject","z":"a86e4a75.58b618","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":360,"wires":[["2d6f2f3d.87c0d"]]},{"id":"c97ed311.78727","type":"ui_button","z":"a86e4a75.58b618","name":"","group":"b7e7a258.d64a6","order":2,"width":5,"height":1,"passthru":false,"label":"Comedor","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":200,"y":420,"wires":[["2d6f2f3d.87c0d"]]},{"id":"86f24046.f4d9b","type":"function","z":"a86e4a75.58b618","name":"","func":"context.global.foto = {chat_idd : msg.payload.chatId, mens_idd : msg.payload.messageId};\nif(msg.payload.content == \"/start\"){\n   var opts = {\n        resize_keyboard: true,\n        one_time_keyboard: true,\n        reply_markup: JSON.stringify({\n           \"inline_keyboard\": [[\n               {\"text\":\"Foto Comedor\",\"switch_inline_query_current_chat\":\"foto_comedor\"},\n               {\"text\":\"Foto Fondo\",\"switch_inline_query_current_chat\":\"foto_fondo\"}\n            ]]\n       })\n    }\n //   msg.payload.chatId = chat_idd;\n    msg.payload.options = opts;\n}\nelse if(msg.payload.content.includes(\"foto_comedor\")){\n    msg.payload = \"on\";\n    return [null,msg,null];\n}\nelse if(msg.payload.content.includes(\"foto_fondo\")){\n    msg.payload = \"on\";\n    return [null,null,msg];\n}\nelse{msg.payload.content=\"\";}\nreturn [msg,null,null];","outputs":3,"noerr":0,"x":430,"y":260,"wires":[["356cc717.c5e028"],["2d6f2f3d.87c0d"],["229a12ac.ffebbe"]]},{"id":"a5a60dd4.afccb","type":"telegram receiver","z":"a86e4a75.58b618","name":"raspi_foto","bot":"2ec70684.c6e27a","saveDataDir":"","filterCommands":false,"x":200,"y":260,"wires":[["86f24046.f4d9b"],[]]},{"id":"fb9046f4.a3a2b8","type":"ui_template","z":"a86e4a75.58b618","group":"b7e7a258.d64a6","name":"","order":9,"width":0,"height":0,"format":"<script>\n(function($scope) {\n$scope.oldGroupName = 'Camara_ip' // initial group placeholder name\n\n$scope.$watch('msg', function() {\n    if ($scope.msg){\n        $(\"p.nr-dashboard-cardtitle\").each(function(){\n            if($(this).text().trim() == $scope.oldGroupName.trim()){\n                p = $(this);\n                p.text($scope.msg.carpeta);\n                 $scope.oldGroupName = $scope.msg.carpeta\n            }\n        })\n    }\n });\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":800,"y":240,"wires":[[]]},{"id":"c6c329a3.c171f8","type":"comment","z":"a86e4a75.58b618","name":"snapshot camara VstartCam c7837wip","info":"","x":290,"y":160,"wires":[]},{"id":"c3dd3387.d10c1","type":"telegram bot","z":"","botname":"your bot","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},{"id":"b7e7a258.d64a6","type":"ui_group","z":"","name":"Camara_ip","tab":"ac37eb6b.568938","order":1,"disp":true,"width":10,"collapse":false},{"id":"2ec70684.c6e27a","type":"telegram bot","z":"","botname":"your boot","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},{"id":"ac37eb6b.568938","type":"ui_tab","z":"","name":"Snapshot_telegram","icon":"dashboard","order":20,"disabled":false,"hidden":false}]

Flow Info

Created 4 years, 5 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • comment (x1)
  • file (x1)
  • function (x5)
  • http request (x1)
  • inject (x2)
Other

Tags

  • Telegram
  • Function
  • Template
  • File
  • Base64
  • Image
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option