- ioBroker Community Home
- Deutsch
- Skripten / Logik
- Node-Red
- Vergleich 2 Werte wenn ungleich 1 Wert ausgeben
NEWS
Vergleich 2 Werte wenn ungleich 1 Wert ausgeben
-
Hallo zusammen,
ich möchte gerne in NodeRed 2 eingehende Werte (aus 2 verschiedenen Nodes) miteinander vergleichen und, wenn sich diese unterscheiden den Wert aus dem 1. Node ausgeben / weiterverarbeiten...
Wie kriege ich das hin ?
-
Hallo zusammen,
ich möchte gerne in NodeRed 2 eingehende Werte (aus 2 verschiedenen Nodes) miteinander vergleichen und, wenn sich diese unterscheiden den Wert aus dem 1. Node ausgeben / weiterverarbeiten...
Wie kriege ich das hin ?
@geforce28 du hast 3 Möglichkeiten:
1- du holst dir beide Werte in ein Nachrichtenobjekt:
1.a. Via iobroker get nodes
1.b via join node
2. du speicherst mind. 1 Wert in einem KontextVergleiche führst du mit einer Switch Node durch.
[ { "id": "bf18acfbac86d91c", "type": "tab", "label": "Werte vergleichen", "disabled": false, "info": "", "env": [] }, { "id": "84f4c2bcc8f52c2b", "type": "comment", "z": "bf18acfbac86d91c", "name": "Du speicherst einen oder ggf. beide Werte in einer oder mehreren Flowvariablen.", "info": "", "x": 380, "y": 140, "wires": [] }, { "id": "cdb69797b74f2807", "type": "ioBroker in", "z": "bf18acfbac86d91c", "name": "PV Tag Prognose", "topic": "0_userdata.0.Test.prognose", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "outFormat": "MQTT", "x": 140, "y": 240, "wires": [ [ "b50f80bf8bcbc213" ] ] }, { "id": "b88f4dd26163692b", "type": "ioBroker in", "z": "bf18acfbac86d91c", "name": "PV Today bis jetzt", "topic": "0_userdata.0.Test.aktuell", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "outFormat": "MQTT", "x": 150, "y": 300, "wires": [ [ "ae13ce4883489a74" ] ] }, { "id": "b50f80bf8bcbc213", "type": "change", "z": "bf18acfbac86d91c", "name": "", "rules": [ { "t": "set", "p": "PV_Tag_Prognose", "pt": "flow", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 400, "y": 240, "wires": [ [] ] }, { "id": "ae13ce4883489a74", "type": "change", "z": "bf18acfbac86d91c", "name": "", "rules": [ { "t": "set", "p": "prognose", "pt": "msg", "to": "PV_Tag_Prognose", "tot": "flow" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 380, "y": 300, "wires": [ [ "88273195c80c84f2" ] ] }, { "id": "88273195c80c84f2", "type": "switch", "z": "bf18acfbac86d91c", "name": "payload > prognose", "property": "payload > prognose", "propertyType": "jsonata", "rules": [ { "t": "true" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 610, "y": 300, "wires": [ [ "70bd4a0a0a2d4787" ] ] }, { "id": "2c68eba46d5dbeef", "type": "debug", "z": "bf18acfbac86d91c", "name": "sende Nachricht (Beispiel Flowvariable)", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1060, "y": 300, "wires": [] }, { "id": "70bd4a0a0a2d4787", "type": "change", "z": "bf18acfbac86d91c", "name": "Nachricht", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "Prognose wurde überschritten", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 800, "y": 300, "wires": [ [ "2c68eba46d5dbeef" ] ] }, { "id": "85702a2c7a400d9c", "type": "comment", "z": "bf18acfbac86d91c", "name": "Du sammelst die beiden Werte in einem Nachrichtenobjekt mit einer JOIN Node.", "info": "", "x": 380, "y": 440, "wires": [] }, { "id": "da0c33ab90da3dad", "type": "ioBroker in", "z": "bf18acfbac86d91c", "name": "PV Tag Prognose", "topic": "0_userdata.0.Test.prognose", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "outFormat": "MQTT", "x": 140, "y": 520, "wires": [ [ "0fa1b7591f0b4d26" ] ] }, { "id": "89ef3782b3d5fbd7", "type": "ioBroker in", "z": "bf18acfbac86d91c", "name": "PV Today bis jetzt", "topic": "0_userdata.0.Test.aktuell", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "outFormat": "MQTT", "x": 150, "y": 600, "wires": [ [ "b2b601430ac7e80d" ] ] }, { "id": "0fa1b7591f0b4d26", "type": "change", "z": "bf18acfbac86d91c", "name": "topic = prognose", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "prognose", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 390, "y": 520, "wires": [ [ "1c38bf5becbffb8a" ] ] }, { "id": "b2b601430ac7e80d", "type": "change", "z": "bf18acfbac86d91c", "name": "topic = aktuell", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "aktuell", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 400, "y": 600, "wires": [ [ "1c38bf5becbffb8a" ] ] }, { "id": "1c38bf5becbffb8a", "type": "join", "z": "bf18acfbac86d91c", "name": "", "mode": "custom", "build": "object", "property": "payload", "propertyType": "msg", "key": "topic", "joiner": "\\n", "joinerType": "str", "accumulate": true, "timeout": "", "count": "2", "reduceRight": false, "reduceExp": "", "reduceInit": "", "reduceInitType": "", "reduceFixup": "", "x": 590, "y": 560, "wires": [ [ "50445639c6bb29cc" ] ] }, { "id": "50445639c6bb29cc", "type": "switch", "z": "bf18acfbac86d91c", "name": "payload > prognose", "property": "payload.aktuell > payload.prognose", "propertyType": "jsonata", "rules": [ { "t": "true" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 770, "y": 560, "wires": [ [ "8d562efab2cfff9a" ] ] }, { "id": "42643fa00df8601f", "type": "debug", "z": "bf18acfbac86d91c", "name": "sende Nachricht (Beispiel JOIN)", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1190, "y": 560, "wires": [] }, { "id": "8d562efab2cfff9a", "type": "change", "z": "bf18acfbac86d91c", "name": "Nachricht", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "Prognose wurde überschritten", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 960, "y": 560, "wires": [ [ "42643fa00df8601f" ] ] }, { "id": "179914fd1a8968f2", "type": "comment", "z": "bf18acfbac86d91c", "name": "Wenn ein Wert getriggert ist und zum Beispiel im iobroker ein anderer ausgelesen werden soll, dann kann man das quasi Huckepack auslesen.", "info": "", "x": 570, "y": 700, "wires": [] }, { "id": "b94fd1601ba3f40c", "type": "ioBroker in", "z": "bf18acfbac86d91c", "name": "PV Today bis jetzt", "topic": "0_userdata.0.Test.aktuell", "payloadType": "value", "onlyack": "", "func": "all", "gap": "", "fireOnStart": "false", "outFormat": "MQTT", "x": 170, "y": 800, "wires": [ [ "cc98ccdd4d05a363" ] ] }, { "id": "cc98ccdd4d05a363", "type": "ioBroker get", "z": "bf18acfbac86d91c", "name": "PV Tag Prognose", "topic": "0_userdata.0.Test.prognose", "attrname": "prognose", "payloadType": "value", "errOnInvalidState": "nothing", "x": 390, "y": 800, "wires": [ [ "242ef6373f0959c3" ] ] }, { "id": "242ef6373f0959c3", "type": "switch", "z": "bf18acfbac86d91c", "name": "payload > prognose", "property": "payload > prognose", "propertyType": "jsonata", "rules": [ { "t": "true" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 610, "y": 800, "wires": [ [ "7124503b946b2a85" ] ] }, { "id": "78445ce181de5648", "type": "debug", "z": "bf18acfbac86d91c", "name": "sende Nachricht (Huckepack)", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1030, "y": 800, "wires": [] }, { "id": "7124503b946b2a85", "type": "change", "z": "bf18acfbac86d91c", "name": "Nachricht", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "Prognose wurde überschritten", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 800, "y": 800, "wires": [ [ "78445ce181de5648" ] ] } ]
Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.