Hallo,
ich probiere mich seit geraumer Zeit meine Heizung noch intelligenter schalten zu lassen. Leider bekomme ich es bisher aber nicht so hin wie ich es gern hätte.
Ich würde gern in einer Function zwei Werte vergleichen (Flow) und wenn beide Werte meine Vorgaben erfüllen eine Trigger zu schalten.
In meinen Beispiel soll durch die Function ein true (msg.payload) gesendet werden wenn der Flow "heizdif" größer als 20 und der Flow wwdif größer als 5 ist.
Wäre sehr dank wenn mir da nochmal einer auf die Sprünge helfen kann wo mein Fehler liegt.
Liebe Grüße Milan
[
{
"id": "0d30e281996aaebd",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "b065417068e26386",
"type": "change",
"z": "0d30e281996aaebd",
"name": "",
"rules": [
{
"t": "set",
"p": "wwdif",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "topic",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1150,
"y": 640,
"wires": [
[
"77da2cce3ae2683d"
]
]
},
{
"id": "44a30c20f9a153e6",
"type": "change",
"z": "0d30e281996aaebd",
"name": "",
"rules": [
{
"t": "set",
"p": "heizdif",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "delete",
"p": "topic",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1150,
"y": 580,
"wires": [
[
"77da2cce3ae2683d"
]
]
},
{
"id": "77da2cce3ae2683d",
"type": "function",
"z": "0d30e281996aaebd",
"name": "",
"func": "var heizdif = flow.get('heizdif'); \nvar wwdif = flow.get('wwdif');\nmsg.heizdif = heizdif;\nmsg.wwdif = wwdif;\nif (msg.heizdif > 20 && msg.wwdif > 5) {\nmsg.payload === true;\n}\nelse {\nmsg.payload === false;\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1400,
"y": 620,
"wires": [
[
"42abd2fecf659b8d",
"9822534383101b8a"
]
]
},
{
"id": "f0c2e0d3753c0549",
"type": "inject",
"z": "0d30e281996aaebd",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "6",
"payloadType": "num",
"x": 810,
"y": 640,
"wires": [
[
"b065417068e26386"
]
]
},
{
"id": "9822534383101b8a",
"type": "debug",
"z": "0d30e281996aaebd",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1650,
"y": 360,
"wires": []
},
{
"id": "6c40bb7ab28ef804",
"type": "inject",
"z": "0d30e281996aaebd",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "30",
"payloadType": "num",
"x": 810,
"y": 580,
"wires": [
[
"44a30c20f9a153e6"
]
]
},
{
"id": "a93efb39ddd6888c",
"type": "trigger",
"z": "0d30e281996aaebd",
"name": "",
"op1": "on",
"op2": "off",
"op1type": "str",
"op2type": "str",
"duration": "10",
"extend": false,
"overrideDelay": false,
"units": "min",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1840,
"y": 620,
"wires": [
[
"9822534383101b8a"
]
]
},
{
"id": "42abd2fecf659b8d",
"type": "switch",
"z": "0d30e281996aaebd",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1590,
"y": 620,
"wires": [
[
"a93efb39ddd6888c"
]
]
}
]