Node-RED und IFTTT

Q: Ich bin gerade dabei das Tutorial über Node-RED und IFTTT durchzuarbeiten.
Nur leider hänge ich bei dem Punkt: IFTTT - Kontakt zu einem Node-RED-Endpunkt. Bei der Ausführung bekomme ich die Error Meldungen: "IFTTT Read error" und "SyntaxError: Unexpected token o in JSON at position 1" Leider bin ich noch ein absoluter Anfänger in Node-Red, hoffe aber dass ihr mir weiterhelfen könnt.

Mike Polinowski
INSTAR MQTT
Firmware Update
Full HD Serie
INSTAR Deutschland GmbH
INSTAR MQTT

Machen Sie Ihrer Kamera zum Herzstück Ihres Smarthomes

INSTAR MQTT Support

Mithilfe der MQTT Schnittstelle Ihrer INSTAR Full HD Kameras können Sie diese zu einem bestehenden Smarthome-System (Home Assistant, OpenHAB, Node-RED, Athom Homey, Homematic, ioBroker, Loxone, homee) hinzufügen kann. Oder auch zum Haupt-Broker für Ihre MQTT Sensoren machen. MQTT ermöglicht es Ihnen ALLE Funktionen Ihrer Kamera zu automatisieren und mit anderen Diensten in Ihrem Smarthome zu verknüpfen.

Mike Polinowski
IFTTT Applets
Firmware Update
Full HD Serie
INSTAR Cloud
INSTAR Deutschland GmbH
INSTAR IFTTT Applets

Kontrollieren Sie Ihre Kamera über den IFTTT Online Dienst

INSTAR IFTTT Support

Auf der IFTTT-Plattform stellten wir einen Dienst namens INSTAR zur Verfügung. Die INSTAR Applets bieten Ihnen die Möglichkeit, einige Einstellungen Ihrer INSTAR Kamera oder INSTAR Cloud mit IFTTT zu steuern. Sie können INSTAR mit Auslösern für Ort (Geo Location) und Datum & Zeit verbinden, Benachrichtigungen versenden und vieles mehr. Zum Beispiel können Sie die INSTAR Applets mit dem IFTTT-Ortungsdienst verbinden und automatisch den Alarm deaktivieren lassen, wenn Sie zu Hause ankommen. Sie können die INSTAR-Applets auch verwenden, um Ihre eigene Automatisierung zu erstellen und sie mit anderen Applets von Drittanbietern zu verbinden.

A: Starten Sie zuerst mit dem Import der folgenden Node-RED Sequenz:

INSTAR Camera Control with Node-RED and IFTTT

[{"id":"b494a047.b16e1","type":"inject","z":"7daa2c74.0caa74","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":90,"y":60,"wires":[["dd733d09.e62"]]},{"id":"dd733d09.e62","type":"ifttt out","z":"7daa2c74.0caa74","eventName":"ifttt_webhook","key":"ed06780a.3466e8","x":234,"y":60,"wires":[]},{"id":"5ab42578.62ff9c","type":"http in","z":"7daa2c74.0caa74","name":"IFTTT POST Trigger","url":"/pushalarm/post/trigger/recording","method":"post","upload":false,"swaggerDoc":"","x":110,"y":160,"wires":[["6bc5487e.e34b78","6723978.979e168"]]},{"id":"6bc5487e.e34b78","type":"http response","z":"7daa2c74.0caa74","name":"Webhook","statusCode":"","headers":{"content-type":"application/json"},"x":296,"y":161,"wires":[]},{"id":"6723978.979e168","type":"debug","z":"7daa2c74.0caa74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":310,"y":120,"wires":[]},{"id":"1fc3d4d.88f2a2b","type":"http in","z":"7daa2c74.0caa74","name":"IFTTT GET Trigger","url":"/pushalarm/get/trigger/recording","method":"get","upload":false,"swaggerDoc":"","x":110,"y":280,"wires":[["28ef78be.5ac678","725de5ab.46260c"]]},{"id":"28ef78be.5ac678","type":"http response","z":"7daa2c74.0caa74","name":"Webhook","statusCode":"","headers":{"content-type":"application/json"},"x":296,"y":281,"wires":[]},{"id":"725de5ab.46260c","type":"debug","z":"7daa2c74.0caa74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":310,"y":240,"wires":[]},{"id":"ed06780a.3466e8","type":"ifttt-key","z":""}]

Diese hat einen Inject-Node zum Auslösen eines IFTTT Webhooks mit dem Event Name ifttt_webhook - den wir später in der IFTTT Oberfläche anlegen müssen (die Benennung hier ist beliebig):

INSTAR Camera Control with Node-RED and IFTTT

Vergessen Sie hier nicht Ihren IFTTT API Key zu hinterlegen, den Sie in Ihrem IFTTT Account Einstellungen nachschauen kkönnen.

