Node Red
Node Red
{
"id": "2f601cc7a1ce95b0",
"type": "tab",
"label": "Flujo 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "3a23e3171e7c54fe",
"type": "mqtt in",
"z": "2f601cc7a1ce95b0",
"name": "",
"topic": "mqtt/CAUDAL",
"qos": "2",
"datatype": "auto-detect",
"broker": "a6049d88621935e0",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 610,
"y": 220,
"wires": [
[
"383751ae21b1dbac"
]
]
},
{
"id": "383751ae21b1dbac",
"type": "ui_chart",
"z": "2f601cc7a1ce95b0",
"name": "",
"group": "5654a62b80a1a70a",
"order": 1,
"width": "10",
"height": "5",
"label": "Caudal OUT",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 810,
"y": 220,
"wires": [
[]
]
},
{
"id": "57b7e483ddf09b21",
"type": "mqtt in",
"z": "2f601cc7a1ce95b0",
"name": "",
"topic": "mqtt/CAUDAL2",
"qos": "2",
"datatype": "auto-detect",
"broker": "a6049d88621935e0",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 620,
"y": 300,
"wires": [
[
"5a985cbdf28598ea"
]
]
},
{
"id": "5a985cbdf28598ea",
"type": "ui_chart",
"z": "2f601cc7a1ce95b0",
"name": "",
"group": "5654a62b80a1a70a",
"order": 1,
"width": "10",
"height": "5",
"label": "Caudal IN",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 800,
"y": 300,
"wires": [
[]
]
},
{
"id": "4bf926b9a877a171",
"type": "mqtt in",
"z": "2f601cc7a1ce95b0",
"name": "",
"topic": "mqtt/NIVEL",
"qos": "2",
"datatype": "auto",
"broker": "a6049d88621935e0",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 410,
"y": 520,
"wires": [
[
"cd63833fc3e13086",
"deb15fb9c420519c",
"3295d5e42a121e18",
"c31b26696aaa4b7e"
]
]
},
{
"id": "be64dd30e2c6322c",
"type": "ui_gauge",
"z": "2f601cc7a1ce95b0",
"name": "",
"group": "fc3845d71421c45a",
"order": 3,
"width": "6",
"height": "7",
"gtype": "wave",
"title": "NIVEL",
"label": "%",
"format": "{{value}}",
"min": "0",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 1030,
"y": 520,
"wires": []
},
{
"id": "cd63833fc3e13086",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "Nivel",
"func": "let nivel = msg.payload;\nif (nivel > 5) {\n msg.payload
= \"1\";\n} else {\n msg.payload = \"0\";\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 480,
"wires": [
[
"49bab413e5ea4e42"
]
]
},
{
"id": "49bab413e5ea4e42",
"type": "debug",
"z": "2f601cc7a1ce95b0",
"name": "debug 1",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 840,
"y": 480,
"wires": []
},
{
"id": "2abe3791eca3e00c",
"type": "BooleanLogicUltimate",
"z": "2f601cc7a1ce95b0",
"name": "",
"payloadPropName": "payload",
"filtertrue": "both",
"persist": true,
"sInitializeWith": "WaitForPayload",
"triggertopic": "trigger",
"outputtriggeredby": "all",
"inputCount": 2,
"topic": "MANUAL",
"restrictinputevaluation": false,
"delayEvaluation": 0,
"translatorConfig": "",
"x": 600,
"y": 720,
"wires": [
[
"c1c9bfc1e314cfa2"
],
[],
[]
]
},
{
"id": "1a382418c66a49b1",
"type": "ui_switch",
"z": "2f601cc7a1ce95b0",
"name": "",
"label": "Manual",
"tooltip": "",
"group": "c2b79efda561f735",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "Manual",
"topicType": "str",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"animate": true,
"className": "",
"x": 260,
"y": 680,
"wires": [
[
"2abe3791eca3e00c",
"c07f32c1b0f6230e"
]
]
},
{
"id": "bd33996ddf55acab",
"type": "ui_switch",
"z": "2f601cc7a1ce95b0",
"name": "",
"label": "ON / OFF",
"tooltip": "",
"group": "c2b79efda561f735",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "Estado",
"topicType": "str",
"style": "",
"onvalue": "1",
"onvalueType": "str",
"onicon": "",
"oncolor": "",
"offvalue": "0",
"offvalueType": "str",
"officon": "",
"offcolor": "",
"animate": true,
"className": "",
"x": 260,
"y": 760,
"wires": [
[
"2abe3791eca3e00c"
]
]
},
{
"id": "c07f32c1b0f6230e",
"type": "InvertUltimate",
"z": "2f601cc7a1ce95b0",
"name": "Invert",
"payloadPropName": "payload",
"x": 410,
"y": 860,
"wires": [
[
"fa2bb9a391b47195"
]
]
},
{
"id": "fa2bb9a391b47195",
"type": "BooleanLogicUltimate",
"z": "2f601cc7a1ce95b0",
"name": "",
"payloadPropName": "payload",
"filtertrue": "both",
"persist": true,
"sInitializeWith": "WaitForPayload",
"triggertopic": "trigger",
"outputtriggeredby": "all",
"inputCount": 2,
"topic": "AUTOMATICO",
"restrictinputevaluation": false,
"delayEvaluation": 0,
"translatorConfig": "",
"x": 600,
"y": 860,
"wires": [
[
"c1c9bfc1e314cfa2"
],
[],
[]
]
},
{
"id": "c1c9bfc1e314cfa2",
"type": "BooleanLogicUltimate",
"z": "2f601cc7a1ce95b0",
"name": "",
"payloadPropName": "payload",
"filtertrue": "both",
"persist": true,
"sInitializeWith": "WaitForPayload",
"triggertopic": "trigger",
"outputtriggeredby": "all",
"inputCount": 2,
"topic": "result",
"restrictinputevaluation": false,
"delayEvaluation": 0,
"x": 820,
"y": 780,
"wires": [
[],
[
"aa0cc191b304a009"
],
[]
]
},
{
"id": "a2bc83a86191ebf8",
"type": "mqtt out",
"z": "2f601cc7a1ce95b0",
"name": "",
"topic": "mqtt/RELE",
"qos": "2",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "a6049d88621935e0",
"x": 1270,
"y": 760,
"wires": []
},
{
"id": "aa0cc191b304a009",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "Nivel",
"func": "\nlet Nivel = msg.payload;\nif (Nivel) {\n msg.payload
= \"1\";\n} else {\n msg.payload = \"0\";\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1030,
"y": 780,
"wires": [
[
"a2bc83a86191ebf8",
"d1b5b5a8cabfb754"
]
]
},
{
"id": "d1b5b5a8cabfb754",
"type": "debug",
"z": "2f601cc7a1ce95b0",
"name": "debug 2",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1160,
"y": 680,
"wires": []
},
{
"id": "ca8668343cb9049e",
"type": "mqtt in",
"z": "2f601cc7a1ce95b0",
"name": "",
"topic": "mqtt/LITROS",
"qos": "2",
"datatype": "auto-detect",
"broker": "a6049d88621935e0",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 610,
"y": 160,
"wires": [
[
"762b9bdecc8dc1e0"
]
]
},
{
"id": "762b9bdecc8dc1e0",
"type": "ui_text",
"z": "2f601cc7a1ce95b0",
"group": "fc3845d71421c45a",
"order": 2,
"width": "6",
"height": "3",
"name": "",
"label": "Litros",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 790,
"y": 160,
"wires": []
},
{
"id": "cc38361d31d24efb",
"type": "influxdb out",
"z": "2f601cc7a1ce95b0",
"influxdb": "3621c603ed0a7628",
"name": "Nivel",
"measurement": "NIVEL",
"precision": "",
"retentionPolicy": "",
"database": "database",
"precisionV18FluxV20": "ms",
"retentionPolicyV18Flux": "",
"org": "UNLAM",
"bucket": "SENSOR",
"x": 850,
"y": 440,
"wires": []
},
{
"id": "deb15fb9c420519c",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "function 1",
"func": "var Lc1 = global.get('Level_1');\nmsg.payload={\
n \"Level1\":Lc1,\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 420,
"wires": [
[
"cc38361d31d24efb"
]
]
},
{
"id": "3295d5e42a121e18",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "Comparar MQTT con Dashboard",
"func": "let mqttValue = msg.payload; // Valor recibido del mensaje MQTT
(por ejemplo, temperatura)\nlet dashboardValue = flow.get(\"dashboardValue\"); //
Valor ingresado en el Dashboard\n\nif (mqttValue >= dashboardValue) {\n
msg.payload = 1;\n} else {\n msg.payload = 0;\n}\n\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 880,
"y": 600,
"wires": [
[
"fa2bb9a391b47195"
]
]
},
{
"id": "05f172dab60f10c8",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "Guardar Valor del Dashboard",
"func": "flow.set(\"dashboardValue\", msg.payload); // Guarda el valor
ingresado en el contexto de flujo\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 960,
"wires": [
[]
]
},
{
"id": "30fc50487f489d9d",
"type": "ui_text_input",
"z": "2f601cc7a1ce95b0",
"name": "",
"label": "Mínimo",
"tooltip": "",
"group": "c2b79efda561f735",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "topic",
"sendOnBlur": true,
"className": "",
"topicType": "msg",
"x": 260,
"y": 960,
"wires": [
[
"05f172dab60f10c8"
]
]
},
{
"id": "e497fc497541485d",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "Guardar Valor del Dashboard",
"func": "flow.set(\"altura\", msg.payload); // Guarda el valor ingresado
en el contexto de flujo\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 1040,
"wires": [
[]
]
},
{
"id": "386c840cbf1196f6",
"type": "ui_text_input",
"z": "2f601cc7a1ce95b0",
"name": "",
"label": "Altura",
"tooltip": "",
"group": "c2b79efda561f735",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "topic",
"sendOnBlur": true,
"className": "",
"topicType": "msg",
"x": 230,
"y": 1040,
"wires": [
[
"e497fc497541485d"
]
]
},
{
"id": "c31b26696aaa4b7e",
"type": "function",
"z": "2f601cc7a1ce95b0",
"name": "Comparar MQTT con Dashboard",
"func": "let mqttValue = msg.payload; // Valor recibido del mensaje MQTT
(por ejemplo, temperatura)\nlet altura = flow.get(\"altura\"); // Valor ingresado
en el Dashboard\n\n// Valor mínimo y máximo\nlet minValue = 150;\nlet maxValue =
2;\n\n\n\n// Calcular el porcentaje\nlet percentage = ((altura - mqttValue) /
(altura - 5)) * 100;\n\n// Asegurarse de que el porcentaje esté en el rango 0-100\
npercentage = Math.max(0, Math.min(100, percentage));\n\n// Asignar el porcentaje
calculado a msg.payload\nmsg.payload = percentage;\n\nreturn msg;\n\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 800,
"y": 560,
"wires": [
[
"be64dd30e2c6322c"
]
]
},
{
"id": "a6049d88621935e0",
"type": "mqtt-broker",
"name": "ZEROW/MQTT",
"broker": "zerow",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "5654a62b80a1a70a",
"type": "ui_group",
"name": "Prueba",
"tab": "fd10700fe7d05ec6",
"order": 2,
"disp": true,
"width": "10",
"collapse": false,
"className": ""
},
{
"id": "fc3845d71421c45a",
"type": "ui_group",
"name": "Tanque",
"tab": "fd10700fe7d05ec6",
"order": 3,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "c2b79efda561f735",
"type": "ui_group",
"name": "Control",
"tab": "fd10700fe7d05ec6",
"order": 1,
"disp": true,
"width": "4",
"collapse": false,
"className": ""
},
{
"id": "3621c603ed0a7628",
"type": "influxdb",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "database",
"name": "Influx HP",
"usetls": false,
"tls": "",
"influxdbVersion": "2.0",
"url": "http:/192.168.0.11:8086",
"timeout": "10",
"rejectUnauthorized": false
},
{
"id": "fd10700fe7d05ec6",
"type": "ui_tab",
"name": "Caudalimetro",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]