Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Node-Red
    5. Werte vergleichen

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Werte vergleichen

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Saranger last edited by

      Guten Abend zusammen,

      leider hänge ich mal wieder an einem für euch wahrscheinlich einfachen Problem :-).

      Ich würde gern zwei Werte vergleichen und wenn der eine Wert höher ist als der andere soll eine Aktion ausgeführt werden.

      Habt Ihr einen TIp für mich?

      Einen schönen Abend.

      Saranger

      mickym 1 Reply Last reply Reply Quote 0
      • mickym
        mickym Most Active @Saranger last edited by mickym

        @saranger Das wurde zwar von mir schon mehrfach erklärt - aber ich mach das gerne nochmal.

        Die Nachrichten warten nicht aufeinander. Wenn man also 2 Werte miteinander vergleichen will, dann muss man mindestens 1 Wert im Flow speichern und dann zum Zeitpunkt des Vergleichs abrufen.

        Dazu hast Du folgende Möglichkeiten:

        1. Du speicherst einen oder ggf. beide Werte in einer oder mehreren Flowvariablen.
        2. Du sammelst die beiden Werte in einem Nachrichtenobjekt mit einer JOIN Node.
        3. Wenn ein Wert getriggert ist und zum Beispiel im iobroker ein anderer ausgelesen werden soll, dann kann man das quasi Hueckpack auslesen.

        Je nachdem was Du bevorzugst - können wir gerne alle 3 Möglichkeiten durchgehen, dann solltest Du aber mit einem konkreten Flow und konkreten Werten hier posten. Dann helfe ich Dir gerne, dass anhand eines konkreten Beispiels umzusetzen.

        Ähnlich wie in Deinem anderen Thread https://forum.iobroker.net/topic/51180/boolean-logic-problem?_=1657223814049 hast Du ja schon mal mit einer JOIN Node gearbeitet - dort hast Du ja auch quasi 2 Werte mit UND/ODER verglichen .

        S 1 Reply Last reply Reply Quote 0
        • S
          Saranger @mickym last edited by

          @mickym danke für deine Antwort, ja das mit dem UND vergleich hab ich mir auch noch mal angesehen aber wie ich da das größer als rein bekomme hab ich nicht verstanden.

          Ich habe zwei Werte die aus dem IO Broker kommen 1x PV Prognose und 1x was die PV bis jetzt erzeugt hat, jetzt möchte ich wenn der erreichte Wert größer ist als die Prognose eine Pushup Nachricht erhalten.

          PV.JPG

          mickym 1 Reply Last reply Reply Quote 0
          • mickym
            mickym Most Active @Saranger last edited by mickym

            @saranger So ich hab Dir mal alle 3 Möglichkeiten implementiert, wie in meinem Posting beschrieben - musst halt nur die Datenpunkte entsprechend anpassen.

            31dbd79d-7c5e-4097-9da4-01cb14477793-image.png

            [
               {
                   "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"
                       ]
                   ]
               }
            ]
            

            Falls Du Fragen zur Funktionsweise der 3 Möglichkeiten hast - gerne. 🙂

            S 1 Reply Last reply Reply Quote 0
            • S
              Saranger @mickym last edited by

              @mickym guten Morgen und schon mal vielen Dank :-). Werd ich jetzt einmal testen und hab mir die gleich mal gespeichert, werd ich bestimmt öfter gebrauchen können :-).

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Support us

              ioBroker
              Community Adapters
              Donate

              1.0k
              Online

              31.7k
              Users

              79.8k
              Topics

              1.3m
              Posts

              2
              5
              318
              Loading More Posts
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes
              Reply
              • Reply as topic
              Log in to reply
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
              The ioBroker Community 2014-2023
              logo