Any help would be appreciated. I am trying to set up a flow for heater control. I want the user to be able to switch on the heater, only when the temperature is bellow the set point and the heater to switch off when the temperature is equal or above the set point. This means that the switch on the dashboard will do nothing if the temperature is above or equal the set point or switch back to off, once the temperature rises to the set point.
[
{
"id": "f499b7ea.100118",
"type": "tab",
"label": "test",
"disabled": false,
"info": ""
},
{
"id": "aebd59a1.e5b398",
"type": "ui_switch",
"z": "f499b7ea.100118",
"name": "",
"label": "switch",
"tooltip": "",
"group": "7c7fe7a7.d5e398",
"order": 5,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "",
"style": "",
"onvalue": "ON",
"onvalueType": "str",
"onicon": "",
"oncolor": "",
"offvalue": "OFF",
"offvalueType": "str",
"officon": "",
"offcolor": "",
"x": 130,
"y": 280,
"wires": [
[
"c6cef357.1f624",
"777db117.66834",
"71cec172.6fe92"
]
]
},
{
"id": "b90d81c6.9977e",
"type": "ui_slider",
"z": "f499b7ea.100118",
"name": "",
"label": "tempNow",
"tooltip": "",
"group": "7c7fe7a7.d5e398",
"order": 4,
"width": 0,
"height": 0,
"passthru": false,
"outs": "end",
"topic": "",
"min": 0,
"max": 10,
"step": 1,
"x": 120,
"y": 100,
"wires": [
[
"a03f3dc7.f3a28"
]
]
},
{
"id": "99c3bd1d.4d195",
"type": "ui_slider",
"z": "f499b7ea.100118",
"name": "",
"label": "tempSet",
"tooltip": "",
"group": "7c7fe7a7.d5e398",
"order": 7,
"width": 0,
"height": 0,
"passthru": false,
"outs": "end",
"topic": "",
"min": 0,
"max": 10,
"step": 1,
"x": 120,
"y": 160,
"wires": [
[
"73f3cfb.639c83"
]
]
},
{
"id": "a03f3dc7.f3a28",
"type": "function",
"z": "f499b7ea.100118",
"name": "msg.tempnow",
"func": "flow.set(\"tempnow\", msg.payload);",
"outputs": 1,
"noerr": 0,
"x": 300,
"y": 100,
"wires": [
[]
]
},
{
"id": "73f3cfb.639c83",
"type": "function",
"z": "f499b7ea.100118",
"name": "msg.tempset",
"func": "flow.set(\"tempset\", msg.payload);",
"outputs": 1,
"noerr": 0,
"x": 290,
"y": 160,
"wires": [
[]
]
},
{
"id": "c6cef357.1f624",
"type": "debug",
"z": "f499b7ea.100118",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 330,
"y": 280,
"wires": []
},
{
"id": "a628afb9.ef32a",
"type": "rpi-gpio out",
"z": "f499b7ea.100118",
"name": "",
"pin": "33",
"set": true,
"level": "1",
"freq": "",
"out": "out",
"x": 640,
"y": 340,
"wires": []
},
{
"id": "777db117.66834",
"type": "change",
"z": "f499b7ea.100118",
"name": "",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "1",
"tot": "num"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "ON",
"fromt": "str",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 340,
"wires": [
[
"a628afb9.ef32a"
]
]
},
{
"id": "71cec172.6fe92",
"type": "trigger",
"z": "f499b7ea.100118",
"op1": "",
"op2": "0",
"op1type": "date",
"op2type": "str",
"duration": "-5",
"extend": false,
"units": "s",
"reset": "OFF",
"bytopic": "all",
"name": "",
"x": 300,
"y": 400,
"wires": [
[
"a4b1ede0.bc5db"
]
]
},
{
"id": "a4b1ede0.bc5db",
"type": "function",
"z": "f499b7ea.100118",
"name": "Temp comparing Set Point",
"func": "var temperature = flow.get(\"tempnow\");\nvar setting = flow.get(\"tempset\");\n\n//if temperature now is less than the setpoint\nif(temperature < setting) {\n //close the relay\n msg.payload = 0;\n return msg;\n }\n//if temperature is equal or over the setpoint \nelse {\n //open the relay\n msg.payload = 1;\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 560,
"y": 400,
"wires": [
[
"a628afb9.ef32a"
]
]
},
{
"id": "87c96e16.83a17",
"type": "inject",
"z": "f499b7ea.100118",
"name": "",
"topic": "",
"payload": "OFF",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 130,
"y": 220,
"wires": [
[
"aebd59a1.e5b398"
]
]
},
{
"id": "7c7fe7a7.d5e398",
"type": "ui_group",
"z": "",
"name": "Control",
"tab": "de03cc52.a371c",
"order": 2,
"disp": false,
"width": "8",
"collapse": false
},
{
"id": "de03cc52.a371c",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]