I am trying to set a function to compare the value of a DHT11 sensor (temperature) with a set point and if the ui-switch is off do nothing. If the temperature is bellow the setpoint and the ui switch is on then send msg 1 (so I can activate a raspberry pi pin for a relay)... I am missing something in the compare function (named Control in my flow) and can't find a way to make it work... Any leads?
[
{
"id": "3614990b.4930c6",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": ""
},
{
"id": "25fafac5.d0a986",
"type": "ui_switch",
"z": "3614990b.4930c6",
"name": "",
"label": "Heater Control",
"tooltip": "",
"group": "259009fe.9666b6",
"order": 2,
"width": 0,
"height": 0,
"passthru": false,
"decouple": "false",
"topic": "button",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 100,
"y": 580,
"wires": [
[
"fabd31c3.f7abc"
]
]
},
{
"id": "4efab544.94c5fc",
"type": "rpi-dht22",
"z": "3614990b.4930c6",
"name": "DHT11",
"topic": "DHT11",
"dht": "11",
"pintype": "0",
"pin": 4,
"x": 100,
"y": 360,
"wires": [
[
"cd903855.3ef318",
"b185c1b2.99c36",
"bf727051.9ac9c",
"891978a3.b7ab88"
]
]
},
{
"id": "265ae43d.c848dc",
"type": "inject",
"z": "3614990b.4930c6",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 110,
"y": 260,
"wires": [
[
"4efab544.94c5fc"
]
]
},
{
"id": "b185c1b2.99c36",
"type": "function",
"z": "3614990b.4930c6",
"name": "Temperature",
"func": "msg.payload;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 370,
"y": 360,
"wires": [
[
"f07772dc.1210e",
"11c7c637.48ac1a",
"cee1ffdc.538a1"
]
]
},
{
"id": "bf727051.9ac9c",
"type": "function",
"z": "3614990b.4930c6",
"name": "Humidity",
"func": "msg.humidity\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 360,
"y": 420,
"wires": [
[
"1a949713.aa3b29",
"d5a5c.e626e5a4",
"17c662cb.10668d"
]
]
},
{
"id": "cd903855.3ef318",
"type": "debug",
"z": "3614990b.4930c6",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 390,
"y": 300,
"wires": []
},
{
"id": "cee1ffdc.538a1",
"type": "debug",
"z": "3614990b.4930c6",
"name": "Temperature Value",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 650,
"y": 300,
"wires": []
},
{
"id": "1a949713.aa3b29",
"type": "debug",
"z": "3614990b.4930c6",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "humidity",
"targetType": "msg",
"x": 620,
"y": 420,
"wires": []
},
{
"id": "f07772dc.1210e",
"type": "ui_gauge",
"z": "3614990b.4930c6",
"name": "Temperature",
"group": "259009fe.9666b6",
"order": 1,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperature",
"label": "C",
"format": "{{value}}",
"min": "-10",
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 630,
"y": 340,
"wires": []
},
{
"id": "d5a5c.e626e5a4",
"type": "ui_gauge",
"z": "3614990b.4930c6",
"name": "Humidity",
"group": "259009fe.9666b6",
"order": 3,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Humidity",
"label": "%",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 600,
"y": 460,
"wires": []
},
{
"id": "11c7c637.48ac1a",
"type": "ui_chart",
"z": "3614990b.4930c6",
"name": "Temperature",
"group": "bed357cb.350a38",
"order": 6,
"width": 0,
"height": 0,
"label": "Temperature chart",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "-20",
"ymax": "50",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": false,
"outputs": 1,
"x": 630,
"y": 380,
"wires": [
[]
]
},
{
"id": "17c662cb.10668d",
"type": "ui_chart",
"z": "3614990b.4930c6",
"name": "Humidity",
"group": "bed357cb.350a38",
"order": 7,
"width": 0,
"height": 0,
"label": "Humiditychart",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "100",
"removeOlder": "5",
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": false,
"outputs": 1,
"x": 600,
"y": 500,
"wires": [
[]
]
},
{
"id": "3307cc3d.4b2854",
"type": "debug",
"z": "3614990b.4930c6",
"name": "Heater ON",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 650,
"y": 580,
"wires": []
},
{
"id": "4d60f6c8.498338",
"type": "debug",
"z": "3614990b.4930c6",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "radio",
"targetType": "msg",
"x": 320,
"y": 640,
"wires": []
},
{
"id": "606640bd.62404",
"type": "function",
"z": "3614990b.4930c6",
"name": "Control",
"func": "if(msg.temperature <= 20) {\n if(msg.radio === true) {\n msg.payload = 1;\n return msg;\n }\n}",
"outputs": 1,
"noerr": 0,
"x": 500,
"y": 580,
"wires": [
[
"3307cc3d.4b2854"
]
]
},
{
"id": "891978a3.b7ab88",
"type": "change",
"z": "3614990b.4930c6",
"name": "payload_to_temperature",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "temperature",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 170,
"y": 500,
"wires": [
[
"606640bd.62404"
]
]
},
{
"id": "fabd31c3.f7abc",
"type": "change",
"z": "3614990b.4930c6",
"name": "payload_to_radio",
"rules": [
{
"t": "move",
"p": "payload",
"pt": "msg",
"to": "radio",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 310,
"y": 580,
"wires": [
[
"606640bd.62404",
"4d60f6c8.498338"
]
]
},
{
"id": "259009fe.9666b6",
"type": "ui_group",
"z": "",
"name": "Home",
"tab": "de03cc52.a371c",
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "bed357cb.350a38",
"type": "ui_group",
"z": "",
"name": "Home",
"tab": "3e12347.8eb56cc",
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "de03cc52.a371c",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "3e12347.8eb56cc",
"type": "ui_tab",
"z": "",
"name": "History",
"icon": "dashboard",
"order": 2,
"disabled": false,
"hidden": false
}
]```