INSTAR Deutschland GmbH

OpenHAB 2 IP Kamera Kontrolle



Kamera API in Node-RED zu OpenHAB

In unserem vorherigen Tutorial haben wir unsere INSTAR REST API bereits auf MQTT mit Node-RED abgebildet. Das bedeutet, dass wir nun eine Nachricht über das MQTT-Protokoll veröffentlichen und Node-RED auslösen können, um einen CGI-Befehl an unsere Kamera zu senden. Wir werden später MQTT.fx verwenden, um diese Nachrichten zu senden oder ein Dashboard in Node-RED zu erstellen, um Nachrichten mit einem Knopfdruck zu veröffentlichen.

Das MQTT-Protokoll ist jedoch ein IoT-Standard (Internet of Things), der Sie zu einer Vielzahl von IoT-Hardware- und Software-Heimautomatisierungssystemen kompatibel macht. Lassen Sie uns einen Blick darauf werfen, wie wir diese neue Energie ausgleichen können, um unsere IP-Kamera in ein bestehendes Smart Home zu integrieren. Lassen Sie uns jetzt die OpenHAB-Schnittstelle verwenden, um Befehle an unsere Kamera zu senden.

OpenHAB Troubleshooting

OpenHAB protokolliert alle wichtigen Systemereignisse und Fehler in zwei Protokolldateien unter ./userdata/events.logs und ./userdata/openhab.log im Installationsverzeichnis von OpenHAB (unter Windows 10 befindet sich dies im Ordner users) - Es empfiehlt sich, diese beiden Dateien beim Bearbeiten von Konfigurationsdateien in Ihrem Editor geöffnet zu lassen:


OpenHAB


Wann immer etwas just nicht zu funktionieren scheint, sehen Sie sich diese Dateien an.

Items

Wir haben bereits gelernt wie man einen Dummy-Switch zu unserer OpenHAB-Benutzeroberfläche hinzuzufügt. Lassen Sie uns das ein bisschen spannender machen, indem Sie einen Switch einem MQTT-Thema zuordnen - so dass der Switch eine MQTT-Nachricht veröffentlicht, die dann von einem bereits vorbereiteten Node-RED-Fluss empfangen wird und einen CGI-Befehl auslöst (Aktivierung oder Deaktivierung der Bewegungserkennung) Bereich 1) zu unserer Kamera. Und um eine Rückmeldung zu erhalten, ob der Befehl empfangen wurde oder nicht, können wir zusätzlich eine Textausgabe zur Benutzeroberfläche hinzufügen.


OpenHAB


Der Code für dieses Konstrukt sieht folgendermaßen aus:

Switch EnableAreaOne {mqtt=">[mosquitto:openhab/alarm/setmdattr/enablearea1/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/enablearea1/enable/get:state:JSONPATH($.val)]"}

String EnableAreaOneState "MD Area 1 [%s]" <motion> {mqtt="<[mosquitto:openhab/alarm/setmdattr/enablearea1/enable/get:state:JSONPATH($.val)]"}

Switch

