Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node-RED Flow ESP32 MQTT Publish/Subscribe
[
{
"id": "d0c256a4.6e3e48",
"type": "tab",
"label": "ESP32 MQTT Dashboard Environmental Parameters",
"disabled": false,
"info": ""
},
{
"id": "454852c9.ec7f5c",
"type": "mqtt-broker",
"name": "EMQ X Edge",
"broker": "mqtt-broker",
"port": "1883",
"clientid": "mqtt-dashboard",
"usetls": false,
"compatmode": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
},
{
"id": "8e0db1d6.df2db",
"type": "ui_group",
"name": "Temperature",
"tab": "ecad0e7f.423a18",
"order": 1,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "a3dd2012.9790b",
"type": "ui_group",
"name": "Humidity",
"tab": "ecad0e7f.423a18",
"order": 2,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "3137f438.fe5684",
"type": "ui_group",
"name": "Pressure",
"tab": "ecad0e7f.423a18",
"order": 3,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "c4f5ebb.11a6318",
"type": "ui_group",
"name": "Temperature",
"tab": "53df88d3.a3a6f",
"order": 1,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "aed82842.e12018",
"type": "ui_group",
"name": "Humidity",
"tab": "53df88d3.a3a6f",
"order": 2,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "f4f27a9e.d912a8",
"type": "ui_group",
"name": "Pressure",
"tab": "53df88d3.a3a6f",
"order": 3,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "67bd5df3.839de4",
"type": "ui_group",
"name": "Relay Status",
"tab": "ecad0e7f.423a18",
"order": 5,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "a45b15d8.074c6",
"type": "ui_group",
"name": "Relay Status",
"tab": "53df88d3.a3a6f",
"order": 4,
"disp": true,
"width": "8",
"collapse": true
},
{
"id": "ecad0e7f.423a18",
"type": "ui_tab",
"name": "ESP32 Device 1",
"icon": "developer_dashboard",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "53df88d3.a3a6f",
"type": "ui_tab",
"name": "ESP32 Device 2",
"icon": "developer_dashboard",
"order": 2,
"disabled": false,
"hidden": false
},
{
"id": "fda0d5aa.911dd",
"type": "ui_base",
"theme": {
"name": "theme-dark",
"lightTheme": {
"default": "#0094CE",
"baseColor": "#0094CE",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"darkTheme": {
"default": "#097479",
"baseColor": "#097479",
"baseFont": "Trebuchet MS,Helvetica,sans-serif",
"edited": true,
"reset": false
},
"customTheme": {
"name": "Untitled Theme 1",
"default": "#4B7930",
"baseColor": "#4B7930",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
},
"themeState": {
"base-color": {
"default": "#097479",
"value": "#097479",
"edited": false
},
"page-titlebar-backgroundColor": {
"value": "#097479",
"edited": false
},
"page-backgroundColor": {
"value": "#111111",
"edited": false
},
"page-sidebar-backgroundColor": {
"value": "#333333",
"edited": false
},
"group-textColor": {
"value": "#0eb8c0",
"edited": false
},
"group-borderColor": {
"value": "#555555",
"edited": false
},
"group-backgroundColor": {
"value": "#333333",
"edited": false
},
"widget-textColor": {
"value": "#eeeeee",
"edited": false
},
"widget-backgroundColor": {
"value": "#097479",
"edited": false
},
"widget-borderColor": {
"value": "#333333",
"edited": false
},
"base-font": {
"value": "Trebuchet MS,Helvetica,sans-serif"
}
},
"angularTheme": {
"primary": "indigo",
"accents": "blue",
"warn": "red",
"background": "grey",
"palette": "dark"
}
},
"site": {
"name": "ESP32 MQTT Dashboard Environmental Parameters",
"hideToolbar": "false",
"allowSwipe": "true",
"lockMenu": "false",
"allowTempTheme": "none",
"dateFormat": "DD/MM/YYYY",
"sizes": {
"sx": 80,
"sy": 80,
"gx": 6,
"gy": 6,
"cx": 6,
"cy": 6,
"px": 0,
"py": 0
}
}
},
{
"id": "a864717c.68151",
"type": "mqtt in",
"z": "d0c256a4.6e3e48",
"name": "Telemetry Data",
"topic": "esp32/telemetry_data",
"qos": "0",
"datatype": "json",
"broker": "454852c9.ec7f5c",
"nl": false,
"rap": false,
"rh": "0",
"x": 220,
"y": 340,
"wires": [
[
"9ba4d9a9.3f784",
"b1445673.b8d8b",
"52152535.d8cafc"
]
],
"outputLabels": [
"Telemetry Data from esp32/telemetry_data topic"
]
},
{
"id": "9ba4d9a9.3f784",
"type": "switch",
"z": "d0c256a4.6e3e48",
"name": "Filter Message for ESP32 Zone 1 Device",
"property": "payload.deviceName",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "esp32-zone-1",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 540,
"y": 180,
"wires": [
[
"8118d063.8f9128"
]
]
},
{
"id": "b1445673.b8d8b",
"type": "switch",
"z": "d0c256a4.6e3e48",
"name": "Filter Message for ESP32 Zone 2 Device",
"property": "payload.deviceName",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "esp32-zone-2",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 540,
"y": 500,
"wires": [
[
"14d1e1aa.a9f416"
]
]
},
{
"id": "8118d063.8f9128",
"type": "function",
"z": "d0c256a4.6e3e48",
"name": "Split Telemetry Data and Relay Status",
"func": "// Get data of the the temperature, humidity and pressure\nvar temperature = { payload: msg.payload.temperature };\nvar humidity = { payload: msg.payload.humidity };\nvar pressure = { payload: msg.payload.pressure };\n\n// Get data of the relay status\nvar relayStatus00 = {payload: msg.payload.relaysStatus[0]}\nvar relayStatus01 = {payload: msg.payload.relaysStatus[1]}\nvar relayStatus02 = {payload: msg.payload.relaysStatus[2]}\nvar relayStatus03 = {payload: msg.payload.relaysStatus[3]}\n\n// Return all values\nreturn [temperature, humidity, pressure, relayStatus00, relayStatus01, relayStatus02, relayStatus03];",
"outputs": 7,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 180,
"wires": [
[
"a0cec44c.72f648"
],
[
"b0660c2e.0fbf8"
],
[
"d39e9242.5c96c8"
],
[
"f45206c5.235268"
],
[
"86db0b3e.a2bf5"
],
[
"4e69fd9.c1a1104"
],
[
"6c728c9f.0dd624"
]
],
"inputLabels": [
"Telemetry Data"
],
"outputLabels": [
"Temperature",
"Humidity",
"Pressure",
"Status Relay 0",
"Status Relay 1",
"Status Relay 2",
"Status Relay 3"
]
},
{
"id": "14d1e1aa.a9f416",
"type": "function",
"z": "d0c256a4.6e3e48",
"name": "Split Telemetry Data and Relay Status",
"func": "// Get data of the the temperature, humidity and pressure\nvar temperature = { payload: msg.payload.temperature };\nvar humidity = { payload: msg.payload.humidity };\nvar pressure = { payload: msg.payload.pressure };\n\n// Get data of the relay status\nvar relayStatus00 = {payload: msg.payload.relaysStatus[0]}\nvar relayStatus01 = {payload: msg.payload.relaysStatus[1]}\nvar relayStatus02 = {payload: msg.payload.relaysStatus[2]}\nvar relayStatus03 = {payload: msg.payload.relaysStatus[3]}\n\n// Return all values\nreturn [temperature, humidity, pressure, relayStatus00, relayStatus01, relayStatus02, relayStatus03];",
"outputs": 7,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 950,
"y": 500,
"wires": [
[
"fae56762.4b501"
],
[
"e2f11d45.fc6f3"
],
[
"7b59f39a.9bb7a4"
],
[
"d91f484b.9ce0a8"
],
[
"40acb59f.c0a10c"
],
[
"7e1b89d6.42ebc8"
],
[
"84c9a371.bfbfa8"
]
],
"inputLabels": [
"Telemetry Data"
],
"outputLabels": [
"Temperature",
"Humidity",
"Pressure",
"Status Relay 0",
"Status Relay 1",
"Status Relay 2",
"Status Relay 3"
]
},
{
"id": "a0cec44c.72f648",
"type": "ui_gauge",
"z": "d0c256a4.6e3e48",
"name": "Temperature",
"group": "8e0db1d6.df2db",
"order": 1,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperature",
"label": "° C",
"format": "{{value}}",
"min": "0",
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 1230,
"y": 60,
"wires": []
},
{
"id": "b0660c2e.0fbf8",
"type": "ui_gauge",
"z": "d0c256a4.6e3e48",
"name": "Humidity",
"group": "a3dd2012.9790b",
"order": 1,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Humidity (in %)",
"label": "%",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 1220,
"y": 100,
"wires": []
},
{
"id": "d39e9242.5c96c8",
"type": "ui_chart",
"z": "d0c256a4.6e3e48",
"name": "Pressure",
"group": "3137f438.fe5684",
"order": 1,
"width": 0,
"height": 0,
"label": "Pressure",
"chartType": "line",
"legend": "true",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"x": 1220,
"y": 140,
"wires": [
[]
]
},
{
"id": "fae56762.4b501",
"type": "ui_gauge",
"z": "d0c256a4.6e3e48",
"name": "Temperature",
"group": "c4f5ebb.11a6318",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperature",
"label": "° C",
"format": "{{value}}",
"min": "0",
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 1230,
"y": 380,
"wires": []
},
{
"id": "e2f11d45.fc6f3",
"type": "ui_gauge",
"z": "d0c256a4.6e3e48",
"name": "Humidity",
"group": "aed82842.e12018",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Humidity (in %)",
"label": "%",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 1220,
"y": 420,
"wires": []
},
{
"id": "7b59f39a.9bb7a4",
"type": "ui_chart",
"z": "d0c256a4.6e3e48",
"name": "Pressure",
"group": "f4f27a9e.d912a8",
"order": 0,
"width": 0,
"height": 0,
"label": "Pressure",
"chartType": "line",
"legend": "true",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"x": 1220,
"y": 460,
"wires": [
[]
]
},
{
"id": "f45206c5.235268",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"order": 5,
"width": 2,
"height": 1,
"name": "Relay Status 0",
"label": "Relay 0 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 180,
"wires": []
},
{
"id": "4e69fd9.c1a1104",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"order": 7,
"width": 2,
"height": 1,
"name": "Relay Status 2",
"label": "Relay 2 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 260,
"wires": []
},
{
"id": "86db0b3e.a2bf5",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"order": 6,
"width": 2,
"height": 1,
"name": "Relay Status 1",
"label": "Relay 1 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 220,
"wires": []
},
{
"id": "6c728c9f.0dd624",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"order": 8,
"width": 2,
"height": 1,
"name": "Relay Status 3",
"label": "Relay 3 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 300,
"wires": []
},
{
"id": "84c9a371.bfbfa8",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"order": 8,
"width": "2",
"height": "1",
"name": "Relay Status 3",
"label": "Relay 3 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 620,
"wires": []
},
{
"id": "7e1b89d6.42ebc8",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"order": 7,
"width": "2",
"height": "1",
"name": "Relay Status 2",
"label": "Relay 2 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 580,
"wires": []
},
{
"id": "40acb59f.c0a10c",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"order": 6,
"width": "2",
"height": "1",
"name": "Relay Status 1",
"label": "Relay 1 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 540,
"wires": []
},
{
"id": "d91f484b.9ce0a8",
"type": "ui_text",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"order": 5,
"width": "2",
"height": "1",
"name": "Relay Status 0",
"label": "Relay 0 Status: ",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 1240,
"y": 500,
"wires": []
},
{
"id": "887d4114.c4014",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"name": "Change Status Relay 0 - Device 1",
"order": 1,
"width": 2,
"height": 2,
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-1:relay;0;on'})\"> \n Turn Relay 0 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-1:relay;0;off'})\"> \n Turn Relay 0 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 660,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "4ef93a4d.7a0e6c",
"type": "mqtt out",
"z": "d0c256a4.6e3e48",
"name": "ESP32 Command/Relay",
"topic": "esp32/command",
"qos": "1",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "454852c9.ec7f5c",
"x": 930,
"y": 820,
"wires": []
},
{
"id": "82d65ac8.b7e778",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"name": "Change Status Relay 3 - Device 1",
"order": 4,
"width": 2,
"height": 2,
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-1:relay;3;on'})\"> \n Turn Relay 3 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-1:relay;3;off'})\"> \n Turn Relay 3 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 780,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "166a7d38.7ff893",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"name": "Change Status Relay 2 - Device 1",
"order": 3,
"width": 2,
"height": 2,
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-1:relay;2;on'})\"> \n Turn Relay 2 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-1:relay;2;off'})\"> \n Turn Relay 2 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 740,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "ee87b3c0.83a58",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "67bd5df3.839de4",
"name": "Change Status Relay 1 - Device 1",
"order": 2,
"width": 2,
"height": 2,
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-1:relay;1;on'})\"> \n Turn Relay 1 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-1:relay;1;off'})\"> \n Turn Relay 1 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 700,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "8684cf29.23e6c8",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"name": "Change Status Relay 2 - Device 2",
"order": 3,
"width": "2",
"height": "2",
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-2:relay;2;on'})\"> \n Turn Relay 2 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-2:relay;2;off'})\"> \n Turn Relay 2 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 920,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "39671375.c25894",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"name": "Change Status Relay 0 - Device 2",
"order": 1,
"width": "2",
"height": "2",
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-2:relay;0;on'})\"> \n Turn Relay 0 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-2:relay;0;off'})\"> \n Turn Relay 0 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 840,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "efff08bd.26b938",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"name": "Change Status Relay 1 - Device 2",
"order": 2,
"width": "2",
"height": "2",
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-2:relay;1;on'})\"> \n Turn Relay 1 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-2:relay;1;off'})\"> \n Turn Relay 1 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 880,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "dbff7110.6f0d4",
"type": "ui_template",
"z": "d0c256a4.6e3e48",
"group": "a45b15d8.074c6",
"name": "Change Status Relay 3 - Device 2",
"order": 4,
"width": "2",
"height": "2",
"format": "<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#27ae60\" ng-click=\"send({payload: 'esp32-zone-2:relay;3;on'})\"> \n Turn Relay 3 On\n</md-button> \n\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'esp32-zone-2:relay;3;off'})\"> \n Turn Relay 3 Off\n</md-button> \n",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"x": 520,
"y": 960,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
},
{
"id": "52152535.d8cafc",
"type": "function",
"z": "d0c256a4.6e3e48",
"name": "Check Threshold Values",
"func": "// Get data of the the temperature, humidity and pressure\nvar temperature = { payload: msg.payload.temperature };\nvar humidity = { payload: msg.payload.humidity };\nvar pressure = { payload: msg.payload.pressure };\nvar deviceName = { payload: msg.payload.deviceName };\n\nif (temperature > 25 && msg.payload.relaysStatus[0] == 0) {\n msg.payload = deviceName + \":relay;0;on\";\n return msg;\n} else if (temperature < 25 && msg.payload.relaysStatus[0] == 1) {\n msg.payload = deviceName + \":relay;0;off\";\n return msg;\n}\n\nif (humidity > 60 && msg.payload.relaysStatus[1] == 0) {\n msg.payload = deviceName + \":relay;1;on\";\n return msg;\n} else if (humidity < 60 && msg.payload.relaysStatus[1] == 1) {\n msg.payload = deviceName + \":relay;1;off\";\n return msg;\n}\n\nif (pressure > 1600 && msg.payload.relaysStatus[2] == 0) {\n msg.payload = deviceName + \":relay;2;on\";\n return msg;\n} else if (pressure < 1600 && msg.payload.relaysStatus[2] == 1) {\n msg.payload = deviceName + \":relay;2;off\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 490,
"y": 340,
"wires": [
[
"4ef93a4d.7a0e6c"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment