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. 2 Werte Subtrtahieren in Node Red

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    2 Werte Subtrtahieren in Node Red

    This topic has been deleted. Only users with topic management privileges can see it.
    • mickym
      mickym Most Active @geschild last edited by mickym

      @geschild Deine Lösung hat den Vorteil, wenn der Verbrauch nicht triggert, dass dann der Wert sofort angepasst wird. Sollte also auch der Wechelrichter triggern müsste man den Verbrauch extra auslesen und dann brauchst Du ein paar mehr Nodes. Insofern hat Deine Lösung durchaus seine Berechtigung, wenn der Verbrauch nicht oft genug triggert.

      In diesem Fall würde sich meine Lösung wie folgt "verkomplizieren":

      aa47d0e8-e584-47c3-8105-3a01aa4ed54e-image.png

      [
         {
             "id": "1abbb3ad15f02df1",
             "type": "ioBroker in",
             "z": "7e6af0015415146d",
             "name": "Teich-Pow",
             "topic": "0_userdata.0.Test.sensor1.power",
             "payloadType": "value",
             "onlyack": "",
             "func": "all",
             "gap": "",
             "fireOnStart": "false",
             "outFormat": "MQTT",
             "x": 3460,
             "y": 160,
             "wires": [
                 [
                     "02a17f5119c5ddeb"
                 ]
             ]
         },
         {
             "id": "db726a38cace8780",
             "type": "ioBroker get",
             "z": "7e6af0015415146d",
             "name": "WR-Fritz",
             "topic": "0_userdata.0.Test.sensor2.power",
             "attrname": "wr",
             "payloadType": "value",
             "errOnInvalidState": "nothing",
             "x": 3860,
             "y": 160,
             "wires": [
                 [
                     "5a663fa76121848c"
                 ]
             ]
         },
         {
             "id": "5a663fa76121848c",
             "type": "change",
             "z": "7e6af0015415146d",
             "name": "TeichPow - WR",
             "rules": [
                 {
                     "t": "set",
                     "p": "payload",
                     "pt": "msg",
                     "to": "verbrauch - wr",
                     "tot": "jsonata"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 4040,
             "y": 200,
             "wires": [
                 [
                     "086dd9b2dd01f025",
                     "9300e05f3c9f9870"
                 ]
             ]
         },
         {
             "id": "086dd9b2dd01f025",
             "type": "ioBroker out",
             "z": "7e6af0015415146d",
             "d": true,
             "name": "Realer_Teichverbrauch",
             "topic": "0_userdata.0.Node_Red_Realer_Teichverbrauch",
             "ack": "true",
             "autoCreate": "false",
             "stateName": "",
             "role": "",
             "payloadType": "",
             "readonly": "",
             "stateUnit": "",
             "stateMin": "",
             "stateMax": "",
             "x": 4290,
             "y": 240,
             "wires": []
         },
         {
             "id": "9300e05f3c9f9870",
             "type": "debug",
             "z": "7e6af0015415146d",
             "name": "Ergebnis nur payload",
             "active": true,
             "tosidebar": true,
             "console": false,
             "tostatus": false,
             "complete": "payload",
             "targetType": "msg",
             "statusVal": "",
             "statusType": "auto",
             "x": 4280,
             "y": 200,
             "wires": []
         },
         {
             "id": "02a17f5119c5ddeb",
             "type": "change",
             "z": "7e6af0015415146d",
             "name": "",
             "rules": [
                 {
                     "t": "move",
                     "p": "payload",
                     "pt": "msg",
                     "to": "verbrauch",
                     "tot": "msg"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 3660,
             "y": 160,
             "wires": [
                 [
                     "db726a38cace8780"
                 ]
             ]
         },
         {
             "id": "253e024afd9346ec",
             "type": "ioBroker in",
             "z": "7e6af0015415146d",
             "name": "WR-Fritz",
             "topic": "0_userdata.0.Test.sensor2.power",
             "payloadType": "value",
             "onlyack": "",
             "func": "all",
             "gap": "",
             "fireOnStart": "false",
             "outFormat": "MQTT",
             "x": 3460,
             "y": 240,
             "wires": [
                 [
                     "3cece316d856fc0e"
                 ]
             ]
         },
         {
             "id": "157517622c425fcd",
             "type": "ioBroker get",
             "z": "7e6af0015415146d",
             "name": "Teich-Pow",
             "topic": "0_userdata.0.Test.sensor1.power",
             "attrname": "verbrauch",
             "payloadType": "value",
             "errOnInvalidState": "nothing",
             "x": 3870,
             "y": 240,
             "wires": [
                 [
                     "5a663fa76121848c"
                 ]
             ]
         },
         {
             "id": "3cece316d856fc0e",
             "type": "change",
             "z": "7e6af0015415146d",
             "name": "",
             "rules": [
                 {
                     "t": "move",
                     "p": "payload",
                     "pt": "msg",
                     "to": "wr",
                     "tot": "msg"
                 }
             ],
             "action": "",
             "property": "",
             "from": "",
             "to": "",
             "reg": false,
             "x": 3660,
             "y": 240,
             "wires": [
                 [
                     "157517622c425fcd"
                 ]
             ]
         }
      ]
      

      In diesem Fall muss man nur sicherstellen, dass immer die richtige Nachrichteneigenschaften gesetzt werden. Deshalb wird die payload dann auf die entsprechende Nachrichteneigenschaft bei den iobroker-IN Nodes nachträglich gesetzt und in den get-Nodes direkt:

      f65f9388-1fd2-47d0-800b-0a5e990f2cc9-image.png

      Das heißt es existiert zum Zeitpunkt der Subtraktion keine payload (deshalb undefined) im Debug Fenster.

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

        @mickym said in 2 Werte Subtrtahieren in Node Red:

        @geschild Deine Lösung hat den Vorteil, wenn der Verbrauch nicht triggert, dass dann der Wert sofort angepasst wird. Sollte also auch der Wechelrichter triggern müsste man den Verbrauch extra auslesen und dann brauchst Du ein paar mehr Nodes. Insofern hat Deine Lösung durchaus seine Berechtigung, wenn der Verbrauch nicht oft genug triggert.

        In diesem Fall würde sich meine Lösung wie folgt "verkomplizieren":

        aa47d0e8-e584-47c3-8105-3a01aa4ed54e-image.png

        [
           {
               "id": "1abbb3ad15f02df1",
               "type": "ioBroker in",
               "z": "7e6af0015415146d",
               "name": "Teich-Pow",
               "topic": "0_userdata.0.Test.sensor1.power",
               "payloadType": "value",
               "onlyack": "",
               "func": "all",
               "gap": "",
               "fireOnStart": "false",
               "outFormat": "MQTT",
               "x": 3460,
               "y": 160,
               "wires": [
                   [
                       "02a17f5119c5ddeb"
                   ]
               ]
           },
           {
               "id": "db726a38cace8780",
               "type": "ioBroker get",
               "z": "7e6af0015415146d",
               "name": "WR-Fritz",
               "topic": "0_userdata.0.Test.sensor2.power",
               "attrname": "wr",
               "payloadType": "value",
               "errOnInvalidState": "nothing",
               "x": 3860,
               "y": 160,
               "wires": [
                   [
                       "5a663fa76121848c"
                   ]
               ]
           },
           {
               "id": "5a663fa76121848c",
               "type": "change",
               "z": "7e6af0015415146d",
               "name": "TeichPow - WR",
               "rules": [
                   {
                       "t": "set",
                       "p": "payload",
                       "pt": "msg",
                       "to": "verbrauch - wr",
                       "tot": "jsonata"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 4040,
               "y": 200,
               "wires": [
                   [
                       "086dd9b2dd01f025",
                       "9300e05f3c9f9870"
                   ]
               ]
           },
           {
               "id": "086dd9b2dd01f025",
               "type": "ioBroker out",
               "z": "7e6af0015415146d",
               "d": true,
               "name": "Realer_Teichverbrauch",
               "topic": "0_userdata.0.Node_Red_Realer_Teichverbrauch",
               "ack": "true",
               "autoCreate": "false",
               "stateName": "",
               "role": "",
               "payloadType": "",
               "readonly": "",
               "stateUnit": "",
               "stateMin": "",
               "stateMax": "",
               "x": 4290,
               "y": 240,
               "wires": []
           },
           {
               "id": "9300e05f3c9f9870",
               "type": "debug",
               "z": "7e6af0015415146d",
               "name": "Ergebnis nur payload",
               "active": true,
               "tosidebar": true,
               "console": false,
               "tostatus": false,
               "complete": "payload",
               "targetType": "msg",
               "statusVal": "",
               "statusType": "auto",
               "x": 4280,
               "y": 200,
               "wires": []
           },
           {
               "id": "02a17f5119c5ddeb",
               "type": "change",
               "z": "7e6af0015415146d",
               "name": "",
               "rules": [
                   {
                       "t": "move",
                       "p": "payload",
                       "pt": "msg",
                       "to": "verbrauch",
                       "tot": "msg"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 3660,
               "y": 160,
               "wires": [
                   [
                       "db726a38cace8780"
                   ]
               ]
           },
           {
               "id": "253e024afd9346ec",
               "type": "ioBroker in",
               "z": "7e6af0015415146d",
               "name": "WR-Fritz",
               "topic": "0_userdata.0.Test.sensor2.power",
               "payloadType": "value",
               "onlyack": "",
               "func": "all",
               "gap": "",
               "fireOnStart": "false",
               "outFormat": "MQTT",
               "x": 3460,
               "y": 240,
               "wires": [
                   [
                       "3cece316d856fc0e"
                   ]
               ]
           },
           {
               "id": "157517622c425fcd",
               "type": "ioBroker get",
               "z": "7e6af0015415146d",
               "name": "Teich-Pow",
               "topic": "0_userdata.0.Test.sensor1.power",
               "attrname": "verbrauch",
               "payloadType": "value",
               "errOnInvalidState": "nothing",
               "x": 3870,
               "y": 240,
               "wires": [
                   [
                       "5a663fa76121848c"
                   ]
               ]
           },
           {
               "id": "3cece316d856fc0e",
               "type": "change",
               "z": "7e6af0015415146d",
               "name": "",
               "rules": [
                   {
                       "t": "move",
                       "p": "payload",
                       "pt": "msg",
                       "to": "wr",
                       "tot": "msg"
                   }
               ],
               "action": "",
               "property": "",
               "from": "",
               "to": "",
               "reg": false,
               "x": 3660,
               "y": 240,
               "wires": [
                   [
                       "157517622c425fcd"
                   ]
               ]
           }
        ]
        

        Danke für die Hilfe ,bin nun doch etwas überfordert aber ich versuche es einfach mal mit dem leztem Beispiel.
        Wenn ich nicht klar komme melde ich mich nochmal hier mit dem Qode hier.

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

          @siporax Wie gesagt das brauchst Du nur, wenn Dir der Tech-Pow trigger nicht ausreicht. 😉 Sonst langt die einfache Lösung. 😉

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

            @mickym said in 2 Werte Subtrtahieren in Node Red:

            @siporax Wie gesagt das brauchst Du nur, wenn Dir der Tech-Pow trigger nicht ausreicht. 😉 Sonst langt die einfache Lösung. 😉

            Setze mich später gleich man dran an das ganze.Melde mich dann wieder.

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

              @siporax Die einfache Lösung nur mit der Trigger des Sonoff - war hier (sind nur 4 Nodes): https://forum.iobroker.net/post/1019849

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

                @mickym said in 2 Werte Subtrtahieren in Node Red:

                @siporax Die einfache Lösung nur mit der Trigger des Sonoff - war hier (sind nur 4 Nodes): https://forum.iobroker.net/post/1019849

                So habs soweit übernommen u d angepasst läuft aber nicht bzw schreib keine Daten in den Broker da steht immer Null

                [
                    {
                        "id": "78f6b708eb6bd2fe",
                        "type": "tab",
                        "label": "Realer Teichverbrauch",
                        "disabled": false,
                        "info": "",
                        "env": []
                    },
                    {
                        "id": "4e110ac9e3526a1d",
                        "type": "ioBroker in",
                        "z": "78f6b708eb6bd2fe",
                        "name": "Teich-Pow",
                        "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                        "payloadType": "value",
                        "onlyack": "",
                        "func": "all",
                        "gap": "",
                        "fireOnStart": "false",
                        "outFormat": "MQTT",
                        "x": 120,
                        "y": 100,
                        "wires": [
                            [
                                "e6795d8dc9d84fcc"
                            ]
                        ]
                    },
                    {
                        "id": "be61f3942177482d",
                        "type": "ioBroker get",
                        "z": "78f6b708eb6bd2fe",
                        "name": "WR-Fritz",
                        "topic": "fritzdect.0.DECT_116570079058.power",
                        "attrname": "wr",
                        "payloadType": "value",
                        "errOnInvalidState": "nothing",
                        "x": 520,
                        "y": 100,
                        "wires": [
                            [
                                "719b166cf1c4cf56"
                            ]
                        ]
                    },
                    {
                        "id": "719b166cf1c4cf56",
                        "type": "change",
                        "z": "78f6b708eb6bd2fe",
                        "name": "TeichPow - WR",
                        "rules": [
                            {
                                "t": "set",
                                "p": "payload",
                                "pt": "msg",
                                "to": "verbrauch - wr",
                                "tot": "jsonata"
                            }
                        ],
                        "action": "",
                        "property": "",
                        "from": "",
                        "to": "",
                        "reg": false,
                        "x": 700,
                        "y": 140,
                        "wires": [
                            [
                                "2528507974039f88",
                                "ec4528823eccb390"
                            ]
                        ]
                    },
                    {
                        "id": "2528507974039f88",
                        "type": "ioBroker out",
                        "z": "78f6b708eb6bd2fe",
                        "d": true,
                        "name": "Realer_Teichverbrauch",
                        "topic": "0_userdata.0.Node_Red_Realer_Teichverbrauch",
                        "ack": "true",
                        "autoCreate": "false",
                        "stateName": "",
                        "role": "",
                        "payloadType": "",
                        "readonly": "",
                        "stateUnit": "",
                        "stateMin": "",
                        "stateMax": "",
                        "x": 950,
                        "y": 180,
                        "wires": []
                    },
                    {
                        "id": "ec4528823eccb390",
                        "type": "debug",
                        "z": "78f6b708eb6bd2fe",
                        "name": "Ergebnis nur payload",
                        "active": true,
                        "tosidebar": true,
                        "console": false,
                        "tostatus": false,
                        "complete": "payload",
                        "targetType": "msg",
                        "statusVal": "",
                        "statusType": "auto",
                        "x": 940,
                        "y": 140,
                        "wires": []
                    },
                    {
                        "id": "e6795d8dc9d84fcc",
                        "type": "change",
                        "z": "78f6b708eb6bd2fe",
                        "name": "",
                        "rules": [
                            {
                                "t": "move",
                                "p": "payload",
                                "pt": "msg",
                                "to": "verbrauch",
                                "tot": "msg"
                            }
                        ],
                        "action": "",
                        "property": "",
                        "from": "",
                        "to": "",
                        "reg": false,
                        "x": 320,
                        "y": 100,
                        "wires": [
                            [
                                "be61f3942177482d"
                            ]
                        ]
                    },
                    {
                        "id": "5413c6e8e87d1659",
                        "type": "ioBroker in",
                        "z": "78f6b708eb6bd2fe",
                        "name": "WR-Fritz",
                        "topic": "fritzdect.0.DECT_116570079058.power",
                        "payloadType": "value",
                        "onlyack": "",
                        "func": "all",
                        "gap": "",
                        "fireOnStart": "false",
                        "outFormat": "MQTT",
                        "x": 120,
                        "y": 180,
                        "wires": [
                            [
                                "e857e6e86301279a"
                            ]
                        ]
                    },
                    {
                        "id": "8e2c30a2834a5bc7",
                        "type": "ioBroker get",
                        "z": "78f6b708eb6bd2fe",
                        "name": "Teich-Pow",
                        "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                        "attrname": "verbrauch",
                        "payloadType": "value",
                        "errOnInvalidState": "nothing",
                        "x": 530,
                        "y": 180,
                        "wires": [
                            [
                                "719b166cf1c4cf56"
                            ]
                        ]
                    },
                    {
                        "id": "e857e6e86301279a",
                        "type": "change",
                        "z": "78f6b708eb6bd2fe",
                        "name": "",
                        "rules": [
                            {
                                "t": "move",
                                "p": "payload",
                                "pt": "msg",
                                "to": "wr",
                                "tot": "msg"
                            }
                        ],
                        "action": "",
                        "property": "",
                        "from": "",
                        "to": "",
                        "reg": false,
                        "x": 320,
                        "y": 180,
                        "wires": [
                            [
                                "8e2c30a2834a5bc7"
                            ]
                        ]
                    }
                ]
                
                S 1 Reply Last reply Reply Quote 0
                • S
                  siporax @siporax last edited by

                  @siporax said in 2 Werte Subtrtahieren in Node Red:

                  @mickym said in 2 Werte Subtrtahieren in Node Red:

                  @siporax Die einfache Lösung nur mit der Trigger des Sonoff - war hier (sind nur 4 Nodes): https://forum.iobroker.net/post/1019849

                  So habs soweit übernommen u d angepasst läuft aber nicht bzw schreib keine Daten in den Broker da steht immer Null

                  [
                      {
                          "id": "78f6b708eb6bd2fe",
                          "type": "tab",
                          "label": "Realer Teichverbrauch",
                          "disabled": false,
                          "info": "",
                          "env": []
                      },
                      {
                          "id": "4e110ac9e3526a1d",
                          "type": "ioBroker in",
                          "z": "78f6b708eb6bd2fe",
                          "name": "Teich-Pow",
                          "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                          "payloadType": "value",
                          "onlyack": "",
                          "func": "all",
                          "gap": "",
                          "fireOnStart": "false",
                          "outFormat": "MQTT",
                          "x": 120,
                          "y": 100,
                          "wires": [
                              [
                                  "e6795d8dc9d84fcc"
                              ]
                          ]
                      },
                      {
                          "id": "be61f3942177482d",
                          "type": "ioBroker get",
                          "z": "78f6b708eb6bd2fe",
                          "name": "WR-Fritz",
                          "topic": "fritzdect.0.DECT_116570079058.power",
                          "attrname": "wr",
                          "payloadType": "value",
                          "errOnInvalidState": "nothing",
                          "x": 520,
                          "y": 100,
                          "wires": [
                              [
                                  "719b166cf1c4cf56"
                              ]
                          ]
                      },
                      {
                          "id": "719b166cf1c4cf56",
                          "type": "change",
                          "z": "78f6b708eb6bd2fe",
                          "name": "TeichPow - WR",
                          "rules": [
                              {
                                  "t": "set",
                                  "p": "payload",
                                  "pt": "msg",
                                  "to": "verbrauch - wr",
                                  "tot": "jsonata"
                              }
                          ],
                          "action": "",
                          "property": "",
                          "from": "",
                          "to": "",
                          "reg": false,
                          "x": 700,
                          "y": 140,
                          "wires": [
                              [
                                  "2528507974039f88",
                                  "ec4528823eccb390"
                              ]
                          ]
                      },
                      {
                          "id": "2528507974039f88",
                          "type": "ioBroker out",
                          "z": "78f6b708eb6bd2fe",
                          "d": true,
                          "name": "Realer_Teichverbrauch",
                          "topic": "0_userdata.0.Node_Red_Realer_Teichverbrauch",
                          "ack": "true",
                          "autoCreate": "false",
                          "stateName": "",
                          "role": "",
                          "payloadType": "",
                          "readonly": "",
                          "stateUnit": "",
                          "stateMin": "",
                          "stateMax": "",
                          "x": 950,
                          "y": 180,
                          "wires": []
                      },
                      {
                          "id": "ec4528823eccb390",
                          "type": "debug",
                          "z": "78f6b708eb6bd2fe",
                          "name": "Ergebnis nur payload",
                          "active": true,
                          "tosidebar": true,
                          "console": false,
                          "tostatus": false,
                          "complete": "payload",
                          "targetType": "msg",
                          "statusVal": "",
                          "statusType": "auto",
                          "x": 940,
                          "y": 140,
                          "wires": []
                      },
                      {
                          "id": "e6795d8dc9d84fcc",
                          "type": "change",
                          "z": "78f6b708eb6bd2fe",
                          "name": "",
                          "rules": [
                              {
                                  "t": "move",
                                  "p": "payload",
                                  "pt": "msg",
                                  "to": "verbrauch",
                                  "tot": "msg"
                              }
                          ],
                          "action": "",
                          "property": "",
                          "from": "",
                          "to": "",
                          "reg": false,
                          "x": 320,
                          "y": 100,
                          "wires": [
                              [
                                  "be61f3942177482d"
                              ]
                          ]
                      },
                      {
                          "id": "5413c6e8e87d1659",
                          "type": "ioBroker in",
                          "z": "78f6b708eb6bd2fe",
                          "name": "WR-Fritz",
                          "topic": "fritzdect.0.DECT_116570079058.power",
                          "payloadType": "value",
                          "onlyack": "",
                          "func": "all",
                          "gap": "",
                          "fireOnStart": "false",
                          "outFormat": "MQTT",
                          "x": 120,
                          "y": 180,
                          "wires": [
                              [
                                  "e857e6e86301279a"
                              ]
                          ]
                      },
                      {
                          "id": "8e2c30a2834a5bc7",
                          "type": "ioBroker get",
                          "z": "78f6b708eb6bd2fe",
                          "name": "Teich-Pow",
                          "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                          "attrname": "verbrauch",
                          "payloadType": "value",
                          "errOnInvalidState": "nothing",
                          "x": 530,
                          "y": 180,
                          "wires": [
                              [
                                  "719b166cf1c4cf56"
                              ]
                          ]
                      },
                      {
                          "id": "e857e6e86301279a",
                          "type": "change",
                          "z": "78f6b708eb6bd2fe",
                          "name": "",
                          "rules": [
                              {
                                  "t": "move",
                                  "p": "payload",
                                  "pt": "msg",
                                  "to": "wr",
                                  "tot": "msg"
                              }
                          ],
                          "action": "",
                          "property": "",
                          "from": "",
                          "to": "",
                          "reg": false,
                          "x": 320,
                          "y": 180,
                          "wires": [
                              [
                                  "8e2c30a2834a5bc7"
                              ]
                          ]
                      }
                  ]
                  

                  5.JPG

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

                    @siporax Ja dann mach mal ein Screenshot und zeig den Status bzw. mach Debug Nodes dran. Wenn 100-100 = 0 rauskommt, dann ist das ja richtig.

                    Und es stimmt ja nicht, dass er nichts schreibt:

                    d561deeb-4f1c-4b7e-a45c-45e666e830ea-image.png

                    Der Datenpunkt wurde um 14:34 heute beschrieben.

                    S geschild 2 Replies Last reply Reply Quote 0
                    • S
                      siporax @mickym last edited by

                      @mickym said in 2 Werte Subtrtahieren in Node Red:

                      @siporax Ja dann mach mal ein Screenshot und zeig den Status bzw. mach Debug Nodes dran. Wenn 100-100 = 0 rauskommt, dann ist das ja richtig.

                      Und es stimmt ja nicht, dass er nichts schreibt:

                      d561deeb-4f1c-4b7e-a45c-45e666e830ea-image.png

                      Der Datenpunkt wurde um 14:34 heute beschrieben.

                      6 Forum.JPG

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

                        @siporax Na dann kommt doch das Ergebnis raus. Du musst doch nur die iobroker-Out Node wieder aktivieren.

                        fbeee56b-dea3-43d8-b28b-14044dacb649-image.png

                        Die Debug Node kannst wieder wegschmeissen - das ist doch nur zur Fehlersuche bzw. zur Demonstration. Und wie gesagt - ich sehe die Sonoff Node trigger meistens - dann könntest auch die einfache Lösung mit den 4 Nodes nehmen:

                        414c6163-0c59-4f6b-85e8-1b570e3ff8f4-image.png

                        [
                          {
                              "id": "1abbb3ad15f02df1",
                              "type": "ioBroker in",
                              "z": "289f539dcc33814e",
                              "name": "Teich-Pow",
                              "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                              "payloadType": "value",
                              "onlyack": "",
                              "func": "all",
                              "gap": "",
                              "fireOnStart": "false",
                              "outFormat": "MQTT",
                              "x": 2440,
                              "y": 4320,
                              "wires": [
                                  [
                                      "db726a38cace8780"
                                  ]
                              ]
                          },
                          {
                              "id": "db726a38cace8780",
                              "type": "ioBroker get",
                              "z": "289f539dcc33814e",
                              "name": "WR-Fritz",
                              "topic": "fritzdect.0.DECT_116570079058.power",
                              "attrname": "wr",
                              "payloadType": "value",
                              "errOnInvalidState": "nothing",
                              "x": 2600,
                              "y": 4320,
                              "wires": [
                                  [
                                      "5a663fa76121848c"
                                  ]
                              ]
                          },
                          {
                              "id": "5a663fa76121848c",
                              "type": "change",
                              "z": "289f539dcc33814e",
                              "name": "TeichPow - WR",
                              "rules": [
                                  {
                                      "t": "set",
                                      "p": "payload",
                                      "pt": "msg",
                                      "to": "payload - wr",
                                      "tot": "jsonata"
                                  }
                              ],
                              "action": "",
                              "property": "",
                              "from": "",
                              "to": "",
                              "reg": false,
                              "x": 2780,
                              "y": 4320,
                              "wires": [
                                  [
                                      "086dd9b2dd01f025"
                                  ]
                              ]
                          },
                          {
                              "id": "086dd9b2dd01f025",
                              "type": "ioBroker out",
                              "z": "289f539dcc33814e",
                              "name": "Realer_Teichverbrauch",
                              "topic": "0_userdata.0.Node_Red_Realer_Teichverbrauch",
                              "ack": "true",
                              "autoCreate": "false",
                              "stateName": "",
                              "role": "",
                              "payloadType": "",
                              "readonly": "",
                              "stateUnit": "",
                              "stateMin": "",
                              "stateMax": "",
                              "x": 3010,
                              "y": 4320,
                              "wires": []
                          }
                        ]
                        
                        

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

                          @mickym
                          teichminus.txt TeichMInusNeu.jpg

                          Sorry: </> Code einfügen hab ich kapiert, aber wie daraus einen Spoiler macht ???

                          Egal. Code in .txt. Habe mal die topics in flow Variable gepackt. Jetzt braucht man die iobrokerIn/Out nur noch wie gewohnt mit den DP verbinden.

                          Könnte man das so machen. (Ich lerne gern dazu)

                          mickym 2 Replies Last reply Reply Quote 0
                          • mickym
                            mickym Most Active @geschild last edited by

                            @geschild Den Spoiler machst Du mit dem Auge. 😉

                            9dc4653a-17b9-418d-8d94-46944466d2e4-image.png

                            code_text
                            

                            Dann innerhalb des Spoilers die Code Tags:
                            a24319eb-ec3d-41c5-a1c6-34f3874b11f8-image.png

                            a681a1eb-cefa-4a6d-901c-72bf409506c0-image.png

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

                              @geschild So nun zu Deinem Flow. 😉

                              Das wird zwar so funktionieren - aber in dem Fall finde ich es übertrieben Flow variablen zu setzen, nur um das topic zu vereinfachen. Insbesondere ändert sich der Wert dieser Flowvariablen ja nie. Das würde nur Sinn machen, wenn Du unabhängig die Initialisierung triggern würdest. Dann lieber wieder das topic direkt setzen:

                              57f3191c-4a7d-4f9a-ba2c-f5edc05d9ab8-image.png

                              [
                                 {
                                     "id": "c32a0a1f4a2b9221",
                                     "type": "ioBroker in",
                                     "z": "78f6b708eb6bd2fe",
                                     "name": "Teich-Pow",
                                     "topic": "0_userdata.0.TeichMinus.Teich-Pow",
                                     "payloadType": "value",
                                     "onlyack": "",
                                     "func": "all",
                                     "gap": "",
                                     "fireOnStart": "false",
                                     "outFormat": "ioBroker",
                                     "x": 180,
                                     "y": 560,
                                     "wires": [
                                         [
                                             "f85da542bcf883c8"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "eceba02fa565ce76",
                                     "type": "ioBroker in",
                                     "z": "78f6b708eb6bd2fe",
                                     "name": "WR-Fritz",
                                     "topic": "0_userdata.0.TeichMinus.WR-Fritz",
                                     "payloadType": "value",
                                     "onlyack": "",
                                     "func": "all",
                                     "gap": "",
                                     "fireOnStart": "false",
                                     "outFormat": "ioBroker",
                                     "x": 180,
                                     "y": 640,
                                     "wires": [
                                         [
                                             "363c25994833957b"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "11f59eb25158b200",
                                     "type": "ioBroker out",
                                     "z": "78f6b708eb6bd2fe",
                                     "name": "Ergebnis",
                                     "topic": "0_userdata.0.TeichMinus.Ergebnis",
                                     "ack": "false",
                                     "autoCreate": "false",
                                     "stateName": "",
                                     "role": "",
                                     "payloadType": "",
                                     "readonly": "",
                                     "stateUnit": "",
                                     "stateMin": "",
                                     "stateMax": "",
                                     "x": 840,
                                     "y": 600,
                                     "wires": []
                                 },
                                 {
                                     "id": "9a2bda7d9bbb1ca2",
                                     "type": "function",
                                     "z": "78f6b708eb6bd2fe",
                                     "name": "wrFritz - teichPow",
                                     "func": "var topic = msg.topic;\nvar teichPow;\nvar wrFritz;\nvar ergebnis;\n\nvar teichPow = context.get('teichPowData') || 0;;\nvar wrFritz = context.get('wrFritzData') || 0;;\n\n\nif (topic == 'teichPowTopic') {\n//if (topic == \"0_userdata.0.TeichMinus.Teich-Pow\") {\n    teichPow = parseInt(msg.payload);\n    context.set('teichPowData', teichPow)\n}\n\nif (topic == 'wrFritzTopic') {\n//if (topic == \"0_userdata/0/TeichMinus/WR-Fritz\") {\n    wrFritz = parseInt(msg.payload);\n    context.set('wrFritzData', wrFritz) \n}\n\nergebnis = wrFritz - teichPow;\nmsg.payload = ergebnis;\nreturn msg;\n\n\n",
                                     "outputs": 1,
                                     "noerr": 0,
                                     "initialize": "",
                                     "finalize": "",
                                     "libs": [],
                                     "x": 610,
                                     "y": 600,
                                     "wires": [
                                         [
                                             "11f59eb25158b200"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "f85da542bcf883c8",
                                     "type": "change",
                                     "z": "78f6b708eb6bd2fe",
                                     "name": "",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "topic",
                                             "pt": "msg",
                                             "to": "teichPowTopic",
                                             "tot": "str"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 380,
                                     "y": 560,
                                     "wires": [
                                         [
                                             "9a2bda7d9bbb1ca2"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "363c25994833957b",
                                     "type": "change",
                                     "z": "78f6b708eb6bd2fe",
                                     "name": "",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "topic",
                                             "pt": "msg",
                                             "to": "wrFritzTopic",
                                             "tot": "str"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 380,
                                     "y": 640,
                                     "wires": [
                                         [
                                             "9a2bda7d9bbb1ca2"
                                         ]
                                     ]
                                 }
                              ]
                              

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

                                @mickym Ist klar, aber wollte @siporax das Leben leichter machen.

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

                                  Übrigens Deine Function Node 😉

                                  var topic = msg.topic;
                                  flow.set('teichPowTopic', topic);
                                  
                                  msg.payload = flow.get('teichPowTopic');
                                  return msg;
                                  

                                  kann man auch mit einer ChangeNode ohne Codieren machen. 😉

                                  Das macht das Gleiche:

                                  014d08e3-c169-4723-813e-d4692745e94d-image.png

                                  S geschild 2 Replies Last reply Reply Quote 0
                                  • S
                                    siporax @mickym last edited by siporax

                                    @mickym said in 2 Werte Subtrtahieren in Node Red:

                                    Übrigens Deine Function Node 😉

                                    var topic = msg.topic;
                                    flow.set('teichPowTopic', topic);
                                    
                                    msg.payload = flow.get('teichPowTopic');
                                    return msg;
                                    

                                    kann man auch mit einer ChangeNode ohne Codieren machen. 😉

                                    Das macht das Gleiche:

                                    014d08e3-c169-4723-813e-d4692745e94d-image.png

                                    So habs zum rechnen gebracht steht zwar ein minus davor im Zielordner beim Ergebnis aber damit kann ich leben.

                                    [
                                       {
                                           "id": "78f6b708eb6bd2fe",
                                           "type": "tab",
                                           "label": "Realer Teichverbrauch",
                                           "disabled": false,
                                           "info": "",
                                           "env": []
                                       },
                                       {
                                           "id": "4e110ac9e3526a1d",
                                           "type": "ioBroker in",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "Teich-Pow",
                                           "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                                           "payloadType": "value",
                                           "onlyack": "",
                                           "func": "all",
                                           "gap": "",
                                           "fireOnStart": "false",
                                           "outFormat": "MQTT",
                                           "x": 120,
                                           "y": 100,
                                           "wires": [
                                               [
                                                   "e6795d8dc9d84fcc"
                                               ]
                                           ]
                                       },
                                       {
                                           "id": "be61f3942177482d",
                                           "type": "ioBroker get",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "WR-Fritz",
                                           "topic": "fritzdect.0.DECT_116570079058.power",
                                           "attrname": "wr",
                                           "payloadType": "value",
                                           "errOnInvalidState": "nothing",
                                           "x": 520,
                                           "y": 100,
                                           "wires": [
                                               [
                                                   "719b166cf1c4cf56"
                                               ]
                                           ]
                                       },
                                       {
                                           "id": "719b166cf1c4cf56",
                                           "type": "change",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "TeichPow - WR",
                                           "rules": [
                                               {
                                                   "t": "set",
                                                   "p": "payload",
                                                   "pt": "msg",
                                                   "to": "verbrauch - wr",
                                                   "tot": "jsonata"
                                               }
                                           ],
                                           "action": "",
                                           "property": "",
                                           "from": "",
                                           "to": "",
                                           "reg": false,
                                           "x": 700,
                                           "y": 140,
                                           "wires": [
                                               [
                                                   "2528507974039f88"
                                               ]
                                           ]
                                       },
                                       {
                                           "id": "2528507974039f88",
                                           "type": "ioBroker out",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "Realer_Teichverbrauch",
                                           "topic": "0_userdata.0.Node_Red_Realer_Teichverbrauch",
                                           "ack": "true",
                                           "autoCreate": "false",
                                           "stateName": "",
                                           "role": "",
                                           "payloadType": "",
                                           "readonly": "",
                                           "stateUnit": "",
                                           "stateMin": "",
                                           "stateMax": "",
                                           "x": 950,
                                           "y": 140,
                                           "wires": []
                                       },
                                       {
                                           "id": "e6795d8dc9d84fcc",
                                           "type": "change",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "",
                                           "rules": [
                                               {
                                                   "t": "move",
                                                   "p": "payload",
                                                   "pt": "msg",
                                                   "to": "verbrauch",
                                                   "tot": "msg"
                                               }
                                           ],
                                           "action": "",
                                           "property": "",
                                           "from": "",
                                           "to": "",
                                           "reg": false,
                                           "x": 320,
                                           "y": 100,
                                           "wires": [
                                               [
                                                   "be61f3942177482d"
                                               ]
                                           ]
                                       },
                                       {
                                           "id": "5413c6e8e87d1659",
                                           "type": "ioBroker in",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "WR-Fritz",
                                           "topic": "fritzdect.0.DECT_116570079058.power",
                                           "payloadType": "value",
                                           "onlyack": "",
                                           "func": "all",
                                           "gap": "",
                                           "fireOnStart": "false",
                                           "outFormat": "MQTT",
                                           "x": 120,
                                           "y": 180,
                                           "wires": [
                                               [
                                                   "e857e6e86301279a"
                                               ]
                                           ]
                                       },
                                       {
                                           "id": "8e2c30a2834a5bc7",
                                           "type": "ioBroker get",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "Teich-Pow",
                                           "topic": "sonoff.0.Teich-Verbrauch.ENERGY_Power",
                                           "attrname": "verbrauch",
                                           "payloadType": "value",
                                           "errOnInvalidState": "nothing",
                                           "x": 530,
                                           "y": 180,
                                           "wires": [
                                               [
                                                   "719b166cf1c4cf56"
                                               ]
                                           ]
                                       },
                                       {
                                           "id": "e857e6e86301279a",
                                           "type": "change",
                                           "z": "78f6b708eb6bd2fe",
                                           "name": "",
                                           "rules": [
                                               {
                                                   "t": "move",
                                                   "p": "payload",
                                                   "pt": "msg",
                                                   "to": "wr",
                                                   "tot": "msg"
                                               }
                                           ],
                                           "action": "",
                                           "property": "",
                                           "from": "",
                                           "to": "",
                                           "reg": false,
                                           "x": 320,
                                           "y": 180,
                                           "wires": [
                                               [
                                                   "8e2c30a2834a5bc7"
                                               ]
                                           ]
                                       }
                                    ]
                                    

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

                                      @mickym Danke. Wie gesagt, komme vom Script und muss mir die Möglichkeiten von nodered erst aneignen. Schönen Sonntag noch.

                                      PS. Kannst du mir den elektrischen Aufbau von @siporax erklären?

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

                                        @siporax Das Minus kannst Du eliminieren, wenn Du die Subtraktion umdrehst oder halt den absoluten Wert nimmst.

                                        Um den absoluten Wert zu erhalten - einfach die ChangeNode wie folgt ändern:

                                        acdece76-dff7-4675-81a7-90f32dc1c15f-image.png

                                        Oder alternativ mit -1 multiplizieren also

                                        (payload-wr) * -1
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • mickym
                                          mickym Most Active @geschild last edited by

                                          @geschild sagte in 2 Werte Subtrtahieren in Node Red:

                                          PS. Kannst du mir den elektrischen Aufbau von @siporax erklären?

                                          Nee - das muss @siporax selbst machen - ich bin nur für die Logik in NodeRed zuständig. 😉

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

                                            @mickym said in 2 Werte Subtrtahieren in Node Red:

                                            @geschild sagte in 2 Werte Subtrtahieren in Node Red:

                                            PS. Kannst du mir den elektrischen Aufbau von @siporax erklären?

                                            Nee - das muss @siporax selbst machen - ich bin nur für die Logik in NodeRed zuständig. 😉

                                            Habe eine Warnmeldungen
                                            7 forum.JPG

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.1k
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            3
                                            60
                                            2618
                                            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