Lassen Sie uns noch einmal zusammentragen, was hier passiert. Zuerst wählen wir ein [item type] (https://www.openhab.org/docs/concepts/items.html#items) - in diesem Fall einen Switch - und geben ihm einen Namen EnableAreaOne, so dass wir ihn von unserem sitemap referenzieren zu können. Dann verwendeten wir das MQTT-Binding, um ein MQTT-Topic an den Zustand unseres Switches zu binden - ON oder OFF: mosquitto:openhab/alarm/setmdattr/enablearea1/enable/set (mosquitto ist der Name des MQTT-Brokers, den wir zuvor eingerichtet haben). Dies wird durch das erste Element dargestellt, das mit > beginnt, was bedeutet, dass es sich um die ausgehende Nachricht handelt. Der Befehl, der vom Switch über den MQTT-Dienst gesendet wird, ist entweder ON oder OFF - da unser Node-RED-Fluss JSON-Nachrichten benötigt, verwenden wir den MAP Transformer um diesen Befehl in die JSON konforme Nachricht ({"val": "ON"} oder {"val": "OFF"}) umzuwandeln

String

Die Textausgabe folgt derselben Struktur. Wir vergeben den richtigen Typ, in diesem Fall einen String, und geben ihm einen Namen (EnableAreaOneState), damit wir ihn in unserer sitemap referenzieren können. Der MD Area 1 [% s] Part stellt der Nachricht den Text MD Area 1 voran - siehe OpenHAB Dokumentation für Weitere Beispiele für die Syntax der Java-Formatierungsklasse. <motion> fügt das Bewegungserkennungssymbol hinzu, das vor der Textausgabe angezeigt wird. Der MQTT-Aufruf ist identisch mit der eingehenden Nachricht für unseren Switch - er nimmt den JSON-Ausdruck, der von unserem Node-RED-Flow über MQTT gesendet wird, und extrahiert den Wert von "val", der als Textausgabe angezeigt wird - ON oder OFF.

Transformation Dienste

Die OpenHAB Transformationen werden verwendet, um Daten von einem überladenen oder technischen Rohwert in eine verarbeitete oder für Menschen lesbare Repräsentation zu übersetzen. Sie sind oft nützlich, um empfangene Item-Werte wie Sensormesswerte oder Statusvariablen zu interpretieren und sie in ein für Menschen lesbares oder besser verarbeitbares Format zu übersetzen. Sie können sie über die OpenHAB PaperUI unter diesem Link installieren:


OpenHAB


Der JSONPath Transformer funktioniert sofort. Für den MAP Transformer müssen Sie eine .map Datei in ./conf/transform hinzufügen, die auf die Werte verweist, die Sie zuordnen möchten


OpenHAB


Sie können im obigen Screenshot sehen, dass wenn der Switch in die ON Position umgeschaltet und der Befehl ON ausgegeben wird. Dieser wird in den JSON Ausdruck {"val":"ON"} transformiert, den wir dann in unserem Node-RED-Flow verwenden können.

Sitemap

Um unsere Switch- und String-Ausgabe anzeigen zu lassen, müssen wir sie jetzt zur Home sitemap hinzufügen. Die Sitemap-Datei befindet sich in ./conf/sitemaps:


OpenHAB


sitemap home label="INSTAR - SmartOffice"
{

        Frame label="Detection Areas" {
                Switch item=EnableAreaOne label="Enable Area 1"
                Text item=EnableAreaOneState

        }
}

Das Sitmap Label wird in der Navigationsleiste über der Benutzeroberfläche angezeigt und der Frame gruppiert unsere Artikel auf einer Material Design Karte. Kopiere Sie dazu den Quellcode für home.items und home.sitemap unten (dieser fügt ein paar weitere Schalter und Textausgaben zur Benutzeroberfläche hinzu) und öffne das OpenHAB Basic-UI unter http://localhost:8080/basicui/app:


OpenHAB


Node-RED Einrichten

Jetzt müssen wir nur den (ziemlich langen) Node-RED Export importieren - Überprüfen Sie die Node-RED-Einführung für den Fall, dass Sie neu sind bei Node-RED:


OpenHAB


Wenn Sie das Node-RED-Dashboard öffnen, wird Ihnen folgende Benutzeroberfläche angezeigt:


OpenHAB


Geben Sie die IP-Adresse Ihrer Kamera (z. B. 192.168.1.116) und Ihre Admin-Anmeldung ein. Dadurch wird die Anmeldung für alle Node-RED-Flows verfügbar (IP, Benutzername und Passwort werden als globale Variablen festgelegt). Wenn Sie beide UIs - das Node-RED Dashboard und die OpenHAB Basic-UI - öffnen, sollten Sie sehen, dass diese ihre Einstellungen über MQTT austauschen:


OpenHAB


Und die Einstellungen spiegeln genau die Kamerakonfiguration wider:


OpenHAB


Source Code

home.items

Kopiere die folgenden Zeilen in die Datei ./conf/items/home.items. Zusätzlich zu der obigen Beschreibung haben wir Schalter für alle 4 Bewegungserkennungsbereiche und zusätzliche Schalter hinzugefügt, um die Empfindlichkeit der Bewegungserkennung zu ändern:

// Detection Areas

// // Activate

Switch EnableAreaOne {mqtt=">[mosquitto:openhab/alarm/setmdattr/enablearea1/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/enablearea1/enable/get:state:JSONPATH($.val)]"}
String EnableAreaOneState "MD Area 1 [%s]" <motion> {mqtt="<[mosquitto:openhab/alarm/setmdattr/enablearea1/enable/get:state:JSONPATH($.val)]"}

Switch EnableAreaTwo {mqtt=">[mosquitto:openhab/alarm/setmdattr/enablearea2/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/enablearea2/enable/get:state:JSONPATH($.val)]"}
String EnableAreaTwoState "MD Area 2 [%s]" <motion> {mqtt="<[mosquitto:openhab/alarm/setmdattr/enablearea2/enable/get:state:JSONPATH($.val)]"}

Switch EnableAreaThree {mqtt=">[mosquitto:openhab/alarm/setmdattr/enablearea3/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/enablearea3/enable/get:state:JSONPATH($.val)]"}
String EnableAreaThreeState "MD Area 3 [%s]" <motion> {mqtt="<[mosquitto:openhab/alarm/setmdattr/enablearea3/enable/get:state:JSONPATH($.val)]"}

Switch EnableAreaFour {mqtt=">[mosquitto:openhab/alarm/setmdattr/enablearea4/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/enablearea4/enable/get:state:JSONPATH($.val)]"}
String EnableAreaFourState "MD Area 4 [%s]" <motion> {mqtt="<[mosquitto:openhab/alarm/setmdattr/enablearea4/enable/get:state:JSONPATH($.val)]"}

// // Sensitivity

Switch AreaOneHighSense (MDNotificationsControlGroup) {mqtt=">[mosquitto:openhab/alarm/setmdattr/area1/highsensitivity/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/area1/highsensitivity/enable/get:state:JSONPATH($.val)]"}
String AreaOneHighSenseState "High Sensitivity Area 1 [%s]" <motion> (MDNotificationsControlGroup) {mqtt="<[mosquitto:openhab/alarm/setmdattr/area1/highsensitivity/enable/get:state:JSONPATH($.val)]"}

Switch AreaTwoHighSense (MDNotificationsControlGroup) {mqtt=">[mosquitto:openhab/alarm/setmdattr/area2/highsensitivity/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/area2/highsensitivity/enable/get:state:JSONPATH($.val)]"}
String AreaTwoHighSenseState "High Sensitivity Area 2 [%s]" <motion> (MDNotificationsControlGroup) {mqtt="<[mosquitto:openhab/alarm/setmdattr/area2/highsensitivity/enable/get:state:JSONPATH($.val)]"}

Switch AreaThreeHighSense (MDNotificationsControlGroup) {mqtt=">[mosquitto:openhab/alarm/setmdattr/area3/highsensitivity/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/area3/highsensitivity/enable/get:state:JSONPATH($.val)]"}
String AreaThreeHighSenseState "High Sensitivity Area 3 [%s]" <motion> (MDNotificationsControlGroup) {mqtt="<[mosquitto:openhab/alarm/setmdattr/area3/highsensitivity/enable/get:state:JSONPATH($.val)]"}

Switch AreaFourHighSense (MDNotificationsControlGroup) {mqtt=">[mosquitto:openhab/alarm/setmdattr/area4/highsensitivity/enable/set:command:*:MAP(mqtt-binding.map)],<[mosquitto:openhab/alarm/setmdattr/area4/highsensitivity/enable/get:state:JSONPATH($.val)]"}
String AreaFourHighSenseState "High Sensitivity Area 4 [%s]" <motion> (MDNotificationsControlGroup) {mqtt="<[mosquitto:openhab/alarm/setmdattr/area4/highsensitivity/enable/get:state:JSONPATH($.val)]"}

home.sitemap

Kopiere die folgenden Zeilen in die Datei ./conf/sitemaps/home.sitemap. Zusätzlich zu der obigen Beschreibung haben wir Schalter für alle 4 Bewegungserkennungsbereiche und zusätzliche Schalter hinzugefügt, um die Empfindlichkeit der Bewegungserkennung zu ändern:

sitemap home label="INSTAR - SmartOffice"
{

        Frame label="Detection Areas" {
                Switch item=EnableAreaOne label="Enable Area 1"
                Text item=EnableAreaOneState
                Switch item=AreaOneHighSense label="Set High Sensitivity"
                Text item=AreaOneHighSenseState

                Switch item=EnableAreaTwo label="Enable Area 2"
                Text item=EnableAreaTwoState
                Switch item=AreaTwoHighSense label="Set High Sensitivity"
                Text item=AreaTwoHighSenseState

                Switch item=EnableAreaThree label="Enable Area 3"
                Text item=EnableAreaThreeState
                Switch item=AreaThreeHighSense label="Set High Sensitivity"
                Text item=AreaThreeHighSenseState

                Switch item=EnableAreaFour label="Enable Area 4"
                Text item=EnableAreaFourState
                Switch item=AreaFourHighSense label="Set High Sensitivity"
                Text item=AreaFourHighSenseState

        }
}

Node-RED Flow

Kopieren Sie den folgenden JSON-Block und verwenden Sie den Node-RED-Import, um ihn in Ihren Node-RED-Flow zu importieren:

[{"id":"13bcbd83.ab1fe2","type":"tab","label":"Wiki Tutorial","disabled":false,"info":""},{"id":"9f5d07da.b800b8","type":"ui_form","z":"13bcbd83.ab1fe2","name":"Camera Address","label":"Change Address","group":"c0689660.4e98c8","order":0,"width":0,"height":0,"options":[{"label":"IP Address","value":"ip","type":"text","required":true},{"label":"Username","value":"user","type":"text","required":true},{"label":"Password","value":"password","type":"password","required":true}],"formValue":{"ip":"","user":"","password":""},"payload":"","submit":"Submit","cancel":"Cancel","topic":"user_set","x":90,"y":100,"wires":[["59d50e34.9ad15"]]},{"id":"d5b37a35.b7c358","type":"comment","z":"13bcbd83.ab1fe2","name":"Set Login Global","info":"","x":90,"y":40,"wires":[]},{"id":"59d50e34.9ad15","type":"change","z":"13bcbd83.ab1fe2","name":"Set Global Login","rules":[{"t":"set","p":"ip","pt":"global","to":"payload.ip","tot":"msg"},{"t":"set","p":"password","pt":"global","to":"payload.password","tot":"msg"},{"t":"set","p":"user","pt":"global","to":"payload.user","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":160,"wires":[["abe4025e.efce5"]]},{"id":"abe4025e.efce5","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"","retain":"","broker":"47feb3e4.56f11c","x":180,"y":220,"wires":[]},{"id":"50bbdd63.52e124","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 1 Enabled","group":"eb6d72f9.38466","order":2,"width":0,"height":0,"passthru":false,"label":"Area 1 Enabled","color":"#ffffff","bgcolor":"#f17c35","icon":"fa-square","payload":"{\"val\" : \"ON\"}","payloadType":"json","topic":"area","x":90,"y":340,"wires":[["b6cb3341.98a26"]]},{"id":"a6efcd3c.355c","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 1 Disabled","group":"eb6d72f9.38466","order":3,"width":0,"height":0,"passthru":false,"label":"Area 1 Disabled","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\" : \"OFF\"}","payloadType":"json","topic":"area","x":90,"y":380,"wires":[["b6cb3341.98a26"]]},{"id":"b6cb3341.98a26","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea1","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":280,"y":360,"wires":[]},{"id":"fdb574a9.ff5aa8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea1","qos":"1","broker":"47feb3e4.56f11c","x":102,"y":426,"wires":[["18250c9f.acf1d3"]]},{"id":"18250c9f.acf1d3","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":257,"y":426,"wires":[["e885f12d.df61b"]]},{"id":"5b4cbb80.6b8de4","type":"function","z":"13bcbd83.ab1fe2","name":"Enable Area 1","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=1&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":518,"y":404,"wires":[["ae8455d1.06fa68"]]},{"id":"1c6b99a6.4a38f6","type":"function","z":"13bcbd83.ab1fe2","name":"Disable Area 1","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=1&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":518,"y":444,"wires":[["b24ab61f.dc17a8"]]},{"id":"b24ab61f.dc17a8","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":659,"y":444,"wires":[["6b9824d6.c21fdc"]]},{"id":"ae8455d1.06fa68","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":659,"y":404,"wires":[["67ecfcb2.1a0a84"]]},{"id":"6b9824d6.c21fdc","type":"http request","z":"13bcbd83.ab1fe2","name":"m1_disable","method":"GET","ret":"txt","url":"","tls":"","x":789,"y":444,"wires":[["f6d426ec.1b1838"]]},{"id":"67ecfcb2.1a0a84","type":"http request","z":"13bcbd83.ab1fe2","name":"m1_enable","method":"GET","ret":"txt","url":"","tls":"","x":789,"y":404,"wires":[["48af1bde.4923d4"]]},{"id":"48af1bde.4923d4","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"ON\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":920,"y":404,"wires":[["5f1fd6dd.4f5978","e0a75c10.addf"]]},{"id":"f6d426ec.1b1838","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"OFF\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":919,"y":444,"wires":[["5f1fd6dd.4f5978","e0a75c10.addf"]]},{"id":"5f1fd6dd.4f5978","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1059,"y":443,"wires":[["83bea234.ac661"]]},{"id":"83bea234.ac661","type":"ui_text","z":"13bcbd83.ab1fe2","group":"eb6d72f9.38466","order":1,"width":0,"height":0,"name":"Area 1","label":"Area 1","format":"{{msg.payload.val}}","layout":"row-spread","x":1181,"y":443,"wires":[]},{"id":"b820ba94.37e9e8","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":811,"y":486,"wires":[["5ecadc88.bf2574"]]},{"id":"5ecadc88.bf2574","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m1_enable\":\"0\","},{"type":"str","value":"\"val\" : \"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m1_enable\":\"1\","},{"type":"str","value":"\"val\" : \"ON\","}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":901,"y":540,"wires":[["5f1fd6dd.4f5978"]]},{"id":"9504a298.49c1f","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":671,"y":486,"wires":[["ff0aa943.7e06a8"]]},{"id":"cedfe4c2.3a48c8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":511,"y":486,"wires":[["2d4bfa60.ff4c76"]]},{"id":"2d4bfa60.ff4c76","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":581,"y":546,"wires":[["9504a298.49c1f"]]},{"id":"ff0aa943.7e06a8","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":731,"y":546,"wires":[["b820ba94.37e9e8"]]},{"id":"b67fea25.629cc8","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 2 Enabled","group":"eb6d72f9.38466","order":5,"width":0,"height":0,"passthru":false,"label":"Area 2 Enabled","color":"#ffffff","bgcolor":"#f17c35","icon":"fa-square","payload":"{\"val\" : \"ON\"}","payloadType":"json","topic":"area","x":90,"y":558,"wires":[["6253feb.c6a6e"]]},{"id":"c55dd3da.c4432","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 2 Disabled","group":"eb6d72f9.38466","order":6,"width":0,"height":0,"passthru":false,"label":"Area 2 Disabled","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\" : \"OFF\"}","payloadType":"json","topic":"area","x":90,"y":598,"wires":[["6253feb.c6a6e"]]},{"id":"6253feb.c6a6e","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea2","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":280,"y":575,"wires":[]},{"id":"f39630d8.2f409","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea2","qos":"1","broker":"47feb3e4.56f11c","x":100,"y":658,"wires":[["5c13b7de.5f1638"]]},{"id":"5c13b7de.5f1638","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":275,"y":657,"wires":[["a250918b.0135f"]]},{"id":"b048228b.4e068","type":"function","z":"13bcbd83.ab1fe2","name":"Enable Area 2","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=2&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":546,"y":635,"wires":[["f3a0e2b0.c2421"]]},{"id":"6e00240f.79302c","type":"function","z":"13bcbd83.ab1fe2","name":"Disable Area 2","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=2&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":546,"y":675,"wires":[["bb1be005.903a6"]]},{"id":"bb1be005.903a6","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":687,"y":675,"wires":[["fb93e517.345708"]]},{"id":"f3a0e2b0.c2421","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":687,"y":635,"wires":[["6a72c5a1.2d242c"]]},{"id":"6a72c5a1.2d242c","type":"http request","z":"13bcbd83.ab1fe2","name":"m2_enable","method":"GET","ret":"txt","url":"","tls":"","x":817,"y":635,"wires":[["7b6f01e0.f24bd"]]},{"id":"fb93e517.345708","type":"http request","z":"13bcbd83.ab1fe2","name":"m2_disable","method":"GET","ret":"txt","url":"","tls":"","x":817,"y":675,"wires":[["5fff4464.24431c"]]},{"id":"5fff4464.24431c","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"OFF\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":947,"y":675,"wires":[["80fb8ad6.384468","5e36f95.7344b08"]]},{"id":"7b6f01e0.f24bd","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"ON\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":948,"y":635,"wires":[["80fb8ad6.384468","5e36f95.7344b08"]]},{"id":"80fb8ad6.384468","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1098,"y":671,"wires":[["60ad714e.bfc2a"]]},{"id":"60ad714e.bfc2a","type":"ui_text","z":"13bcbd83.ab1fe2","group":"eb6d72f9.38466","order":4,"width":0,"height":0,"name":"Area 2","label":"Area 2","format":"{{msg.payload.val}}","layout":"row-spread","x":1220,"y":671,"wires":[]},{"id":"5cb0588d.bfbc98","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":840,"y":718,"wires":[["e4d70fd8.ccf18"]]},{"id":"e4d70fd8.ccf18","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m2_enable\":\"0\","},{"type":"str","value":"\"val\" : \"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m2_enable\":\"1\","},{"type":"str","value":"\"val\" : \"ON\","}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":930,"y":772,"wires":[["80fb8ad6.384468"]]},{"id":"c6920e18.23b3d","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":718,"wires":[["e63370f8.cc0ac"]]},{"id":"43840b42.48b284","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":540,"y":718,"wires":[["6a37f433.3d461c"]]},{"id":"6a37f433.3d461c","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":610,"y":778,"wires":[["c6920e18.23b3d"]]},{"id":"e63370f8.cc0ac","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":778,"wires":[["5cb0588d.bfbc98"]]},{"id":"65dc577.f719ea8","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 3 Enabled","group":"eb6d72f9.38466","order":8,"width":0,"height":0,"passthru":false,"label":"Area 3 Enabled","color":"#ffffff","bgcolor":"#f17c35","icon":"fa-square","payload":"{\"val\" : \"ON\"}","payloadType":"json","topic":"area","x":90,"y":782,"wires":[["a54cc5d2.cc2658"]]},{"id":"73a27565.1a652c","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 3 Disabled","group":"eb6d72f9.38466","order":9,"width":0,"height":0,"passthru":false,"label":"Area 3 Disabled","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\" : \"OFF\"}","payloadType":"json","topic":"area","x":90,"y":822,"wires":[["a54cc5d2.cc2658"]]},{"id":"a54cc5d2.cc2658","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea3","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":280,"y":802,"wires":[]},{"id":"daf8848f.738df8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea3","qos":"1","broker":"47feb3e4.56f11c","x":104,"y":880,"wires":[["4e811056.d19ae"]]},{"id":"4e811056.d19ae","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":261,"y":880,"wires":[["648ecc91.a8ad74"]]},{"id":"a4fab16.e81205","type":"function","z":"13bcbd83.ab1fe2","name":"Enable Area 3","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=3&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":547,"y":858,"wires":[["4a86fcf6.d16f74"]]},{"id":"d40c4daa.a91b3","type":"function","z":"13bcbd83.ab1fe2","name":"Disable Area 3","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=3&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":547,"y":898,"wires":[["d6ea6337.5686a"]]},{"id":"4a86fcf6.d16f74","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":688,"y":858,"wires":[["1699e773.5581e9"]]},{"id":"d6ea6337.5686a","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":688,"y":898,"wires":[["354d4915.09d376"]]},{"id":"354d4915.09d376","type":"http request","z":"13bcbd83.ab1fe2","name":"m3_disable","method":"GET","ret":"txt","url":"","tls":"","x":818,"y":898,"wires":[["13c330d4.719acf"]]},{"id":"1699e773.5581e9","type":"http request","z":"13bcbd83.ab1fe2","name":"m3_enable","method":"GET","ret":"txt","url":"","tls":"","x":818,"y":858,"wires":[["c49ee612.c49b98"]]},{"id":"c49ee612.c49b98","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"ON\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":949,"y":858,"wires":[["8c373b7a.84d268","adbd9928.d09308"]]},{"id":"13c330d4.719acf","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"OFF\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":948,"y":898,"wires":[["8c373b7a.84d268"]]},{"id":"8c373b7a.84d268","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1089,"y":895,"wires":[["da08c2ea.595a6"]]},{"id":"da08c2ea.595a6","type":"ui_text","z":"13bcbd83.ab1fe2","group":"eb6d72f9.38466","order":7,"width":0,"height":0,"name":"Area 3","label":"Area 3","format":"{{msg.payload.val}}","layout":"row-spread","x":1211,"y":895,"wires":[]},{"id":"799a2e20.1a1ac","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":840,"y":943,"wires":[["77ac8451.68f38c"]]},{"id":"77ac8451.68f38c","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m3_enable\":\"0\","},{"type":"str","value":"\"val\" : \"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m3_enable\":\"1\","},{"type":"str","value":"\"val\" : \"ON\","}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":930,"y":997,"wires":[["8c373b7a.84d268"]]},{"id":"4c7d809d.a7774","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":943,"wires":[["809d94e7.0b3908"]]},{"id":"b923534d.88971","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":540,"y":943,"wires":[["e709f26d.fc5ad"]]},{"id":"e709f26d.fc5ad","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":610,"y":1003,"wires":[["4c7d809d.a7774"]]},{"id":"809d94e7.0b3908","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":1003,"wires":[["799a2e20.1a1ac"]]},{"id":"ad6f2ddb.410a8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea4","qos":"1","broker":"47feb3e4.56f11c","x":100,"y":1122,"wires":[["57bf96be.d51998"]]},{"id":"1c8c0b6b.e09215","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 4 Enabled","group":"eb6d72f9.38466","order":11,"width":0,"height":0,"passthru":false,"label":"Area 4 Enabled","color":"#ffffff","bgcolor":"#f17c35","icon":"fa-square","payload":"{\"val\" : \"ON\"}","payloadType":"json","topic":"area","x":90,"y":1022,"wires":[["592422c.a6f58dc"]]},{"id":"3bfbac95.5141b4","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 4 Disabled","group":"eb6d72f9.38466","order":12,"width":0,"height":0,"passthru":false,"label":"Area 4 Disabled","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\" : \"OFF\"}","payloadType":"json","topic":"area","x":90,"y":1065,"wires":[["592422c.a6f58dc"]]},{"id":"b460b1d8.86c4d","type":"function","z":"13bcbd83.ab1fe2","name":"Enable Area 4","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=4&-enable=1&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":514,"y":1101,"wires":[["9012e2b.6d17d2"]]},{"id":"a9cf4a9b.bc16c8","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"ON\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":916,"y":1101,"wires":[["d3f75249.e723e","36fd7e33.7b7d32"]]},{"id":"9012e2b.6d17d2","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":655,"y":1101,"wires":[["26728bf.016bd74"]]},{"id":"26728bf.016bd74","type":"http request","z":"13bcbd83.ab1fe2","name":"m4_enable","method":"GET","ret":"txt","url":"","tls":"","x":785,"y":1101,"wires":[["a9cf4a9b.bc16c8"]]},{"id":"4634e777.d3e578","type":"function","z":"13bcbd83.ab1fe2","name":"Disable Area 4","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=4&-enable=0&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":514,"y":1141,"wires":[["ece708b7.a8f2c8"]]},{"id":"ece708b7.a8f2c8","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":655,"y":1141,"wires":[["70dab78c.9aaa08"]]},{"id":"70dab78c.9aaa08","type":"http request","z":"13bcbd83.ab1fe2","name":"m4_disable","method":"GET","ret":"txt","url":"","tls":"","x":785,"y":1141,"wires":[["4bb34daa.5d61f4"]]},{"id":"4bb34daa.5d61f4","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\" : \"OFF\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":915,"y":1141,"wires":[["d3f75249.e723e","36fd7e33.7b7d32"]]},{"id":"af2afba6.6d1618","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":798,"y":1187,"wires":[["b99a089b.e87a58"]]},{"id":"b99a089b.e87a58","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m4_enable\":\"0\","},{"type":"str","value":"\"val\" : \"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"\"m4_enable\":\"1\","},{"type":"str","value":"\"val\" : \"ON\","}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":888,"y":1241,"wires":[["d3f75249.e723e"]]},{"id":"a2f28739.b93d38","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":658,"y":1187,"wires":[["629272c9.acd98c"]]},{"id":"74548af9.3c4de4","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":498,"y":1187,"wires":[["b2dd3e4c.b5a2a"]]},{"id":"b2dd3e4c.b5a2a","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":568,"y":1247,"wires":[["a2f28739.b93d38"]]},{"id":"629272c9.acd98c","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":718,"y":1247,"wires":[["af2afba6.6d1618"]]},{"id":"d3f75249.e723e","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1072,"y":1135,"wires":[["bac0e32f.b1e66"]]},{"id":"bac0e32f.b1e66","type":"ui_text","z":"13bcbd83.ab1fe2","group":"eb6d72f9.38466","order":10,"width":0,"height":0,"name":"Area 4","label":"Area 4","format":"{{msg.payload.val}}","layout":"row-spread","x":1194,"y":1135,"wires":[]},{"id":"6dba5d05.9b5cf4","type":"switch","z":"13bcbd83.ab1fe2","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":370,"y":1121,"wires":[["b460b1d8.86c4d"],["4634e777.d3e578"]]},{"id":"57bf96be.d51998","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":250,"y":1121,"wires":[["6dba5d05.9b5cf4"]]},{"id":"592422c.a6f58dc","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Activate Alarm Area","topic":"ipcam/alarm/setmdattr/enablearea4","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":280,"y":1042,"wires":[]},{"id":"648ecc91.a8ad74","type":"switch","z":"13bcbd83.ab1fe2","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":390,"y":881,"wires":[["a4fab16.e81205"],["d40c4daa.a91b3"]]},{"id":"a250918b.0135f","type":"switch","z":"13bcbd83.ab1fe2","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":400,"y":657,"wires":[["b048228b.4e068"],["6e00240f.79302c"]]},{"id":"e885f12d.df61b","type":"switch","z":"13bcbd83.ab1fe2","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":375,"y":426,"wires":[["5b4cbb80.6b8de4"],["1c6b99a6.4a38f6"]]},{"id":"49117dff.1d9904","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea4/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":130,"y":1167,"wires":[["57bf96be.d51998"]]},{"id":"36fd7e33.7b7d32","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea4/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1080,"y":1100,"wires":[]},{"id":"503be340.32259c","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea3/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":135,"y":924,"wires":[["4e811056.d19ae"]]},{"id":"adbd9928.d09308","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea3/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1095,"y":858,"wires":[]},{"id":"5e36f95.7344b08","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea2/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1106,"y":634,"wires":[]},{"id":"96a1d187.6eebc","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea2/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":130,"y":698,"wires":[["5c13b7de.5f1638"]]},{"id":"8e622bc6.ceb978","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea1/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":130,"y":471,"wires":[["18250c9f.acf1d3"]]},{"id":"e0a75c10.addf","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/enablearea1/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1067,"y":404,"wires":[]},{"id":"ee3a315a.7fb5","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 1 High Sensitivity","group":"7b82c3d3.aea4ac","order":2,"width":0,"height":0,"passthru":false,"label":"Area 1 High Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\" : \"ON\"}","payloadType":"json","topic":"area","x":110,"y":1360,"wires":[["15841b5.7094ce5"]]},{"id":"17805dfe.63e402","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 1 Low Sensitivity","group":"7b82c3d3.aea4ac","order":3,"width":0,"height":0,"passthru":false,"label":"Area 1 Low Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\" : \"OFF\"}","payloadType":"json","topic":"area","x":110,"y":1400,"wires":[["15841b5.7094ce5"]]},{"id":"15841b5.7094ce5","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area1/highsensitivity","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":311,"y":1380,"wires":[]},{"id":"39d76b57.d3b314","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area1/highsensitivity","qos":"1","broker":"47feb3e4.56f11c","x":110,"y":1442,"wires":[["1c4a374b.46aa19"]]},{"id":"1c4a374b.46aa19","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":271,"y":1441,"wires":[["2101358a.90d5aa"]]},{"id":"2101358a.90d5aa","type":"switch","z":"13bcbd83.ab1fe2","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":388,"y":1441,"wires":[["99d066e.ff48c98"],["e5d29600.1fc8a8"]]},{"id":"99d066e.ff48c98","type":"function","z":"13bcbd83.ab1fe2","name":"Area 75%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=1&-s=75&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":523,"y":1420,"wires":[["4a6a06c9.d7df78"]]},{"id":"e5d29600.1fc8a8","type":"function","z":"13bcbd83.ab1fe2","name":"Area 25%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=1&-s=25&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":523,"y":1460,"wires":[["70674026.ea218"]]},{"id":"4a6a06c9.d7df78","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":663,"y":1420,"wires":[["408777d2.0fc0f8"]]},{"id":"70674026.ea218","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":663,"y":1460,"wires":[["b93efa2e.106408"]]},{"id":"408777d2.0fc0f8","type":"http request","z":"13bcbd83.ab1fe2","name":"m1_enable","method":"GET","ret":"txt","url":"","tls":"","x":793,"y":1420,"wires":[["e880eb26.1ec688"]]},{"id":"b93efa2e.106408","type":"http request","z":"13bcbd83.ab1fe2","name":"m1_disable","method":"GET","ret":"txt","url":"","tls":"","x":793,"y":1460,"wires":[["3aad640a.831bec"]]},{"id":"e880eb26.1ec688","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{ \"val\": \"ON\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":924,"y":1420,"wires":[["658af9a7.9ab4e8","6ca84bf7.9af744"]]},{"id":"3aad640a.831bec","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{ \"val\": \"OFF\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":923,"y":1460,"wires":[["658af9a7.9ab4e8","6ca84bf7.9af744"]]},{"id":"658af9a7.9ab4e8","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1064,"y":1455,"wires":[["f1af1189.25b6e"]]},{"id":"f1af1189.25b6e","type":"ui_text","z":"13bcbd83.ab1fe2","group":"7b82c3d3.aea4ac","order":1,"width":0,"height":0,"name":"Area 1","label":"Area 1","format":"{{msg.payload.val}}","layout":"row-spread","x":1186,"y":1455,"wires":[]},{"id":"db78855f.3659c8","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":812,"y":1500,"wires":[["5420473e.c6a498"]]},{"id":"c5d1e2c7.36a0e","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":672,"y":1500,"wires":[["d45f117e.ecf76"]]},{"id":"bd0fa42f.b7d1b8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":523,"y":1500,"wires":[["477b764f.5e4368"]]},{"id":"5420473e.c6a498","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"75\","},{"type":"str","value":"ON\","}]},{"name":"replaceAll","params":[{"type":"str","value":"25\","},{"type":"str","value":"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"m1_sensitivity"},{"type":"str","value":"val"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":913,"y":1554,"wires":[["658af9a7.9ab4e8"]]},{"id":"d45f117e.ecf76","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":743,"y":1560,"wires":[["db78855f.3659c8"]]},{"id":"477b764f.5e4368","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":593,"y":1560,"wires":[["c5d1e2c7.36a0e"]]},{"id":"6ca84bf7.9af744","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area1/highsensitivity/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1073,"y":1419,"wires":[]},{"id":"34a94a27.511146","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area1/highsensitivity/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":150,"y":1480,"wires":[["1c4a374b.46aa19"]]},{"id":"24499dd8.5d1b42","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 2 High Sensitivity","group":"7b82c3d3.aea4ac","order":5,"width":0,"height":0,"passthru":false,"label":"Area 2 High Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\": \"ON\"}","payloadType":"json","topic":"area","x":110,"y":1565,"wires":[["32ee57af.a691a8"]]},{"id":"59eed1bb.56c61","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 2 Low Sensitivity","group":"7b82c3d3.aea4ac","order":6,"width":0,"height":0,"passthru":false,"label":"Area 2 Low Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\": \"OFF\"}","payloadType":"json","topic":"area","x":110,"y":1602,"wires":[["32ee57af.a691a8"]]},{"id":"32ee57af.a691a8","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area2/highsensitivity","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":317,"y":1582,"wires":[]},{"id":"3ab76bc0.379d64","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area2/highsensitivity","qos":"1","broker":"47feb3e4.56f11c","x":110,"y":1648,"wires":[["5e41afbb.f90e8"]]},{"id":"5e41afbb.f90e8","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":271,"y":1647,"wires":[["c460a35.556896"]]},{"id":"f0754575.962a48","type":"function","z":"13bcbd83.ab1fe2","name":"Area 2 25%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=2&-s=25&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":519,"y":1666,"wires":[["55af7fa.55ccd8"]]},{"id":"97abcdec.c89ec","type":"function","z":"13bcbd83.ab1fe2","name":"Area 2 75%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=2&-s=75&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":519,"y":1626,"wires":[["a4f817fb.de5d18"]]},{"id":"a4f817fb.de5d18","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":1626,"wires":[["f5649837.f61c38"]]},{"id":"55af7fa.55ccd8","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":1666,"wires":[["ff7bead4.5a7b08"]]},{"id":"ff7bead4.5a7b08","type":"http request","z":"13bcbd83.ab1fe2","name":"m2_disable","method":"GET","ret":"txt","url":"","tls":"","x":800,"y":1666,"wires":[["b5f87f0.204b68"]]},{"id":"f5649837.f61c38","type":"http request","z":"13bcbd83.ab1fe2","name":"m2_enable","method":"GET","ret":"txt","url":"","tls":"","x":800,"y":1626,"wires":[["14b777d8.35bdd8"]]},{"id":"14b777d8.35bdd8","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\": \"ON\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":931,"y":1626,"wires":[["2a66755e.11afaa","d8c78e10.2a333"]]},{"id":"b5f87f0.204b68","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\": \"OFF\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":930,"y":1666,"wires":[["2a66755e.11afaa","d8c78e10.2a333"]]},{"id":"2a66755e.11afaa","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1067,"y":1662,"wires":[["91d468e0.52f8d8"]]},{"id":"91d468e0.52f8d8","type":"ui_text","z":"13bcbd83.ab1fe2","group":"7b82c3d3.aea4ac","order":4,"width":0,"height":0,"name":"Area 2","label":"Area 2","format":"{{msg.payload.val}}","layout":"row-spread","x":1189,"y":1662,"wires":[]},{"id":"cd306cee.53944","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":811,"y":1712,"wires":[["26ad8b73.8449f4"]]},{"id":"db067a4.aa1fc88","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":671,"y":1712,"wires":[["3daf957.2e27f6a"]]},{"id":"8d01bea3.3ca4b","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":522,"y":1712,"wires":[["e5431df4.88c62"]]},{"id":"26ad8b73.8449f4","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"25\","},{"type":"str","value":"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"75\","},{"type":"str","value":"ON\","}]},{"name":"replaceAll","params":[{"type":"str","value":"25\","},{"type":"str","value":"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"m2_sensitivity"},{"type":"str","value":"val"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":912,"y":1766,"wires":[["2a66755e.11afaa"]]},{"id":"3daf957.2e27f6a","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":742,"y":1772,"wires":[["cd306cee.53944"]]},{"id":"e5431df4.88c62","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":592,"y":1772,"wires":[["db067a4.aa1fc88"]]},{"id":"d8c78e10.2a333","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area2/highsensitivity/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1076,"y":1626,"wires":[]},{"id":"8ab2b2ed.7916f","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area2/highsensitivity/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":151,"y":1686,"wires":[["5e41afbb.f90e8"]]},{"id":"9165b63b.643c48","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 3 High Sensitivity","group":"7b82c3d3.aea4ac","order":8,"width":0,"height":0,"passthru":false,"label":"Area 3 High Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\": \"ON\"}","payloadType":"json","topic":"area","x":108,"y":1776,"wires":[["2739a719.547ce8"]]},{"id":"31f3d3e1.637ccc","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 3 Low Sensitivity","group":"7b82c3d3.aea4ac","order":9,"width":0,"height":0,"passthru":false,"label":"Area 3 Low Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\": \"OFF\"}","payloadType":"json","topic":"area","x":108,"y":1815,"wires":[["2739a719.547ce8"]]},{"id":"2739a719.547ce8","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area3/highsensitivity","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":315,"y":1792,"wires":[]},{"id":"bcb50b92.f9c128","type":"function","z":"13bcbd83.ab1fe2","name":"Area 3 75%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=3&-s=75&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":519,"y":1836,"wires":[["31fc0f62.19341"]]},{"id":"3d5413d2.f5912c","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\": \"ON\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":931,"y":1836,"wires":[["2cd8a384.267c5c","95056a19.1a8fa8"]]},{"id":"31fc0f62.19341","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":1836,"wires":[["ed86d7c3.61d0e8"]]},{"id":"ed86d7c3.61d0e8","type":"http request","z":"13bcbd83.ab1fe2","name":"m3_enable","method":"GET","ret":"txt","url":"","tls":"","x":800,"y":1836,"wires":[["3d5413d2.f5912c"]]},{"id":"f9948f48.8db0b","type":"function","z":"13bcbd83.ab1fe2","name":"Area 3 25%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=3&-s=25&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":519,"y":1876,"wires":[["eab2a03e.dc7ec"]]},{"id":"eab2a03e.dc7ec","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":1876,"wires":[["c219fbda.d2e768"]]},{"id":"c219fbda.d2e768","type":"http request","z":"13bcbd83.ab1fe2","name":"m3_disable","method":"GET","ret":"txt","url":"","tls":"","x":800,"y":1876,"wires":[["33d7d44c.8eacac"]]},{"id":"33d7d44c.8eacac","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\": \"OFF\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":930,"y":1876,"wires":[["2cd8a384.267c5c","95056a19.1a8fa8"]]},{"id":"2cd8a384.267c5c","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1069,"y":1871,"wires":[["865a79b2.b94ba8"]]},{"id":"865a79b2.b94ba8","type":"ui_text","z":"13bcbd83.ab1fe2","group":"7b82c3d3.aea4ac","order":7,"width":0,"height":0,"name":"Area 3","label":"Area 3","format":"{{msg.payload.val}}","layout":"row-spread","x":1191,"y":1871,"wires":[]},{"id":"7d588e45.801a","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":266,"y":1857,"wires":[["59a9cb9.48fe734"]]},{"id":"1acc099b.427966","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area3/highsensitivity","qos":"1","broker":"47feb3e4.56f11c","x":105,"y":1858,"wires":[["7d588e45.801a"]]},{"id":"97bc17ef.904878","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area4/highsensitivity","qos":"1","broker":"47feb3e4.56f11c","x":110,"y":2069,"wires":[["ec5ca73a.447f28"]]},{"id":"2f5e751b.7511ba","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 4 High Sensitivity","group":"7b82c3d3.aea4ac","order":11,"width":0,"height":0,"passthru":false,"label":"Area 4 High Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\": \"ON\"}","payloadType":"json","topic":"area","x":110,"y":1983,"wires":[["99879a04.b49d48"]]},{"id":"99879a04.b49d48","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"Alarm Area Sensitivity","topic":"ipcam/alarm/setmdattr/area4/highsensitivity","qos":"1","retain":"","broker":"47feb3e4.56f11c","x":315,"y":2001,"wires":[]},{"id":"7dee6c26.ba3ba4","type":"ui_button","z":"13bcbd83.ab1fe2","name":"Area 4 Low Sensitivity","group":"7b82c3d3.aea4ac","order":12,"width":0,"height":0,"passthru":false,"label":"Area 4 Low Sensitivity","color":"#000000","bgcolor":"#dddddd","icon":"fa-square","payload":"{\"val\": \"OFF\"}","payloadType":"json","topic":"area","x":111,"y":2023,"wires":[["99879a04.b49d48"]]},{"id":"8ae7454a.e765f8","type":"function","z":"13bcbd83.ab1fe2","name":"Area 4 75%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"three\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=4&-s=75&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":523,"y":2047,"wires":[["5bba5a0a.ba6bc4"]]},{"id":"cb91247a.2096a8","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{\"val\": \"ON\"}"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{\"val\": \"OFF\"}"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":935,"y":2047,"wires":[["8a638b6c.d0faa8","a943350b.a43d68"]]},{"id":"5bba5a0a.ba6bc4","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":674,"y":2047,"wires":[["ce449a7c.888dc8"]]},{"id":"ce449a7c.888dc8","type":"http request","z":"13bcbd83.ab1fe2","name":"m4_enable","method":"GET","ret":"txt","url":"","tls":"","x":804,"y":2047,"wires":[["cb91247a.2096a8"]]},{"id":"95ff166c.95c538","type":"function","z":"13bcbd83.ab1fe2","name":"Area 4 25%","func":"var ip = global.get(\"ip\");\nvar user = global.get(\"user\");\nvar password = global.get(\"password\");\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"six\";\nmsg.payload = ip+\"/param.cgi?cmd=setmdattr&-name=4&-s=25&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":523,"y":2087,"wires":[["96ac3b58.0f1308"]]},{"id":"96ac3b58.0f1308","type":"change","z":"13bcbd83.ab1fe2","name":"Set URL","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":674,"y":2087,"wires":[["7d5cc0ff.3b1b5"]]},{"id":"7d5cc0ff.3b1b5","type":"http request","z":"13bcbd83.ab1fe2","name":"m4_disable","method":"GET","ret":"txt","url":"","tls":"","x":804,"y":2087,"wires":[["2465f582.96a4fa"]]},{"id":"2465f582.96a4fa","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"replaceAll","params":[{"type":"str","value":"[Succeed]set ok."},{"type":"str","value":"{ \"val\": \"OFF\" }"}]},{"name":"replaceAll","params":[{"type":"str","value":"[Error]Param error."},{"type":"str","value":"{ \"val\": \"Error\" }"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":934,"y":2087,"wires":[["8a638b6c.d0faa8","a943350b.a43d68"]]},{"id":"a5a83c06.8beda","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":817,"y":2129,"wires":[["d8a60201.277a3"]]},{"id":"dfc123c4.fd5a4","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":677,"y":2129,"wires":[["ff0a93e3.d4a31"]]},{"id":"23e4dba9.e821d4","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":517,"y":2129,"wires":[["ccd574b0.78f4d8"]]},{"id":"8a638b6c.d0faa8","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":1072,"y":2084,"wires":[["1186a292.001ded"]]},{"id":"1186a292.001ded","type":"ui_text","z":"13bcbd83.ab1fe2","group":"7b82c3d3.aea4ac","order":10,"width":0,"height":0,"name":"Area 4","label":"Area 4","format":"{{msg.payload.val}}","layout":"row-spread","x":1194,"y":2084,"wires":[]},{"id":"ec5ca73a.447f28","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":271,"y":2068,"wires":[["3f1bf29b.12152e"]]},{"id":"d8a60201.277a3","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"m4_sensitivity"},{"type":"str","value":"val"}]},{"name":"replaceAll","params":[{"type":"str","value":"25\","},{"type":"str","value":"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"75\","},{"type":"str","value":"ON\","}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":907,"y":2183,"wires":[["8a638b6c.d0faa8"]]},{"id":"ff0a93e3.d4a31","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":737,"y":2189,"wires":[["a5a83c06.8beda"]]},{"id":"ccd574b0.78f4d8","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":587,"y":2189,"wires":[["dfc123c4.fd5a4"]]},{"id":"f0ec4a6f.f1f188","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area4/highsensitivity/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":151,"y":2108,"wires":[["ec5ca73a.447f28"]]},{"id":"a943350b.a43d68","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area4/highsensitivity/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1081,"y":2047,"wires":[]},{"id":"d3e7e4d.160c618","type":"http request","z":"13bcbd83.ab1fe2","name":"getmdattr","method":"GET","ret":"txt","url":"","tls":"","x":820,"y":1915,"wires":[["882c55c3.e76938"]]},{"id":"67705f2c.8b401","type":"function","z":"13bcbd83.ab1fe2","name":"getmdattr","func":"var ip = msg.payload.ip;\nvar user = msg.payload.user;\nvar password = msg.payload.password;\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 update: \" + currentdate + \" - \" + currenttime});\n\nmsg.topic = \"getmdattr\";\nmsg.payload = ip+\"/param.cgi?cmd=getmdattr&-usr=\"+user+\"&-pwd=\"+password;\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":1915,"wires":[["4f767032.51599"]]},{"id":"fdad471.d5f63b8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"","topic":"ipcam/login","qos":"2","broker":"47feb3e4.56f11c","x":520,"y":1915,"wires":[["815fff53.223ff"]]},{"id":"882c55c3.e76938","type":"string","z":"13bcbd83.ab1fe2","name":"toJSON","methods":[{"name":"delRightMost","params":[{"type":"str","value":";"}]},{"name":"append","params":[{"type":"str","value":" }"}]},{"name":"prepend","params":[{"type":"str","value":"{ "}]},{"name":"replaceAll","params":[{"type":"str","value":"var "},{"type":"str","value":"\""}]},{"name":"replaceAll","params":[{"type":"str","value":"="},{"type":"str","value":"\":"}]},{"name":"replaceAll","params":[{"type":"str","value":";"},{"type":"str","value":","}]},{"name":"replaceAll","params":[{"type":"str","value":"m3_sensitivity"},{"type":"str","value":"val"}]},{"name":"replaceAll","params":[{"type":"str","value":"25\","},{"type":"str","value":"OFF\","}]},{"name":"replaceAll","params":[{"type":"str","value":"75\","},{"type":"str","value":"ON\","}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":910,"y":1969,"wires":[["2cd8a384.267c5c"]]},{"id":"4f767032.51599","type":"change","z":"13bcbd83.ab1fe2","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1975,"wires":[["d3e7e4d.160c618"]]},{"id":"815fff53.223ff","type":"json","z":"13bcbd83.ab1fe2","name":"","property":"payload","action":"","pretty":false,"x":590,"y":1975,"wires":[["67705f2c.8b401"]]},{"id":"e790268f.0f92e8","type":"mqtt in","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area3/highsensitivity/enable/set","qos":"1","broker":"47feb3e4.56f11c","x":148,"y":1895,"wires":[["7d588e45.801a"]]},{"id":"95056a19.1a8fa8","type":"mqtt out","z":"13bcbd83.ab1fe2","name":"OpenHAB","topic":"openhab/alarm/setmdattr/area3/highsensitivity/enable/get","qos":"1","retain":"false","broker":"47feb3e4.56f11c","x":1078,"y":1835,"wires":[]},{"id":"c460a35.556896","type":"switch","z":"13bcbd83.ab1fe2","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":390,"y":1647,"wires":[["97abcdec.c89ec"],["f0754575.962a48"]]},{"id":"59a9cb9.48fe734","type":"switch","z":"13bcbd83.ab1fe2","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":390,"y":1857,"wires":[["bcb50b92.f9c128"],["f9948f48.8db0b"]]},{"id":"3f1bf29b.12152e","type":"switch","z":"13bcbd83.ab1fe2","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":390,"y":2068,"wires":[["8ae7454a.e765f8"],["95ff166c.95c538"]]},{"id":"64df6c86.1e0a94","type":"comment","z":"13bcbd83.ab1fe2","name":"Activate Areas","info":"","x":90,"y":300,"wires":[]},{"id":"515c3296.6e38fc","type":"comment","z":"13bcbd83.ab1fe2","name":"High Sensitivity","info":"","x":90,"y":1320,"wires":[]},{"id":"c0689660.4e98c8","type":"ui_group","z":"","name":"Camera Login","tab":"7a3391b6.03a81","order":1,"disp":true,"width":"6","collapse":false},{"id":"47feb3e4.56f11c","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"eb6d72f9.38466","type":"ui_group","z":"","name":"Motion Detection","tab":"7a3391b6.03a81","disp":true,"width":"6","collapse":false},{"id":"7b82c3d3.aea4ac","type":"ui_group","z":"","name":"Motion Detection Sensitivity","tab":"7a3391b6.03a81","disp":true,"width":"6","collapse":false},{"id":"7a3391b6.03a81","type":"ui_tab","z":"","name":"Wiki Tutorial","icon":"dashboard","order":29}]