[ { "id": "4c58b98e8c65fb19", "type": "tab", "label": "Portal sensors", "disabled": false, "info": "", "env": [] }, { "id": "09991c7a1d9c9ea4", "type": "inject", "z": "4c58b98e8c65fb19", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "10", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 110, "y": 120, "wires": [ [ "4cf1211a8f1ad88c" ] ] }, { "id": "539ff8155c2c3eaf", "type": "http request", "z": "4c58b98e8c65fb19", "name": "", "method": "GET", "ret": "txt", "paytoqs": "ignore", "url": "", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [], "x": 410, "y": 120, "wires": [ [ "89d77fb75653efd1" ] ] }, { "id": "89d77fb75653efd1", "type": "xml", "z": "4c58b98e8c65fb19", "name": "XML Parse", "property": "payload", "attr": "", "chr": "", "x": 570, "y": 120, "wires": [ [ "63f6cef709ca5b8e", "022f613c5e177297" ] ] }, { "id": "63f6cef709ca5b8e", "type": "debug", "z": "4c58b98e8c65fb19", "name": "json object", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 570, "y": 180, "wires": [] }, { "id": "64fe7a357f647d44", "type": "comment", "z": "4c58b98e8c65fb19", "name": "XML", "info": "", "x": 90, "y": 80, "wires": [] }, { "id": "022f613c5e177297", "type": "function", "z": "4c58b98e8c65fb19", "name": "format data", "func": "var data = msg.payload[\"Root\"].Devices[0].Device\n\nmsg.sensors = [] // includes digital inputs\nmsg.payload = data[0].Groups[0].Group[0].Sensors[0].Sensor\n\n/* append all sensors and digital inputs to an array */\nfor (let i = 0; i < data.length; i++) {\n const device = data[i];\n for (let j = 0; j < device.Groups[0].Group[0].Sensors[0].Sensor.length; j++) {\n const element = device.Groups[0].Group[0].Sensors[0].Sensor[j];\n msg.sensors.push(element)\n } \n}\n\nreturn msg\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 750, "y": 120, "wires": [ [ "32b1f5360e4b971e", "caa22524a898bd27" ] ] }, { "id": "32b1f5360e4b971e", "type": "debug", "z": "4c58b98e8c65fb19", "name": "msg.sensors", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "sensors", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 790, "y": 180, "wires": [] }, { "id": "4cf1211a8f1ad88c", "type": "change", "z": "4c58b98e8c65fb19", "name": "CONFIG", "rules": [ { "t": "set", "p": "url", "pt": "msg", "to": "https://sensdesk.com/sensdesk/dashboard/17278/values.xml?values_xml_key=vss4Q8GdAE49eZnD9y4HGL-TQFqcf_ZHpPY5gK5NdDQ", "tot": "str" }, { "t": "set", "p": "g1_id", "pt": "flow", "to": "282380", "tot": "str" }, { "t": "set", "p": "g2_id", "pt": "flow", "to": "282409", "tot": "str" }, { "t": "set", "p": "g3_id", "pt": "flow", "to": "282385", "tot": "str" }, { "t": "set", "p": "g4_id", "pt": "flow", "to": "282383", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 260, "y": 120, "wires": [ [ "539ff8155c2c3eaf" ] ] }, { "id": "592a8c872d62d90f", "type": "comment", "z": "4c58b98e8c65fb19", "name": "SET CONFIG DATA HERE", "info": "msg.url\n copy-paste the url from your sensdesk account here\n \nflow.g1_id\n set the ID of the sensor/digital input that will be displayed in group 1\n\nflow.g2_id\n set the ID of the sensor/digital input that will be displayed in group 2\n\nflow.g3_id\n set the ID of the sensor/digital input that will be displayed in group 3\n\nflow.g4_id\n set the ID of the sensor/digital input that will be displayed in group 4", "x": 270, "y": 80, "wires": [] }, { "id": "633e119f2a1dec81", "type": "comment", "z": "4c58b98e8c65fb19", "name": "Fetch data", "info": "", "x": 560, "y": 20, "wires": [] }, { "id": "4c23d9ac9a027b29", "type": "ui_gauge", "z": "4c58b98e8c65fb19", "name": "", "group": "c133371acc1bb9c4", "order": 4, "width": 0, "height": 0, "gtype": "gage", "title": "{{msg.name}}", "label": "", "format": "{{value}} {{units}}", "min": "0", "max": "10", "colors": [ "#00b500", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "diff": false, "className": "", "x": 270, "y": 560, "wires": [] }, { "id": "38c4a88c28736f66", "type": "ui_chart", "z": "4c58b98e8c65fb19", "name": "chart", "group": "c133371acc1bb9c4", "order": 4, "width": 0, "height": 0, "label": "{{msg.name}}", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "waiting for data", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "", "removeOlderUnit": "604800", "cutout": 0, "useOneColor": false, "useUTC": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "outputs": 1, "useDifferentColor": false, "className": "", "x": 250, "y": 600, "wires": [ [] ] }, { "id": "a3a22ad4a9265dd2", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "c133371acc1bb9c4", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 180, "y": 440, "wires": [] }, { "id": "2c1f351f99e7c866", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "c133371acc1bb9c4", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 180, "y": 480, "wires": [] }, { "id": "6a9ef7113bc197f6", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "c133371acc1bb9c4", "order": 3, "width": 0, "height": 0, "name": "state", "label": "State:", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 180, "y": 520, "wires": [] }, { "id": "cffe384eb2dd8922", "type": "ui_ui_control", "z": "4c58b98e8c65fb19", "name": "hide/show groups", "events": "all", "x": 190, "y": 320, "wires": [ [] ] }, { "id": "6213b3b3ac3e368d", "type": "link out", "z": "4c58b98e8c65fb19", "name": "G1 sen out", "mode": "link", "links": [ "c5f7a848ca3231c4" ], "x": 245, "y": 360, "wires": [] }, { "id": "c5f7a848ca3231c4", "type": "link in", "z": "4c58b98e8c65fb19", "name": "G1 sen in", "links": [ "6213b3b3ac3e368d" ], "x": 75, "y": 520, "wires": [ [ "6a9ef7113bc197f6", "a3a22ad4a9265dd2", "2c1f351f99e7c866", "d64cfbe6bb474f5a", "bace9a7d4387e6ba" ] ] }, { "id": "d64cfbe6bb474f5a", "type": "function", "z": "4c58b98e8c65fb19", "name": "range", "func": "msg.ui_control = { \n \"min\": msg.min, \n \"max\": msg.max, \n \"name\": msg.name,\n }\n\nmsg.payload = msg.value\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 150, "y": 560, "wires": [ [ "4c23d9ac9a027b29" ] ] }, { "id": "96216e0c846c3f5b", "type": "function", "z": "4c58b98e8c65fb19", "name": "func 1", "func": "var sensor = new Object\nvar di = new Object\nvar element\nvar group_id = flow.get(\"g1_id\")\nvar i\n\n// get index of desired sensor/digital input\ntry {\n i = msg.sensors.findIndex(e => e[\"$\"][\"sens_id\"] === group_id);\n} catch {\n i = -2\n}\n\nif (i > -1) {\n if (msg.sensors[i][\"Value\"][0] > -100) { // check for ivalid/disconnected sensors\n element = msg.sensors[i]\n\n // check if the ID has changed, if yes reset the chart\n if (element[\"$\"][\"sens_id\"] !== flow.get(\"g1_dat\")[\"$\"][\"sens_id\"]) {\n sensor.reset_chart = true\n } else {\n sensor.reset_chart = false\n }\n\n sensor.enabled = true\n flow.set(\"g1_dat\", element)\n } else {\n // if the sensor is disconnected, get historic values and grey out the Group\n sensor.enabled = false\n element = flow.get(\"g1_dat\")\n\n }\n \n // get data for sensors\n if (element[\"Senstype\"][0][\"_\"] == \"Generic sensor\") {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0]) / 10\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = (parseInt(element[\"Min\"][0])/10) - 10\n sensor.max = (parseInt(element[\"Max\"][0])/10) + 10\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_1_di\"], \"show\": [\"Portal_sensors_group_1_sen\"], \"focus\": true } }\n \n // get data for digital inputs\n } else if (element[\"Senstype\"][0][\"_\"] == \"Binary input\") {\n di.name = element[\"Alias\"][0]\n di.id = element[\"$\"][\"sens_id\"]\n di.value = element[\"Value\"][0]\n di.state = element[\"State\"][0]\n di.enabled = true\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_1_sen\"], \"show\": [\"Portal_sensors_group_1_di\"], \"focus\": true } }\n \n \n } else { // if Senstype is Unknown\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0])\n if (element[\"Value\"][0].length == 3) { sensor.value /= 10 } // divide by 10 if the value has 3 digits\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = parseInt(element[\"Min\"][0]) - 2 \n sensor.max = parseInt(element[\"Max\"][0]) + 2\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_1_di\"], \"show\": [\"Portal_sensors_group_1_sen\"], \"focus\": true } }\n }\n} else {\n sensor.name = \"INVALID ID\"\n sensor.enabled = false\n}\nreturn [msg, sensor, di];", "outputs": 3, "noerr": 0, "initialize": "// Code added here will be run once\n// whenever the node is started.\n\nflow.set(\"g1_dat\", {\"$\": {\"sens_id\": \"x\"}})", "finalize": "", "libs": [], "x": 130, "y": 380, "wires": [ [ "cffe384eb2dd8922" ], [ "6213b3b3ac3e368d" ], [ "41a445f09568895c" ] ] }, { "id": "bace9a7d4387e6ba", "type": "function", "z": "4c58b98e8c65fb19", "name": "func", "func": "if (msg.reset_chart) {\n msg.payload = []\n} else {\n msg.payload = msg.value\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 130, "y": 600, "wires": [ [ "38c4a88c28736f66" ] ] }, { "id": "94ae2567a0e152a2", "type": "comment", "z": "4c58b98e8c65fb19", "name": "Group 1", "info": "", "x": 160, "y": 280, "wires": [] }, { "id": "caa22524a898bd27", "type": "link out", "z": "4c58b98e8c65fb19", "name": "link out 4", "mode": "link", "links": [ "b293765f0f51eba7", "590c815754f81ad7", "20947ba38f8f216a", "a7e9d0317e8f9a57", "ecc4a8b70b0df6d0", "d0fe4524220854f9" ], "x": 925, "y": 120, "wires": [] }, { "id": "590c815754f81ad7", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 6", "links": [ "caa22524a898bd27", "415a225e2e0e7e30" ], "x": 35, "y": 380, "wires": [ [ "96216e0c846c3f5b" ] ] }, { "id": "8be409a44d86950d", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "f218a341244d1b7f", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 190, "y": 660, "wires": [] }, { "id": "87514124568efda4", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "f218a341244d1b7f", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 190, "y": 700, "wires": [] }, { "id": "1c2e61afe529073b", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "f218a341244d1b7f", "order": 5, "width": 0, "height": 0, "name": "value", "label": "Value: ", "format": "{{msg.value}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 190, "y": 740, "wires": [] }, { "id": "16583adf31b82dee", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "f218a341244d1b7f", "order": 6, "width": 0, "height": 0, "name": "state", "label": "State: ", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 190, "y": 780, "wires": [] }, { "id": "7a0fa408bfd610d3", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 7", "links": [ "41a445f09568895c" ], "x": 75, "y": 720, "wires": [ [ "8be409a44d86950d", "87514124568efda4", "1c2e61afe529073b", "16583adf31b82dee" ] ] }, { "id": "41a445f09568895c", "type": "link out", "z": "4c58b98e8c65fb19", "name": "link out 5", "mode": "link", "links": [ "7a0fa408bfd610d3" ], "x": 245, "y": 400, "wires": [] }, { "id": "7d7c6d8a05a7f103", "type": "ui_gauge", "z": "4c58b98e8c65fb19", "name": "", "group": "59227f63bc0c2c56", "order": 4, "width": 0, "height": 0, "gtype": "gage", "title": "{{msg.name}}", "label": "", "format": "{{value}} {{units}}", "min": "0", "max": "10", "colors": [ "#00b500", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "diff": false, "className": "", "x": 590, "y": 560, "wires": [] }, { "id": "9b5f5ef978e9e462", "type": "ui_chart", "z": "4c58b98e8c65fb19", "name": "chart", "group": "59227f63bc0c2c56", "order": 4, "width": 0, "height": 0, "label": "{{msg.name}}", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "waiting for data", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "", "removeOlderUnit": "604800", "cutout": 0, "useOneColor": false, "useUTC": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "outputs": 1, "useDifferentColor": false, "className": "", "x": 570, "y": 600, "wires": [ [] ] }, { "id": "4707c8ac24ae8e0b", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "59227f63bc0c2c56", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 500, "y": 440, "wires": [] }, { "id": "f0850288d34be16a", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "59227f63bc0c2c56", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 500, "y": 480, "wires": [] }, { "id": "923492531ea72053", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "59227f63bc0c2c56", "order": 3, "width": 0, "height": 0, "name": "state", "label": "State:", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 500, "y": 520, "wires": [] }, { "id": "05cae74383233aa8", "type": "ui_ui_control", "z": "4c58b98e8c65fb19", "name": "hide/show groups", "events": "all", "x": 510, "y": 320, "wires": [ [] ] }, { "id": "4e952c5e3cc4cdd1", "type": "link out", "z": "4c58b98e8c65fb19", "name": "G1 sen out", "mode": "link", "links": [ "9cce381d5147c00f" ], "x": 565, "y": 360, "wires": [] }, { "id": "9cce381d5147c00f", "type": "link in", "z": "4c58b98e8c65fb19", "name": "G1 sen in", "links": [ "4e952c5e3cc4cdd1" ], "x": 395, "y": 520, "wires": [ [ "923492531ea72053", "4707c8ac24ae8e0b", "f0850288d34be16a", "03f699bd498c9cd3", "88ecea2138b1c337" ] ] }, { "id": "03f699bd498c9cd3", "type": "function", "z": "4c58b98e8c65fb19", "name": "range", "func": "msg.ui_control = { \n \"min\": msg.min, \n \"max\": msg.max, \n \"name\": msg.name,\n }\n\nmsg.payload = msg.value\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 470, "y": 560, "wires": [ [ "7d7c6d8a05a7f103" ] ] }, { "id": "bdcd8dbee6d38ae5", "type": "function", "z": "4c58b98e8c65fb19", "name": "func 2", "func": "var sensor = new Object\nvar di = new Object\nvar element\nvar group_id = flow.get(\"g2_id\")\nvar i\n\n// get index of desired sensor/digital input\ntry {\n i = msg.sensors.findIndex(e => e[\"$\"][\"sens_id\"] === group_id);\n} catch {\n i = -2\n}\n\nif (i > -1) {\n if (msg.sensors[i][\"Value\"][0] > -100) { // check for ivalid/disconnected sensors\n element = msg.sensors[i]\n\n // check if the ID has changed, if yes reset the chart\n if (element[\"$\"][\"sens_id\"] !== flow.get(\"g2_dat\")[\"$\"][\"sens_id\"]) {\n sensor.reset_chart = true\n } else {\n sensor.reset_chart = false\n }\n\n sensor.enabled = true\n flow.set(\"g2_dat\", element)\n } else {\n // if the sensor is disconnected, get historic values and grey out the Group\n sensor.enabled = false\n element = flow.get(\"g2_dat\")\n\n }\n \n // get data for sensors\n if (element[\"Senstype\"][0][\"_\"] == \"Generic sensor\") {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0]) / 10\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = (parseInt(element[\"Min\"][0])/10) - 10\n sensor.max = (parseInt(element[\"Max\"][0])/10) + 10\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_2_di\"], \"show\": [\"Portal_sensors_group_2_sen\"], \"focus\": true } }\n \n // get data for digital inputs\n } else if (element[\"Senstype\"][0][\"_\"] == \"Binary input\") {\n di.name = element[\"Alias\"][0]\n di.id = element[\"$\"][\"sens_id\"]\n di.value = element[\"Value\"][0]\n di.state = element[\"State\"][0]\n di.enabled = true\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_2_sen\"], \"show\": [\"Portal_sensors_group_2_di\"], \"focus\": true } }\n \n \n } else {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0])\n if (element[\"Value\"][0].length == 3) { sensor.value /= 10 } // divide by 10 if the value has 3 digits\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = parseInt(element[\"Min\"][0]) - 2 \n sensor.max = parseInt(element[\"Max\"][0]) + 2\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_2_di\"], \"show\": [\"Portal_sensors_group_2_sen\"], \"focus\": true } }\n }\n} else {\n sensor.name = \"INVALID ID\"\n sensor.enabled = false\n}\nreturn [msg, sensor, di];", "outputs": 3, "noerr": 0, "initialize": "// Code added here will be run once\n// whenever the node is started.\n\nflow.set(\"g2_dat\", { \"$\": { \"sens_id\": \"x\" } })", "finalize": "", "libs": [], "x": 450, "y": 380, "wires": [ [ "05cae74383233aa8" ], [ "4e952c5e3cc4cdd1" ], [ "f93550bf9c4e11a4" ] ] }, { "id": "88ecea2138b1c337", "type": "function", "z": "4c58b98e8c65fb19", "name": "func", "func": "if (msg.reset_chart) {\n msg.payload = []\n} else {\n msg.payload = msg.value\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 450, "y": 600, "wires": [ [ "9b5f5ef978e9e462" ] ] }, { "id": "423d91437b1c2078", "type": "comment", "z": "4c58b98e8c65fb19", "name": "Group 2", "info": "", "x": 480, "y": 280, "wires": [] }, { "id": "20947ba38f8f216a", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 8", "links": [ "caa22524a898bd27", "415a225e2e0e7e30" ], "x": 355, "y": 380, "wires": [ [ "bdcd8dbee6d38ae5" ] ] }, { "id": "f38efcfea4869af7", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "63794353779e669f", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 510, "y": 660, "wires": [] }, { "id": "5432e7b81889252d", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "63794353779e669f", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 510, "y": 700, "wires": [] }, { "id": "025c42b48f7ec62c", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "63794353779e669f", "order": 5, "width": 0, "height": 0, "name": "value", "label": "Value: ", "format": "{{msg.value}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 510, "y": 740, "wires": [] }, { "id": "1faa4b2e1ea2aa07", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "63794353779e669f", "order": 6, "width": 0, "height": 0, "name": "state", "label": "State: ", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 510, "y": 780, "wires": [] }, { "id": "38473eba99356632", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 9", "links": [ "f93550bf9c4e11a4" ], "x": 395, "y": 720, "wires": [ [ "f38efcfea4869af7", "5432e7b81889252d", "025c42b48f7ec62c", "1faa4b2e1ea2aa07" ] ] }, { "id": "f93550bf9c4e11a4", "type": "link out", "z": "4c58b98e8c65fb19", "name": "link out 6", "mode": "link", "links": [ "38473eba99356632" ], "x": 565, "y": 400, "wires": [] }, { "id": "8fdce70f147de234", "type": "ui_gauge", "z": "4c58b98e8c65fb19", "name": "", "group": "b3041be7c6063c18", "order": 4, "width": 0, "height": 0, "gtype": "gage", "title": "{{msg.name}}", "label": "", "format": "{{value}} {{units}}", "min": "0", "max": "10", "colors": [ "#00b500", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "diff": false, "className": "", "x": 930, "y": 560, "wires": [] }, { "id": "870cadef22fdb083", "type": "ui_chart", "z": "4c58b98e8c65fb19", "name": "chart", "group": "b3041be7c6063c18", "order": 4, "width": 0, "height": 0, "label": "{{msg.name}}", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "waiting for data", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "", "removeOlderUnit": "604800", "cutout": 0, "useOneColor": false, "useUTC": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "outputs": 1, "useDifferentColor": false, "className": "", "x": 910, "y": 600, "wires": [ [] ] }, { "id": "675a4c4c7d570523", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "b3041be7c6063c18", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 840, "y": 440, "wires": [] }, { "id": "19403e50fb3810d2", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "b3041be7c6063c18", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 840, "y": 480, "wires": [] }, { "id": "a8cbc883d67efecf", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "b3041be7c6063c18", "order": 3, "width": 0, "height": 0, "name": "state", "label": "State:", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 840, "y": 520, "wires": [] }, { "id": "16d54a9526318e9b", "type": "ui_ui_control", "z": "4c58b98e8c65fb19", "name": "hide/show groups", "events": "all", "x": 850, "y": 320, "wires": [ [] ] }, { "id": "458e1bcead98c829", "type": "link out", "z": "4c58b98e8c65fb19", "name": "G1 sen out", "mode": "link", "links": [ "515f3c4d5bab3ad3" ], "x": 905, "y": 360, "wires": [] }, { "id": "515f3c4d5bab3ad3", "type": "link in", "z": "4c58b98e8c65fb19", "name": "G1 sen in", "links": [ "458e1bcead98c829" ], "x": 735, "y": 520, "wires": [ [ "a8cbc883d67efecf", "675a4c4c7d570523", "19403e50fb3810d2", "0929444139512a6b", "7749c1abc3bd786a" ] ] }, { "id": "0929444139512a6b", "type": "function", "z": "4c58b98e8c65fb19", "name": "range", "func": "msg.ui_control = { \n \"min\": msg.min, \n \"max\": msg.max, \n \"name\": msg.name,\n }\n\nmsg.payload = msg.value\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 810, "y": 560, "wires": [ [ "8fdce70f147de234" ] ] }, { "id": "68fd9972a249bcef", "type": "function", "z": "4c58b98e8c65fb19", "name": "func 3", "func": "var sensor = new Object\nvar di = new Object\nvar element\nvar group_id = flow.get(\"g3_id\")\nvar i\n\n// get index of desired sensor/digital input\ntry {\n i = msg.sensors.findIndex(e => e[\"$\"][\"sens_id\"] === group_id);\n} catch {\n i = -2\n}\n\nif (i > -1) {\n if (msg.sensors[i][\"Value\"][0] > -100) { // check for ivalid/disconnected sensors\n element = msg.sensors[i]\n\n // check if the ID has changed, if yes reset the chart\n if (element[\"$\"][\"sens_id\"] !== flow.get(\"g3_dat\")[\"$\"][\"sens_id\"]) {\n sensor.reset_chart = true\n } else {\n sensor.reset_chart = false\n }\n\n sensor.enabled = true\n flow.set(\"g3_dat\", element)\n } else {\n // if the sensor is disconnected, get historic values and grey out the Group\n sensor.enabled = false\n element = flow.get(\"g3_dat\")\n\n }\n \n // get data for sensors\n if (element[\"Senstype\"][0][\"_\"] == \"Generic sensor\") {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0]) / 10\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = (parseInt(element[\"Min\"][0])/10) - 10\n sensor.max = (parseInt(element[\"Max\"][0])/10) + 10\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_3_di\"], \"show\": [\"Portal_sensors_group_3_sen\"], \"focus\": true } }\n \n // get data for digital inputs\n } else if (element[\"Senstype\"][0][\"_\"] == \"Binary input\") {\n di.name = element[\"Alias\"][0]\n di.id = element[\"$\"][\"sens_id\"]\n di.value = element[\"Value\"][0]\n di.state = element[\"State\"][0]\n di.enabled = true\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_3_sen\"], \"show\": [\"Portal_sensors_group_3_di\"], \"focus\": true } }\n \n \n } else {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0])\n if (element[\"Value\"][0].length == 3) { sensor.value /= 10 } // divide by 10 if the value has 3 digits\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = parseInt(element[\"Min\"][0]) - 2 \n sensor.max = parseInt(element[\"Max\"][0]) + 2\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_3_di\"], \"show\": [\"Portal_sensors_group_3_sen\"], \"focus\": true } }\n }\n} else {\n sensor.name = \"INVALID ID\"\n sensor.enabled = false\n}\nreturn [msg, sensor, di];", "outputs": 3, "noerr": 0, "initialize": "// Code added here will be run once\n// whenever the node is started.\n\nflow.set(\"g3_dat\", { \"$\": { \"sens_id\": \"x\" } })", "finalize": "", "libs": [], "x": 790, "y": 380, "wires": [ [ "16d54a9526318e9b" ], [ "458e1bcead98c829" ], [ "fe6c4ce221ab594a" ] ] }, { "id": "7749c1abc3bd786a", "type": "function", "z": "4c58b98e8c65fb19", "name": "func", "func": "if (msg.reset_chart) {\n msg.payload = []\n} else {\n msg.payload = msg.value\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 790, "y": 600, "wires": [ [ "870cadef22fdb083" ] ] }, { "id": "4892666fefc05aac", "type": "comment", "z": "4c58b98e8c65fb19", "name": "Group 3", "info": "", "x": 820, "y": 280, "wires": [] }, { "id": "a7e9d0317e8f9a57", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 10", "links": [ "caa22524a898bd27", "415a225e2e0e7e30" ], "x": 695, "y": 380, "wires": [ [ "68fd9972a249bcef" ] ] }, { "id": "54a2e2238ac13c96", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "26cbb28d4aa9a585", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 850, "y": 660, "wires": [] }, { "id": "14441857b76e23d7", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "26cbb28d4aa9a585", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 850, "y": 700, "wires": [] }, { "id": "e4a774d91ff5056f", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "26cbb28d4aa9a585", "order": 5, "width": 0, "height": 0, "name": "value", "label": "Value: ", "format": "{{msg.value}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 850, "y": 740, "wires": [] }, { "id": "6a20e0f3266116d5", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "26cbb28d4aa9a585", "order": 6, "width": 0, "height": 0, "name": "state", "label": "State: ", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 850, "y": 780, "wires": [] }, { "id": "7460232b59ad5f70", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 11", "links": [ "fe6c4ce221ab594a" ], "x": 735, "y": 720, "wires": [ [ "54a2e2238ac13c96", "14441857b76e23d7", "e4a774d91ff5056f", "6a20e0f3266116d5" ] ] }, { "id": "fe6c4ce221ab594a", "type": "link out", "z": "4c58b98e8c65fb19", "name": "link out 7", "mode": "link", "links": [ "7460232b59ad5f70" ], "x": 905, "y": 400, "wires": [] }, { "id": "5698a8ca0811fc7c", "type": "ui_gauge", "z": "4c58b98e8c65fb19", "name": "", "group": "9b2ea9864d0a6f2d", "order": 4, "width": 0, "height": 0, "gtype": "gage", "title": "{{msg.name}}", "label": "", "format": "{{value}} {{units}}", "min": "0", "max": "10", "colors": [ "#00b500", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "diff": false, "className": "", "x": 1270, "y": 560, "wires": [] }, { "id": "742921c62b88e71f", "type": "ui_chart", "z": "4c58b98e8c65fb19", "name": "chart", "group": "9b2ea9864d0a6f2d", "order": 4, "width": 0, "height": 0, "label": "{{msg.name}}", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "waiting for data", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "", "removeOlderUnit": "604800", "cutout": 0, "useOneColor": false, "useUTC": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "outputs": 1, "useDifferentColor": false, "className": "", "x": 1250, "y": 600, "wires": [ [] ] }, { "id": "0bcbf8d136bc4873", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "9b2ea9864d0a6f2d", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 1180, "y": 440, "wires": [] }, { "id": "6d89073c0576fe51", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "9b2ea9864d0a6f2d", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 1180, "y": 480, "wires": [] }, { "id": "dff569febc80acae", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "9b2ea9864d0a6f2d", "order": 3, "width": 0, "height": 0, "name": "state", "label": "State:", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 1180, "y": 520, "wires": [] }, { "id": "a026fcc28cfa6fd5", "type": "ui_ui_control", "z": "4c58b98e8c65fb19", "name": "hide/show groups", "events": "all", "x": 1190, "y": 320, "wires": [ [] ] }, { "id": "06179c3a3e4f11e1", "type": "link out", "z": "4c58b98e8c65fb19", "name": "G1 sen out", "mode": "link", "links": [ "e75613f8170d5142" ], "x": 1245, "y": 360, "wires": [] }, { "id": "e75613f8170d5142", "type": "link in", "z": "4c58b98e8c65fb19", "name": "G1 sen in", "links": [ "06179c3a3e4f11e1" ], "x": 1075, "y": 520, "wires": [ [ "dff569febc80acae", "0bcbf8d136bc4873", "6d89073c0576fe51", "e932596398fc1944", "1d69d01496be6b60" ] ] }, { "id": "e932596398fc1944", "type": "function", "z": "4c58b98e8c65fb19", "name": "range", "func": "msg.ui_control = { \n \"min\": msg.min, \n \"max\": msg.max, \n \"name\": msg.name,\n }\n\nmsg.payload = msg.value\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1150, "y": 560, "wires": [ [ "5698a8ca0811fc7c" ] ] }, { "id": "cdf49fd7f70e4dd0", "type": "function", "z": "4c58b98e8c65fb19", "name": "func 4", "func": "var sensor = new Object\nvar di = new Object\nvar element\nvar group_id = flow.get(\"g4_id\")\nvar i\n\n// get index of desired sensor/digital input\ntry {\n i = msg.sensors.findIndex(e => e[\"$\"][\"sens_id\"] === group_id);\n} catch {\n i = -2\n}\n\nif (i > -1) {\n if (msg.sensors[i][\"Value\"][0] > -100) { // check for ivalid/disconnected sensors\n element = msg.sensors[i]\n\n // check if the ID has changed, if yes reset the chart\n if (element[\"$\"][\"sens_id\"] !== flow.get(\"g4_dat\")[\"$\"][\"sens_id\"]) {\n sensor.reset_chart = true\n } else {\n sensor.reset_chart = false\n }\n\n sensor.enabled = true\n flow.set(\"g4_dat\", element)\n } else {\n // if the sensor is disconnected, get historic values and grey out the Group\n sensor.enabled = false\n element = flow.get(\"g4_dat\")\n\n }\n \n // get data for sensors\n if (element[\"Senstype\"][0][\"_\"] == \"Generic sensor\") {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0]) / 10\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = (parseInt(element[\"Min\"][0])/10) - 10\n sensor.max = (parseInt(element[\"Max\"][0])/10) + 10\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_4_di\"], \"show\": [\"Portal_sensors_group_4_sen\"], \"focus\": true } }\n \n // get data for digital inputs\n } else if (element[\"Senstype\"][0][\"_\"] == \"Binary input\") {\n di.name = element[\"Alias\"][0]\n di.id = element[\"$\"][\"sens_id\"]\n di.value = element[\"Value\"][0]\n di.state = element[\"State\"][0]\n di.enabled = true\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_4_sen\"], \"show\": [\"Portal_sensors_group_4_di\"], \"focus\": true } }\n \n \n } else {\n sensor.name = element[\"Alias\"][0]\n sensor.id = element[\"$\"][\"sens_id\"]\n sensor.state = element[\"State\"][0]\n sensor.value = parseInt(element[\"Value\"][0])\n if (element[\"Value\"][0].length == 3) { sensor.value /= 10 } // divide by 10 if the value has 3 digits\n sensor.units = element[\"Units\"][0][\"_\"]\n sensor.min = parseInt(element[\"Min\"][0]) - 2 \n sensor.max = parseInt(element[\"Max\"][0]) + 2\n msg.payload = { \"group\": { \"hide\": [\"Portal_sensors_group_4_di\"], \"show\": [\"Portal_sensors_group_4_sen\"], \"focus\": true } }\n }\n} else {\n sensor.name = \"INVALID ID\"\n sensor.enabled = false\n}\nreturn [msg, sensor, di];", "outputs": 3, "noerr": 0, "initialize": "// Code added here will be run once\n// whenever the node is started.\n\nflow.set(\"g4_dat\", { \"$\": { \"sens_id\": \"x\" } })", "finalize": "", "libs": [], "x": 1130, "y": 380, "wires": [ [ "a026fcc28cfa6fd5" ], [ "06179c3a3e4f11e1" ], [ "ca7c237184ee4d51" ] ] }, { "id": "1d69d01496be6b60", "type": "function", "z": "4c58b98e8c65fb19", "name": "func", "func": "if (msg.reset_chart) {\n msg.payload = []\n} else {\n msg.payload = msg.value\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1130, "y": 600, "wires": [ [ "742921c62b88e71f" ] ] }, { "id": "e884cc80205fb286", "type": "comment", "z": "4c58b98e8c65fb19", "name": "Group 4", "info": "", "x": 1160, "y": 280, "wires": [] }, { "id": "ecc4a8b70b0df6d0", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 12", "links": [ "caa22524a898bd27", "415a225e2e0e7e30" ], "x": 1035, "y": 380, "wires": [ [ "cdf49fd7f70e4dd0" ] ] }, { "id": "6ae69e2206d366f2", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "e6a83e8535a8fb07", "order": 1, "width": 0, "height": 0, "name": "name", "label": "", "format": "{{msg.name}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": "20", "color": "#000000", "x": 1190, "y": 660, "wires": [] }, { "id": "112580ec728f9458", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "e6a83e8535a8fb07", "order": 2, "width": 0, "height": 0, "name": "id", "label": "ID:", "format": "{{msg.id}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 1190, "y": 700, "wires": [] }, { "id": "deb825a51fca1bb6", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "e6a83e8535a8fb07", "order": 5, "width": 0, "height": 0, "name": "value", "label": "Value: ", "format": "{{msg.value}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 1190, "y": 740, "wires": [] }, { "id": "6e86064029551d97", "type": "ui_text", "z": "4c58b98e8c65fb19", "group": "e6a83e8535a8fb07", "order": 6, "width": 0, "height": 0, "name": "state", "label": "State: ", "format": "{{msg.state}}", "layout": "row-center", "className": "", "style": false, "font": "", "fontSize": 16, "color": "#000000", "x": 1190, "y": 780, "wires": [] }, { "id": "17c159d9d152c736", "type": "link in", "z": "4c58b98e8c65fb19", "name": "link in 13", "links": [ "ca7c237184ee4d51" ], "x": 1075, "y": 720, "wires": [ [ "6ae69e2206d366f2", "112580ec728f9458", "deb825a51fca1bb6", "6e86064029551d97" ] ] }, { "id": "ca7c237184ee4d51", "type": "link out", "z": "4c58b98e8c65fb19", "name": "link out 8", "mode": "link", "links": [ "17c159d9d152c736" ], "x": 1245, "y": 400, "wires": [] }, { "id": "c133371acc1bb9c4", "type": "ui_group", "name": "group_1_sen", "tab": "7b8b76128b6a31a4", "order": 1, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "f218a341244d1b7f", "type": "ui_group", "name": "group_1_di", "tab": "7b8b76128b6a31a4", "order": 2, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "59227f63bc0c2c56", "type": "ui_group", "name": "group_2_sen", "tab": "7b8b76128b6a31a4", "order": 3, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "63794353779e669f", "type": "ui_group", "name": "group_2_di", "tab": "7b8b76128b6a31a4", "order": 4, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "b3041be7c6063c18", "type": "ui_group", "name": "group_3_sen", "tab": "7b8b76128b6a31a4", "order": 5, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "26cbb28d4aa9a585", "type": "ui_group", "name": "group_3_di", "tab": "7b8b76128b6a31a4", "order": 6, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "9b2ea9864d0a6f2d", "type": "ui_group", "name": "group_4_sen", "tab": "7b8b76128b6a31a4", "order": 7, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "e6a83e8535a8fb07", "type": "ui_group", "name": "group_4_di", "tab": "7b8b76128b6a31a4", "order": 8, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "7b8b76128b6a31a4", "type": "ui_tab", "name": "Portal sensors", "icon": "dashboard", "order": 5, "disabled": false, "hidden": false } ]