Im folgenden haben wir zwei Webhooks in Node-RED angelegt - einen für einen POST und einen für einen GET Request. Ob IFTTT POST oder GET verwendet können Sie später in der IFTTT Konfiguration festlegen. Wir werden hier erstmal beides testen und später entscheiden, welchen wir nehmen wollen.

INSTAR Camera Control with Node-RED and IFTTT

Der POST Webhook hat die URL /pushalarm/post/trigger/recording - dass bedeutet wenn Sie ihn im lokalen Netzwerk aufrufen wollen, müssten Sie einen POST Request an http://IP-der-Node-RED-Installation:1880/pushalarm/post/trigger/recording senden. Dies funktioniert nur im lokalen Netzwerk. Für IFTTT müssen Sie entsprechend einen DDNS Adresse - z.B. von einer INSTAR IP Kamera im gleichen Netzwerk - anstatt der lokalen IP Adresse von Node-RED verwenden und es muß ein (externer) Port auf den internen Port Ihrer Node-RED Installation durchgeleitet werden:

INSTAR Camera Control with Node-RED and IFTTT

Sie können hier direkt den Port 1880 durchleiten oder als externen Port einen anderen wählen.

INSTAR Camera Control with Node-RED and IFTTT

Der POST Webhook hat die URL /pushalarm/get/trigger/recording - dass bedeutet wenn Sie ihn im lokalen Netzwerk aufrufen wollen, können Sie einen diese URL http://IP-der-Node-RED-Installation:1880/pushalarm/get/trigger/recording direkt in Ihrem Browser aufrufen. Sie werden hier eine leere JSON Antwort {} erhalten, wenn alles richtig konfiguriert ist.

INSTAR Camera Control with Node-RED and IFTTT

Diese leere Antwort wird in dem als Webhook benannten HTTP Response Node erzeugt. Sie können hier alles leer lassen.

INSTAR Camera Control with Node-RED and IFTTT

Für den POST Request müssen Sie den Webhook in IFTTT wie folgt anlegen (das Beispiel nutzt die DDNS Adresse einer AVM Fritzbox - hier kann genauso eine INSTAR DDNS Adresse verwendet werden). Der hier verwendete Port - abgetrennt durch einen Doppelpunkt von der DDNS Adresse - muß dem Port entsprechen, den Sie in Ihrem Router auf die Node-RED Installation durchgeleitet haben.

Sie sehen, dass wir hier als Body den JSON Ausdruck {"val":"on"} mitgeben. Diesen möchten wir später zum Einschalten der Bewegungserkennungs-Bereiche nutzen.

INSTAR Camera Control with Node-RED and IFTTT

Für den GET Request wählen Sie einfach GET als Methode aus und ändern Sie das post zu einem get in der URL die aufgerufen werden soll.

INSTAR Camera Control with Node-RED and IFTTT

Sie können den IFTT Webhook jetzt testen, indem Sie die folgende URL aufrufen https://maker.ifttt.com/trigger/ifttt_webhook/with/key/c3oL9WnAbz8Z08KumJWS. Hierbei ist ifttt_webhook der Name den wir dem Webhook gegeben haben und c3oL9WnAbz8Z08KumJWS Ihr persönlicher IFTTT API Schlüssel (sehr wichtig - geben Sie diesen Schlüssel nicht an Dritte weiter. Er ermöglicht Zugriff auf alle Webhooks, die Sie in IFTTT anlegen.)

INSTAR Camera Control with Node-RED and IFTTT

Alternativ können Sie auch den node-red-contrib-ifttt Node in der Node-RED Sequenz anstoßen, um den Webhook zu kontaktieren.

INSTAR Camera Control with Node-RED and IFTTT

Jetzt zu etwas praktischen. Kopieren Sie den folgenden Flow in Ihre Node-RED installation:

