INSTAR Deutschland GmbHINSTAR Deutschland GmbH

OpenHAB 2 IP Camera Control



Camera API to Node-RED to OpenHAB

In our previous tutorial we already mapped our INSTAR REST API to MQTT with Node-RED. That means, that we are now able to publish a message via the MQTT protocol and trigger Node-RED to send a CGI Command to our camera. Before we used MQTT.fx to send those messages or build a Dashboard in Node-RED to publish messages with a press of a button.

But the MQTT protocol is an IoT (Internet of Things) standard that makes you camera compatible to a wide range of IoT hardware and software home automation systems. Let us take a look how we can level this new power to integrate our IP camera into an existing smart home. Let us now use the OpenHAB interface to send commands to our camera.

OpenHAB Troubleshooting

OpenHAB logs all important system events and errors in two log files under ./userdata/events.logs and ./userdata/openhab.log in the install directory of OpenHAB (under Windows 10 this is inside the Users folder) - it is a good practice to keep those two files opened in your editor when working on configuration files:


OpenHAB


Whenever something just doesn't seem to work, take a look at those files.

Items

We already learnt how to add a dummy switch to our OpenHAB UI. Let's make this a little bit more exciting by mapping a switch to a MQTT topic - so that using the switch publishes a MQTT message that is then received by an already prepared Node-RED flow and triggers sending a CGI command (activate or deactivate Motion Detection Area 1) to our camera. And to get a feedback, whether the command was received or not, we can additionally add a text output to the UI.


OpenHAB


The code for this construct looks like this:

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

Let's break down what is happening here. First we choose an item type - in this case a Switch - and gave it a name EnableAreaOne, so we can reference it from our sitemap. We then used the MQTT binding to bind a MQTT topic mosquitto:openhab/alarm/setmdattr/enablearea1/enable/set (mosquitto is the name of MQTT broker we set up earlier) to the ON and OFF state of our switch. This is represented by the first element that starts with >, which means that it is the outgoing message. The command send by the switch, over the MQTT service, is either ON or OFF - since we our Node-RED flow requires a JSON messages, we are using the MAP Transformer to turn this command into the compliant message ({"val":"ON"} or {"val":"OFF"}).

For incoming messages - symbolized by the < in the second part of the binding - subscribes our Switch to mosquitto:openhab/alarm/setmdattr/enablearea1/enable/get which is also defined in our Node-RED flow and gives us the current state of Motion Detection area one. The incoming message here is formatted in JSON and needs to be transformed to a string value. We use the JSONPath Transoformer to give us the value of val (in the incoming message {"val":"ON"} or {"val":"OFF"}) which is setting the state of our button either in the ON or OFF position.

String

The Text-Output follows the same structure. We assign the proper type, in this case a String and give it a name (EnableAreaOneState), to be able to reference it in our sitemap. The "MD Area 1 [%s]" prefixes the message output with MD Area 1 - see OpenHAB documentation for more examples of the Java formatter class syntax. <motion> adds the Motion Detection Icon that will be displayed in front of the text output. The MQTT call is identical to the incoming message for our switch - it takes the JSON expression send over MQTT by our Node-RED flow and extracts the value of val to be displayed as the text output.

Transformation Services

The OpenHAB Transformations are used to translate data from a cluttered or technical raw value to a processed or human-readable representation. They are often useful, to interpret received Item values, like sensor readings or state variables, and to translate them into a human-readable or better processible format. You can install them through the OpenHAB PaperUI under this link:


OpenHAB


The JSONPath Transformer works out of the box. For the MAP Transformer you need to add a .map in ./conf/transform referencing the values you want to map


OpenHAB


You can see in the screenshot above that when the Switch is switched into the ON Position and the ON command is issued, it is then transformed into the JSON expression {"val":"ON"} that we then can use in our Node-RED flow.

Sitemap

To have our Switch and String output displayed, we now have to add it to the home sitemap. The sitemap file can be found in ./conf/sitemaps:


OpenHAB


sitemap home label="INSTAR - SmartOffice"
{

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

        }
}

The Sitemap Label will be displayed in the Navigation Bar above the UI and the Frame groups our items in a Material Design Card. Go and copy the source code for home.items and home.sitemap below (it adds a few more switches and text outputs to the UI) and open the OpenHAB Basic-UI under http://localhost:8080/basicui/app:


OpenHAB


Setting up Node-RED

Now we just have to import the (rather long) Node-RED export - check out the Node-RED Introduction in case that you missed it:


OpenHAB


Opening the Node-RED dashboard will show you the following UI:


OpenHAB


Type in your cameras IP address (e.g. 192.168.1.116) and your admin login - this will make the login available to all Node-RED flows (IP, username and password are set as global variables). When opening up both UI - the Node-RED Dashboard and the OpenHAB Basic-UI - you should see that they operate in sync:


OpenHAB


And the settings accurately reflect the camera configuration:


OpenHAB


Source Code

home.items

Copy the following lines into ./conf/items/home.items. In addition to the description above, we added Switches for all 4 Motion Detection areas and additional switches to change the sensitivity of the Motion Detection:

// 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

Copy the following lines into ./conf/sitemaps/home.sitemap. In addition to the description above, we added Switches for all 4 Motion Detection areas and additional switches to change the sensitivity of the Motion Detection:

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

Copy the following JSON block and use the Node-RED Import to import it into your Node-RED Flow:

[{"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}]