Mit Node-Red kann man schon sehr viele coole Dinge machen, unter anderem Bilder von Webcams via Twitter zu senden. Hab nun eine Möglichkeit gefunden, wie man Bilder von Webcams an Twitter senden kann.
Aussehen könnte es dann wie hier :
Auf Github gibt es das RPI CAM Projekt welches sehr verbreitet und zuverlässig arbeitet, da selbst im Einsatz. https://github.com/silvanmelchior/RPi_Cam_Web_Interface
Die Umsetzung mit Node-Red sieht wie folgt aus :
Erstelle bitte diese Verzeichnisse auf dem lokalen PI “
mkdir /home/pi/webcams mkdir /home/pi/webcams/wohnzimmer/ mkdir /home/pi/webcams/terrasse/ mkdir /home/pi/webcams/zugspitze/
[{"id":"58c8a941.117328","type":"twitter out","z":"3fc7cc64.dce774","twitter":"","name":"Tweet","x":720,"y":409,"wires":[]},{"id":"f7113c6e.db0ac","type":"change","z":"3fc7cc64.dce774","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"Current Photoshoot Inside","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":544,"y":409,"wires":[["58c8a941.117328"]]},{"id":"73e768b7.3a2c08","type":"file in","z":"3fc7cc64.dce774","name":"Read locale Photo","filename":"/home/pi/webcams/wohnzimmer/wohnzimmer.jpg","format":"","x":326,"y":409,"wires":[["f7113c6e.db0ac"]]},{"id":"b4303470.e508f","type":"exec","z":"3fc7cc64.dce774","command":"/usr/bin/raspistill -n -vf -hf -o /home/pi/webcams/wohnzimmer/wohnzimmer.jpg","addpay":false,"append":"","useSpawn":"","timer":"","name":"Take Picture","x":373,"y":534,"wires":[["73e768b7.3a2c08"],[],[]]},{"id":"22f1aec6.e50c2a","type":"inject","z":"3fc7cc64.dce774","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":133,"y":535,"wires":[["b4303470.e508f"]]}]
Der Befehl welcher das Bild aufnimmt ist wie folgt:
„/usr/bin/raspistill -n -vf -hf -o /home/pi/webcams/wohnzimmer/wohnzimmer.jpg“
[{"id":"ab55d8e3.c2c428","type":"twitter out","z":"df8f3282.942358","twitter":"","name":"Tweet","x":807,"y":225,"wires":[]},{"id":"936288c8.1a9cf8","type":"change","z":"df8f3282.942358","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"RPI CAM Photo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":589,"y":225,"wires":[["ab55d8e3.c2c428"]]},{"id":"2dfd5f74.863238","type":"file in","z":"df8f3282.942358","name":"Read Photo from RPI CAM","filename":"/home/pi/webcams/terrasse/terrasse.jpg","format":"","x":328,"y":225,"wires":[["936288c8.1a9cf8"]]},{"id":"45c92e29.8921e","type":"exec","z":"df8f3282.942358","command":"wget -O /home/pi/webcams/terrasse/terrasse.jpg --http-user=username --http-password=\"password\" http://192.168.1.100/cam_pic.php","addpay":false,"append":"","useSpawn":"","timer":"","name":"Take Picture","x":548,"y":366,"wires":[["2dfd5f74.863238"],[],[]]},{"id":"da4f1f72.589df8","type":"inject","z":"df8f3282.942358","name":"","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":false,"x":329,"y":366,"wires":[["45c92e29.8921e"]]}]
Hier der Code für die dritte Lösung, mit folgendem Kommando:
„wget -O /home/pi/webcams/zugspitze/zugspitze.jpg http://www.foto-webcam.eu/webcam/bzb-tal/current/1200.jpg“
[{"id":"44b35bbe.6eabbc","type":"twitter out","z":"3fc7cc64.dce774","twitter":"","name":"Tweet","x":620,"y":1074,"wires":[]},{"id":"720dc56d.835c6c","type":"change","z":"3fc7cc64.dce774","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"Current Photo Zugspitze Copyright http://www.foto-webcam.eu/webcam/bzb-tal/","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":402,"y":1074,"wires":[["44b35bbe.6eabbc"]]},{"id":"8d72afe4.0bf72","type":"file in","z":"3fc7cc64.dce774","name":"Read Photo Zugspitze","filename":"/home/pi/webcams/zugspitze/zugspitze.jpg","format":"","x":200,"y":1074,"wires":[["720dc56d.835c6c"]]},{"id":"643221c6.644ec","type":"exec","z":"3fc7cc64.dce774","command":"wget -O /home/pi/webcams/zugspitze/zugspitze.jpg http://www.foto-webcam.eu/webcam/bzb-tal/current/1200.jpg","addpay":false,"append":"","useSpawn":"","timer":"","name":"Take Picture","x":361,"y":1215,"wires":[["8d72afe4.0bf72"],[],[]]},{"id":"e563ed35.56b098","type":"inject","z":"3fc7cc64.dce774","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":132,"y":1215,"wires":[["643221c6.644ec"]]}]
So das war es schon wieder. Es begeistert mich immer wieder mit Node-Red zu arbeiten und wie einfach es ist eine Implementierung umzusetzen. Das Erfolgserlebnis stellt sich schnell ein und das ist auch was Node-Red so erfolgreich macht. Ich bin kein Programmierer und will es auch nicht sein, denn ich arbeite den lieben langen Arbeitstag schon in hoch komplexen Infrastruktur Umgebungen.
Update 17.01.2017 : Hab eine Erweiterung von weiteren Webcams eingebaut die mit MQTT getriggert werden können. Dh. mit dem Topic „cam“ und der Nachricht „Cam1 / Cam2 / Cam3 usw.“ kann ein aktuelles Bild von der Webcam angefordert werden, welches dann per Twitter publiziert wird.
Der Flow sieht wie folgt aus :
Hier der Code für den Flow:
[{"id":"1ad7aed5.2cf621","type":"debug","z":"2d29490a.5c976e","name":"","active":true,"console":"false","complete":"false","x":560,"y":651,"wires":[]},{"id":"71c051cd.9b6bd8","type":"function","z":"2d29490a.5c976e","name":"Test Function 5","func":"if (msg.payload == \"Cam1\") {\n return [ msg, null, null, null, null ];\n} else if (msg.payload == \"Cam2\") {\n return [ null, msg, null, null, null ];\n} else if (msg.payload == \"Cam3\") {\n return [null, null, msg, null, null];\n} else if (msg.payload == \"Cam4\") {\n return [null, null, null, msg, null];\n} else {\n return [null, null, null, null, msg];\n}\n\n","outputs":"5","noerr":0,"x":116,"y":649,"wires":[["1ad7aed5.2cf621","5a69960e.3d824"],["1ad7aed5.2cf621","286c4c16.6cd804"],["1ad7aed5.2cf621","c9fb1ad0.9e8b48"],["1ad7aed5.2cf621","7a2d19e1.f0ac88"],["1ad7aed5.2cf621","47e11b1a.ff481c"]]},{"id":"d12b6247.c93b78","type":"mqtt in","z":"2d29490a.5c976e","name":"","topic":"cam","qos":"2","broker":"737b2ae7.84f5f4","x":95,"y":531,"wires":[["71c051cd.9b6bd8"]]},{"id":"5a69960e.3d824","type":"exec","z":"2d29490a.5c976e","command":"wget -O /home/pi/webcams/terrasse/terrasse.jpg --http-user=XXXXXX --http-password=\"XXXXX\" http://192.168.1.XXX/cam_pic.php","addpay":false,"append":"","useSpawn":"","timer":"","name":"Take Picture","x":318,"y":452,"wires":[["d7f5fe35.5817d8"],[],[]]},{"id":"286c4c16.6cd804","type":"exec","z":"2d29490a.5c976e","command":"wget -O /home/pi/webcams/noliakameran.net.umea.se/cam1.jpg http://noliakameran.net.umea.se/axis-cgi/jpg/image.cgi","addpay":false,"append":"","useSpawn":"","timer":"20","name":"Take Picture","x":315,"y":371,"wires":[["ec3809b0.83888"],[],[]]},{"id":"c9fb1ad0.9e8b48","type":"exec","z":"2d29490a.5c976e","command":"wget -O /home/pi/webcams/oviso.axiscam.net/cam1.jpg http://oviso.axiscam.net/axis-cgi/jpg/image.cgi ","addpay":false,"append":"","useSpawn":"","timer":"20","name":"Take Picture","x":312,"y":288,"wires":[["5d4bce12.59baf8"],[],[]]},{"id":"7a2d19e1.f0ac88","type":"exec","z":"2d29490a.5c976e","command":"wget -O /home/pi/webcams/saint-petersburg/cam1.jpg http://95.161.181.198/axis-cgi/jpg/image.cgi","addpay":false,"append":"","useSpawn":"","timer":"20","name":"Take Picture","x":303,"y":218,"wires":[["a930adea.c2342"],[],[]]},{"id":"47e11b1a.ff481c","type":"exec","z":"2d29490a.5c976e","command":"wget -O /home/pi/webcams/trcwebcams.org/cam1.jpg http://www.trcwebcams.org/camera11/camera11.jpg","addpay":false,"append":"","useSpawn":"","timer":"20","name":"Take Picture","x":299,"y":150,"wires":[["ac224d39.879a9"],[],[]]},{"id":"d7f5fe35.5817d8","type":"file in","z":"2d29490a.5c976e","name":"Read Photo from RPI CAM","filename":"/home/pi/webcams/terrasse/terrasse.jpg","format":"","x":556,"y":439,"wires":[["f32d56d6.ca175"]]},{"id":"e08533be.b41d68","type":"inject","z":"2d29490a.5c976e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":125,"y":451,"wires":[["5a69960e.3d824"]]},{"id":"2d833449.c35b54","type":"inject","z":"2d29490a.5c976e","name":"","topic":"","payload":"","payloadType":"date","repeat":"7500","crontab":"","once":false,"x":108,"y":371,"wires":[["286c4c16.6cd804"]]},{"id":"ec3809b0.83888","type":"file in","z":"2d29490a.5c976e","name":"Read Photo from CAM 1","filename":"/home/pi/webcams/cam1.jpg","format":"","x":545,"y":358,"wires":[["e65ea678.8bcfe8"]]},{"id":"a246141c.9c5208","type":"inject","z":"2d29490a.5c976e","name":"","topic":"","payload":"","payloadType":"date","repeat":"7200","crontab":"","once":false,"x":112,"y":288,"wires":[["c9fb1ad0.9e8b48"]]},{"id":"5d4bce12.59baf8","type":"file in","z":"2d29490a.5c976e","name":"Read Photo from CAM 2","filename":"/home/pi/webcams/cam2.jpg","format":"","x":543,"y":275,"wires":[["7fc7eba6.ce366c"]]},{"id":"a930adea.c2342","type":"file in","z":"2d29490a.5c976e","name":"Read Photo from CAM 3","filename":"/home/pi/webcams/cam3.jpg","format":"","x":534,"y":205,"wires":[["6058ada2.ad151c"]]},{"id":"62edf082.ff4ea8","type":"inject","z":"2d29490a.5c976e","name":"","topic":"","payload":"","payloadType":"date","repeat":"7200","crontab":"","once":false,"x":103,"y":218,"wires":[["7a2d19e1.f0ac88"]]},{"id":"ac224d39.879a9","type":"file in","z":"2d29490a.5c976e","name":"Read Photo from CAM 4","filename":"/home/pi/webcams/cam4.jpg","format":"","x":530,"y":137,"wires":[["92713ec8.a133c"]]},{"id":"a161007.b73e3","type":"inject","z":"2d29490a.5c976e","name":"","topic":"","payload":"","payloadType":"date","repeat":"7200","crontab":"","once":false,"x":99,"y":150,"wires":[["47e11b1a.ff481c"]]},{"id":"f32d56d6.ca175","type":"change","z":"2d29490a.5c976e","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"RPI CAM ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":822,"y":439,"wires":[["8061116f.9f6a5"]]},{"id":"e65ea678.8bcfe8","type":"change","z":"2d29490a.5c976e","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"http://noliakameran.net.umea.se Cam 1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":812,"y":358,"wires":[["8b32477c.8f8f78"]]},{"id":"7fc7eba6.ce366c","type":"change","z":"2d29490a.5c976e","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"http://oviso.axiscam.net/ Cam 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":802,"y":275,"wires":[["3458e15a.296c0e"]]},{"id":"6058ada2.ad151c","type":"change","z":"2d29490a.5c976e","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"Saint Petersburg City - Cam 3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":793,"y":205,"wires":[["69e37baf.02cd5c"]]},{"id":"92713ec8.a133c","type":"change","z":"2d29490a.5c976e","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"http://www.trcwebcams.org Cam 4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":789,"y":137,"wires":[["976aee37.37a43"]]},{"id":"8061116f.9f6a5","type":"twitter out","z":"2d29490a.5c976e","twitter":"","name":"Tweet","x":1012,"y":439,"wires":[]},{"id":"8b32477c.8f8f78","type":"twitter out","z":"2d29490a.5c976e","twitter":"","name":"Tweet","x":1002,"y":357,"wires":[]},{"id":"3458e15a.296c0e","type":"twitter out","z":"2d29490a.5c976e","twitter":"","name":"Tweet","x":994,"y":275,"wires":[]},{"id":"69e37baf.02cd5c","type":"twitter out","z":"2d29490a.5c976e","twitter":"","name":"Tweet","x":985,"y":205,"wires":[]},{"id":"976aee37.37a43","type":"twitter out","z":"2d29490a.5c976e","twitter":"","name":"Tweet","x":981,"y":137,"wires":[]},{"id":"737b2ae7.84f5f4","type":"mqtt-broker","z":"","broker":"mqtt.unixweb.de","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Hier der Download Link der App für Android Tablet / Smartphone:
https://play.google.com/store/apps/details?id=com.thn.iotmqttdashboard&hl=de
Weiterhin viel Spaß, beim basteln und bei unserem gemeinsamen Hobby wünscht Dir Joachim