[{"id":"ead56e0c.9001","type":"http in","z":"7daa2c74.0caa74","name":"IFTTT Trigger","url":"/alarm/md/areas","method":"post","upload":false,"swaggerDoc":"","x":150,"y":539,"wires":[["db2cbc36.5d91e","6664558a.f6708c","dbe8067d.bb8a28"]]},{"id":"db2cbc36.5d91e","type":"http response","z":"7daa2c74.0caa74","name":"Webhook","statusCode":"","headers":{"content-type":"application/json"},"x":300,"y":500,"wires":[]},{"id":"ed404972.3504d8","type":"function","z":"7daa2c74.0caa74","name":"Enable Area 1","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 1\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=1&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":390,"wires":[["c2d5879e.abb308"]]},{"id":"2e3134ea.2896bc","type":"function","z":"7daa2c74.0caa74","name":"Disable Area 1","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 1\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=1&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":570,"wires":[["23d3f1c2.2207de"]]},{"id":"23d3f1c2.2207de","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":570,"wires":[["ae6b249f.2bd9b8"]]},{"id":"c2d5879e.abb308","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":390,"wires":[["d214ac4.329e15"]]},{"id":"ae6b249f.2bd9b8","type":"http request","z":"7daa2c74.0caa74","name":"m1_disable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":570,"wires":[["e46d691e.6c1a68"]]},{"id":"d214ac4.329e15","type":"http request","z":"7daa2c74.0caa74","name":"m1_enable","method":"GET","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":834,"y":390,"wires":[["e46d691e.6c1a68"]]},{"id":"6664558a.f6708c","type":"switch","z":"7daa2c74.0caa74","name":"Push","property":"payload.val","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":330,"y":539,"wires":[["ed404972.3504d8","3ceb937e.88f20c","96be2992.947a38","93c60eb7.d9497"],["2e3134ea.2896bc","e3f362a8.041ef","26ac4b9c.4632e4","ed93967b.79c908"]]},{"id":"e46d691e.6c1a68","type":"debug","z":"7daa2c74.0caa74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1039,"y":538,"wires":[]},{"id":"3ceb937e.88f20c","type":"function","z":"7daa2c74.0caa74","name":"Enable Area 2","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 2\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=2&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":432,"wires":[["98144281.8d951"]]},{"id":"98144281.8d951","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":432,"wires":[["c7bfd8c6.b8f6e8"]]},{"id":"c7bfd8c6.b8f6e8","type":"http request","z":"7daa2c74.0caa74","name":"m1_enable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":432,"wires":[["e46d691e.6c1a68"]]},{"id":"96be2992.947a38","type":"function","z":"7daa2c74.0caa74","name":"Enable Area 3","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 3\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=3&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":472,"wires":[["a4c727eb.e93508"]]},{"id":"a4c727eb.e93508","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":472,"wires":[["6cb7cabe.3103d4"]]},{"id":"6cb7cabe.3103d4","type":"http request","z":"7daa2c74.0caa74","name":"m1_enable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":472,"wires":[["e46d691e.6c1a68"]]},{"id":"93c60eb7.d9497","type":"function","z":"7daa2c74.0caa74","name":"Enable Area 4","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 4\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=4&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":512,"wires":[["d3c05e5.8e40da"]]},{"id":"d3c05e5.8e40da","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":512,"wires":[["bd3b3647.c5a998"]]},{"id":"bd3b3647.c5a998","type":"http request","z":"7daa2c74.0caa74","name":"m1_enable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":512,"wires":[["e46d691e.6c1a68"]]},{"id":"e3f362a8.041ef","type":"function","z":"7daa2c74.0caa74","name":"Disable Area 2","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 2\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=2&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":612,"wires":[["9e948381.1b5bf"]]},{"id":"9e948381.1b5bf","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":612,"wires":[["758ed212.5c8c6c"]]},{"id":"758ed212.5c8c6c","type":"http request","z":"7daa2c74.0caa74","name":"m1_disable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":612,"wires":[["e46d691e.6c1a68"]]},{"id":"26ac4b9c.4632e4","type":"function","z":"7daa2c74.0caa74","name":"Disable Area 3","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 3\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=3&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":652,"wires":[["b6569fcb.32091"]]},{"id":"b6569fcb.32091","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":652,"wires":[["6676cfed.b231"]]},{"id":"6676cfed.b231","type":"http request","z":"7daa2c74.0caa74","name":"m1_disable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":652,"wires":[["e46d691e.6c1a68"]]},{"id":"ed93967b.79c908","type":"function","z":"7daa2c74.0caa74","name":"Disable Area 4","func":"var ip = \"192.168.2.165\";\nvar user = \"admin\";\nvar password = \"instar\";\n\n// Update the status with current timestamp\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\nvar currenttime= hh + \":\" + mmm + \":\" + ss;\nvar currentdate= dd + \".\" + mm + \".\" + yyyy;\n\nnode.status({fill:\"blue\",shape:\"ring\",text:\"Last updateChanged: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"area 4\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=4&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":535,"y":692,"wires":[["ed9704cc.f69a18"]]},{"id":"ed9704cc.f69a18","type":"change","z":"7daa2c74.0caa74","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":692,"wires":[["bd53e77a.f197f8"]]},{"id":"bd53e77a.f197f8","type":"http request","z":"7daa2c74.0caa74","name":"m1_disable","method":"GET","ret":"txt","url":"","tls":"","x":834,"y":692,"wires":[["e46d691e.6c1a68"]]},{"id":"dbe8067d.bb8a28","type":"debug","z":"7daa2c74.0caa74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":290,"y":580,"wires":[]}]

Diese Sequenz gibt Ihnen einen neuen POST Webhook auf der URL /alarm/md/areas:

INSTAR Camera Control with Node-RED and IFTTT

Sortiert dann ob ein {"val":"on"} oder {"val":"off"} gesendet wurde (dies hatten wir in der IFTTT Konfiguration festgelegt):

INSTAR Camera Control with Node-RED and IFTTT

Im folgenden werden dann die Bereiche entweder ein oder ausgeschaltet auf der Kamera, die in den 8 Function-Nodes festgelegt wird:

INSTAR Camera Control with Node-RED and IFTTT