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. Smartmeter -> NR

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Smartmeter -> NR

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

      Hallo,
      ich habe es nun endlich geschafft meinen Smartmeter via MQTT mit NR zu verbinden. Die Daten kommen so (Bild) bei mir an.

      Jetzt möchte ich gern das immer um z.B. Mitternacht der Wert gespeichert wird und dann 24h später die Differenz der beiden Werte berechnet wird daraus ergibt sich dann der Tages kwh Verbrauch.
      Mir fehlt mir aber komplett die Idee wie ich das umsetzen könnte, vlt hat das ja so oder so ähnlich schon jemand umgesetzt und kann mir helfen.

      Danke und Lg
      HP
      Unbenannt.PNG

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

        @hpgo Du speicherst den Wert in einer Flowvariablen mittels Change Node. Dann nimmst Du eine Inject-Node, die selbstständig beim Tageswechsel triggert, den Vortageswert und den aktuellen Wert speichert und die Differenz ausgibt.

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

          @mickym
          Danke, bei dir klingt das immer alles so leicht.

          Naja der Smartmeter sendet jede Minute den neuen verbrauch. So wird die Flow Variable aber doch auch immer neu überschrieben.Unbenannt.PNG

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

            @hpgo Das macht ja nichts - Über die Inject Node - nimmst Du dann ja nur den Wert der aktuell dann um Mitternacht drinsteht speicherst das quasi als Vortageswert nachdem du die Differenz (die beim ersten Mal natürlich 0 ist). genommen hast.

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

              @mickym
              Kapier ich nicht, sorry
              Ich schaffe es nur die flow Variable mit >9000 und <9001 abzufragen.

              [
                  {
                      "id": "c7b1863ec3de5b58",
                      "type": "tab",
                      "label": "Smartmeter",
                      "disabled": false,
                      "info": "",
                      "env": []
                  },
                  {
                      "id": "4f4c02518d0af791",
                      "type": "mqtt in",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "topic": "smartmeter/SmartyReader",
                      "qos": "2",
                      "datatype": "auto",
                      "broker": "501dcbe75f7121d1",
                      "nl": false,
                      "rap": true,
                      "rh": 0,
                      "inputs": 0,
                      "x": 430,
                      "y": 180,
                      "wires": [
                          [
                              "83af5ee7562b2766",
                              "fdb8ec4dd58e4f02"
                          ]
                      ]
                  },
                  {
                      "id": "83af5ee7562b2766",
                      "type": "json",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "property": "payload",
                      "action": "",
                      "pretty": false,
                      "x": 630,
                      "y": 180,
                      "wires": [
                          [
                              "483a142959cc36be"
                          ]
                      ]
                  },
                  {
                      "id": "fdb8ec4dd58e4f02",
                      "type": "debug",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "active": true,
                      "tosidebar": true,
                      "console": false,
                      "tostatus": false,
                      "complete": "false",
                      "statusVal": "",
                      "statusType": "auto",
                      "x": 650,
                      "y": 120,
                      "wires": []
                  },
                  {
                      "id": "483a142959cc36be",
                      "type": "change",
                      "z": "c7b1863ec3de5b58",
                      "name": "payload.energy_consumption_calc_kWh",
                      "rules": [
                          {
                              "t": "set",
                              "p": "payload",
                              "pt": "msg",
                              "to": "payload.energy_consumption_calc_kWh",
                              "tot": "msg"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 880,
                      "y": 180,
                      "wires": [
                          [
                              "7562d54de63c4554"
                          ]
                      ]
                  },
                  {
                      "id": "7562d54de63c4554",
                      "type": "calculator",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "inputMsgField": "payload",
                      "outputMsgField": "payload",
                      "operation": "div",
                      "constant": "1000",
                      "round": true,
                      "decimals": "2",
                      "x": 1130,
                      "y": 180,
                      "wires": [
                          [
                              "7c3d8abd88fc55aa",
                              "ada862e65c4e3bf9"
                          ]
                      ]
                  },
                  {
                      "id": "7c3d8abd88fc55aa",
                      "type": "debug",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "active": true,
                      "tosidebar": true,
                      "console": false,
                      "tostatus": true,
                      "complete": "payload",
                      "targetType": "msg",
                      "statusVal": "payload",
                      "statusType": "auto",
                      "x": 1290,
                      "y": 140,
                      "wires": []
                  },
                  {
                      "id": "ada862e65c4e3bf9",
                      "type": "change",
                      "z": "c7b1863ec3de5b58",
                      "name": "flow.smartmeter.kwh",
                      "rules": [
                          {
                              "t": "set",
                              "p": "payload",
                              "pt": "msg",
                              "to": "smartmeter.kwh",
                              "tot": "flow"
                          }
                      ],
                      "action": "",
                      "property": "",
                      "from": "",
                      "to": "",
                      "reg": false,
                      "x": 1320,
                      "y": 240,
                      "wires": [
                          []
                      ]
                  },
                  {
                      "id": "4bb2def3f08ebd30",
                      "type": "inject",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "props": [
                          {
                              "p": "payload"
                          },
                          {
                              "p": "topic",
                              "vt": "str"
                          }
                      ],
                      "repeat": "",
                      "crontab": "",
                      "once": false,
                      "onceDelay": 0.1,
                      "topic": "",
                      "payload": "",
                      "payloadType": "date",
                      "x": 360,
                      "y": 340,
                      "wires": [
                          [
                              "229327472da1804a"
                          ]
                      ]
                  },
                  {
                      "id": "229327472da1804a",
                      "type": "switch",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "property": "payload",
                      "propertyType": "msg",
                      "rules": [
                          {
                              "t": "eq",
                              "v": "smartmeter.kwh",
                              "vt": "flow"
                          }
                      ],
                      "checkall": "true",
                      "repair": false,
                      "outputs": 1,
                      "x": 510,
                      "y": 340,
                      "wires": [
                          [
                              "87acd33c808325b1"
                          ]
                      ]
                  },
                  {
                      "id": "87acd33c808325b1",
                      "type": "debug",
                      "z": "c7b1863ec3de5b58",
                      "name": "",
                      "active": true,
                      "tosidebar": true,
                      "console": false,
                      "tostatus": false,
                      "complete": "false",
                      "statusVal": "",
                      "statusType": "auto",
                      "x": 710,
                      "y": 340,
                      "wires": []
                  },
                  {
                      "id": "501dcbe75f7121d1",
                      "type": "mqtt-broker",
                      "name": "",
                      "broker": "192.168.178.103",
                      "port": "1883",
                      "clientid": "",
                      "autoConnect": true,
                      "usetls": false,
                      "protocolVersion": "5",
                      "keepalive": "60",
                      "cleansession": true,
                      "birthTopic": "",
                      "birthQos": "0",
                      "birthPayload": "",
                      "birthMsg": {},
                      "closeTopic": "",
                      "closeQos": "0",
                      "closePayload": "",
                      "closeMsg": {},
                      "willTopic": "",
                      "willQos": "0",
                      "willPayload": "",
                      "willMsg": {},
                      "sessionExpiry": ""
                  }
              ]
              
              mickym 1 Reply Last reply Reply Quote 0
              • mickym
                mickym Most Active @hpgo last edited by mickym

                @hpgo Ich helf Dir gleich - nach 23 Uhr^^. Was Du in der Flow smartmeter.kwh gespeichert hast, ist doch die Summe die Du zum Tageswechseln brauchst?

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

                  @mickym
                  Ja bitte, ich freue mich über deine Hilfe sehr!
                  Das ist der Gesamtverbrauch des Hausanschlusses, also ja damit ich dann mit der neuen Summe vergleichen kann (neu minus alt).
                  Oder denk ich zu kompliziert??

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

                    @hpgo Also ich machs mal mit 2 Flowvariablen - aber eigentlich müsstest Du es mit Datenpunkten machen - entweder über mqtt oder iobroker Datenpunkte - da ja sonst nach jedem Neustart der Vortageswert weg ist.

                    Und die letzte Change Node musst natürlich umgekehrt machen, um die Flowvariable zu setzen.

                    15f0bab9-cfb1-4692-ba6e-c1d0ce174e77-image.png

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

                      @mickym
                      Ja, das stimmt natürlich - muss ich schauen wie ich das am besten machen kann. Bevorzugen würde ich eine Lösung im Mqtt Broker.
                      Grundsätzlich wüsste ich nicht wie ich das sonst umsetzen soll, als beide Werte zu vergleichen (Differenz)

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

                        @hpgo Na dann speicher das einfach unter einem Topic - hier mal wie man es mit Flowvariablen macht. Wenn Du mqtt topics nimmst, dann musst Du die sowieso wieder in Flowvariablen abspeichern - also parallel und dann setzen.

                        So einfach habe ich mir das vorgestellt:

                        [
                            {
                                "id": "4bb2def3f08ebd30",
                                "type": "inject",
                                "z": "c7b1863ec3de5b58",
                                "name": "trigger um Mitternacht",
                                "props": [
                                    {
                                        "p": "payload"
                                    }
                                ],
                                "repeat": "",
                                "crontab": "00 00 * * *",
                                "once": false,
                                "onceDelay": 0.1,
                                "topic": "",
                                "payload": "true",
                                "payloadType": "bool",
                                "x": 570,
                                "y": 440,
                                "wires": [
                                    [
                                        "16258346f6ff4528"
                                    ]
                                ]
                            },
                            {
                                "id": "87acd33c808325b1",
                                "type": "debug",
                                "z": "c7b1863ec3de5b58",
                                "name": "",
                                "active": true,
                                "tosidebar": true,
                                "console": false,
                                "tostatus": false,
                                "complete": "false",
                                "statusVal": "",
                                "statusType": "auto",
                                "x": 1050,
                                "y": 440,
                                "wires": []
                            },
                            {
                                "id": "16258346f6ff4528",
                                "type": "change",
                                "z": "c7b1863ec3de5b58",
                                "name": "",
                                "rules": [
                                    {
                                        "t": "set",
                                        "p": "aktuell",
                                        "pt": "msg",
                                        "to": "smartmeter.kwh",
                                        "tot": "flow"
                                    },
                                    {
                                        "t": "set",
                                        "p": "vortag",
                                        "pt": "msg",
                                        "to": "$flowContext(\"smartmeter.vortag\") ? $flowContext(\"smartmeter.vortag\") : 0\t\t\t",
                                        "tot": "jsonata"
                                    },
                                    {
                                        "t": "set",
                                        "p": "payload",
                                        "pt": "msg",
                                        "to": "aktuell - vortag",
                                        "tot": "jsonata"
                                    },
                                    {
                                        "t": "set",
                                        "p": "smartmeter.vortag",
                                        "pt": "flow",
                                        "to": "aktuell",
                                        "tot": "msg"
                                    }
                                ],
                                "action": "",
                                "property": "",
                                "from": "",
                                "to": "",
                                "reg": false,
                                "x": 810,
                                "y": 440,
                                "wires": [
                                    [
                                        "87acd33c808325b1"
                                    ]
                                ]
                            }
                        ]
                        

                        da0b6fbd-365b-4111-bdae-183c7fc10245-image.png

                        In der payload ist also der Verbrauch und zum Schluss wird der aktuelle Stand schon in den Wert vortag kopiert, um den dann beim nächsten Tageswechsel zur Verfügung zu haben.

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

                          @mickym
                          Ok ich glaube, ich beginne zu verstehen wie du das meist.
                          Leider ist das heute schon zu viel für mich, brauch ne mütze voll schlaf - werde mir das morgen nochmal genau anschauen und wenn ich darf auch nachfragen bei dir.

                          Für heute vielen lieben Dank

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

                            @hpgo sagte in Smartmeter -> NR:

                            @mickym
                            Ok ich glaube, ich beginne zu verstehen wie du das meist.
                            Leider ist das heute schon zu viel für mich, brauch ne mütze voll schlaf - werde mir das morgen nochmal genau anschauen und wenn ich darf auch nachfragen bei dir.

                            Für heute vielen lieben Dank

                            Na klar doch! - Freue mich immer, wenn es noch Leute gibt, die dieses fantastische Tool nutzen. Schlaf gut!!!

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

                              @hpgo Hier mal ein ganzer Flow - mit mqtt als Zwischenspeicher. Und statt der Divide Node habe ich eine normale genommen, da ich diese 1. nicht habe und ich Nodes vermeide, wenn ich das mit Boardmitteln erreichen kann:

                              [
                                 {
                                     "id": "4f4c02518d0af791",
                                     "type": "mqtt in",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "topic": "smartmeter/SmartyReader",
                                     "qos": "2",
                                     "datatype": "auto",
                                     "broker": "501dcbe75f7121d1",
                                     "nl": false,
                                     "rap": true,
                                     "rh": 0,
                                     "inputs": 0,
                                     "x": 430,
                                     "y": 180,
                                     "wires": [
                                         [
                                             "83af5ee7562b2766",
                                             "fdb8ec4dd58e4f02"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "83af5ee7562b2766",
                                     "type": "json",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "property": "payload",
                                     "action": "",
                                     "pretty": false,
                                     "x": 630,
                                     "y": 180,
                                     "wires": [
                                         [
                                             "483a142959cc36be"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "fdb8ec4dd58e4f02",
                                     "type": "debug",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "active": true,
                                     "tosidebar": true,
                                     "console": false,
                                     "tostatus": false,
                                     "complete": "false",
                                     "statusVal": "",
                                     "statusType": "auto",
                                     "x": 650,
                                     "y": 120,
                                     "wires": []
                                 },
                                 {
                                     "id": "483a142959cc36be",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "payload.energy_consumption_calc_kWh",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "payload",
                                             "pt": "msg",
                                             "to": "payload.energy_consumption_calc_kWh",
                                             "tot": "msg"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 880,
                                     "y": 180,
                                     "wires": [
                                         [
                                             "48a6e7bff5963893"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "4bb2def3f08ebd30",
                                     "type": "inject",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "trigger um Mitternacht",
                                     "props": [
                                         {
                                             "p": "payload"
                                         }
                                     ],
                                     "repeat": "",
                                     "crontab": "00 00 * * *",
                                     "once": false,
                                     "onceDelay": 0.1,
                                     "topic": "",
                                     "payload": "true",
                                     "payloadType": "bool",
                                     "x": 450,
                                     "y": 440,
                                     "wires": [
                                         [
                                             "16258346f6ff4528"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "16258346f6ff4528",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "aktuell",
                                             "pt": "msg",
                                             "to": "smartmeter.aktuell",
                                             "tot": "flow"
                                         },
                                         {
                                             "t": "set",
                                             "p": "vortag",
                                             "pt": "msg",
                                             "to": "$flowContext(\"smartmeter.vortag\") ? $flowContext(\"smartmeter.vortag\") : 0\t\t\t",
                                             "tot": "jsonata"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 690,
                                     "y": 440,
                                     "wires": [
                                         [
                                             "d5fb6df94bac6441",
                                             "10e449ba6576c606"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "48a6e7bff5963893",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "Divide",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "payload",
                                             "pt": "msg",
                                             "to": "payload /1000",
                                             "tot": "jsonata"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 1130,
                                     "y": 180,
                                     "wires": [
                                         [
                                             "c6f33ac925334c18"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "c6f33ac925334c18",
                                     "type": "mqtt out",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "topic": "smartmeter/aktuell",
                                     "qos": "0",
                                     "retain": "true",
                                     "respTopic": "",
                                     "contentType": "",
                                     "userProps": "",
                                     "correl": "",
                                     "expiry": "",
                                     "broker": "501dcbe75f7121d1",
                                     "x": 1310,
                                     "y": 180,
                                     "wires": []
                                 },
                                 {
                                     "id": "f6822e891382cc53",
                                     "type": "mqtt in",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "topic": "smartmeter/aktuell",
                                     "qos": "2",
                                     "datatype": "json",
                                     "broker": "501dcbe75f7121d1",
                                     "nl": false,
                                     "rap": true,
                                     "rh": 0,
                                     "inputs": 0,
                                     "x": 410,
                                     "y": 280,
                                     "wires": [
                                         [
                                             "3c9f037fa95cd9a0"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "2702b4f8d50278a9",
                                     "type": "mqtt in",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "topic": "smartmeter/vortag",
                                     "qos": "2",
                                     "datatype": "json",
                                     "broker": "501dcbe75f7121d1",
                                     "nl": false,
                                     "rap": true,
                                     "rh": 0,
                                     "inputs": 0,
                                     "x": 410,
                                     "y": 340,
                                     "wires": [
                                         [
                                             "1a76e50621c6f78f"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "3c9f037fa95cd9a0",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "smartmeter.aktuell",
                                             "pt": "flow",
                                             "to": "payload",
                                             "tot": "msg"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 700,
                                     "y": 280,
                                     "wires": [
                                         []
                                     ]
                                 },
                                 {
                                     "id": "1a76e50621c6f78f",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "smartmeter.vortag",
                                             "pt": "flow",
                                             "to": "payload",
                                             "tot": "msg"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 700,
                                     "y": 340,
                                     "wires": [
                                         []
                                     ]
                                 },
                                 {
                                     "id": "10e449ba6576c606",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "Tagesverbrauch",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "payload",
                                             "pt": "msg",
                                             "to": "aktuell - vortag",
                                             "tot": "jsonata"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 920,
                                     "y": 420,
                                     "wires": [
                                         [
                                             "b6d1f4335392c4c1"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "d5fb6df94bac6441",
                                     "type": "change",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "aktuell => vortag",
                                     "rules": [
                                         {
                                             "t": "set",
                                             "p": "payload",
                                             "pt": "msg",
                                             "to": "aktuell",
                                             "tot": "msg"
                                         }
                                     ],
                                     "action": "",
                                     "property": "",
                                     "from": "",
                                     "to": "",
                                     "reg": false,
                                     "x": 910,
                                     "y": 460,
                                     "wires": [
                                         [
                                             "b9f17858738e632f"
                                         ]
                                     ]
                                 },
                                 {
                                     "id": "b9f17858738e632f",
                                     "type": "mqtt out",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "topic": "smartmeter/vortag",
                                     "qos": "0",
                                     "retain": "true",
                                     "respTopic": "",
                                     "contentType": "",
                                     "userProps": "",
                                     "correl": "",
                                     "expiry": "",
                                     "broker": "501dcbe75f7121d1",
                                     "x": 1130,
                                     "y": 460,
                                     "wires": []
                                 },
                                 {
                                     "id": "b6d1f4335392c4c1",
                                     "type": "mqtt out",
                                     "z": "c7b1863ec3de5b58",
                                     "name": "",
                                     "topic": "smartmeter/tagesverbrauch",
                                     "qos": "0",
                                     "retain": "",
                                     "respTopic": "",
                                     "contentType": "",
                                     "userProps": "",
                                     "correl": "",
                                     "expiry": "",
                                     "broker": "501dcbe75f7121d1",
                                     "x": 1160,
                                     "y": 420,
                                     "wires": []
                                 },
                                 {
                                     "id": "501dcbe75f7121d1",
                                     "type": "mqtt-broker",
                                     "name": "",
                                     "broker": "192.168.178.103",
                                     "port": "1883",
                                     "clientid": "",
                                     "autoConnect": true,
                                     "usetls": false,
                                     "protocolVersion": "5",
                                     "keepalive": "60",
                                     "cleansession": true,
                                     "birthTopic": "",
                                     "birthQos": "0",
                                     "birthPayload": "",
                                     "birthMsg": {},
                                     "closeTopic": "",
                                     "closeQos": "0",
                                     "closePayload": "",
                                     "closeMsg": {},
                                     "willTopic": "",
                                     "willQos": "0",
                                     "willPayload": "",
                                     "willMsg": {},
                                     "sessionExpiry": ""
                                 }
                              ]
                              

                              50d96096-c7a8-413d-97bb-94b96357ebf0-image.png

                              Der erste Teil ist quasi dein bisheriger Flow ohne diese Divide Node (ich gehe mal davon aus, dass Du hier nur die payload durch 1000 teilst).

                              Im mittleren Teil werden die Inhalte der mqtt topics permanent für den Flow verfügbar gemacht.

                              Und der letzte teil triggert zum Tageswechsel, rechnet den Tagesverbrauch als Differenz zum Vortag aus und setzt den Vortageswert neu und speichert alles wieder im mqtt ab. Dadurch dass ich die Werte in den mqtt topics als retain abspeichere, werden die Flowvariablen automatisch nach Neustart des Flows wieder belegt.

                              Übrigens wenn Du in den mqtt-In Nodes die Opition ein analysiertes JSON Objekt nutzt, dann kannst DU Dir die JSON Node wahrscheinlich auch sparen.

                              e413b780-ed86-4487-a991-524411adea8f-image.png

                              Das nutze ich auch unten um Zahlenwerte rauszubekommen. Funktioniert leider bei normalen Stings nicht, habe ich aber mal an die NOde-Red Entwickler weiter gegeben und dürfte vielleicht in Node-Red Version 3.0.x enthalten sein.

                              https://discourse.nodered.org/t/improvement-of-mqtt-in-nodes/55445

                              https://github.com/node-red/node-red/blob/98b4b0dce057047c414e7a41b7220384c0c1d11a/CHANGELOG.md

                              Hoffe ich mal. 😉

                              e961376c-4546-4345-bb08-d4aea60ed116-image.png

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

                                @mickym
                                Wow, ein großes Dankeschön von mir für die Mühe. Jetzt muss ich mir das mal genauer anschauen.

                                Edit: Echt bombe, was du da in kurzer Zeit zusammengeklickt hast, dafür hätte ich Tage gebraucht.
                                Nochmal vielen Dank, bin dir wirklich dankbar, auch wenn ich vor allem im letzten Teil nicht alles verstehe.

                                Lg

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

                                  @hpgo sagte in Smartmeter -> NR:

                                  Nochmal vielen Dank, bin dir wirklich dankbar, auch wenn ich vor allem im letzten Teil nicht alles verstehe.
                                  Lg

                                  Na dann raus mit der Sprache - welche Node ist Dir unklar. Nur vom Fragen lernt man. 😉 ... oder welcher Teil des Flows (unten nach der Inject Node?)

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

                                    @mickym
                                    Tut mir leid das ich mich erst jetzt wieder melde, war unverhofft weg über Pfingsten.
                                    Genau, vor allem die 2 Regel in der Change Node "$flowContext("smartmeter.vortag") ? $flowContext("smartmeter.vortag") : 0" verstehe ich gar nicht.
                                    ? und $ Zeichen?

                                    Werde jetzt mal schauen, ob das mit dem Tagesverbrauch so funktioniert.
                                    Nochmals vielen lieben Dank an dich!

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

                                      @hpgo Nun alle Funktionen in JSONATA beginnen mit einem $

                                      347599bb-8625-4329-847e-de35f28cddc5-image.png

                                      Ansonsten ist das einfach eine normale Bedigung, die es sowohl unter Javascript also auch unter JSONATA gibt:

                                      Es wird hier nur der conditional Operator ? genommen: https://docs.jsonata.org/other-operators

                                      0ff244bc-17d2-41e9-beec-f29c29f6eb28-image.png

                                      In diesem Fall:

                                      Wenn ein Inhalt der Flow Variable smartmeter.vortag gelesen werden kann ( da sie bereits gesetzt/initialisiert wurde ), soll der Inhalt der Flow Variable smartmeter.vortag zurückgegeben werden, falls nicht, dann soll 0 zurückgeggeben werden.
                                      In der Change Node wird mit der 2. Regel als die Eigenschaft vortag des msg Objektes entweder auf 0 oder auf den Wert der Flowvariable smartmeter.vortag gesetzt.

                                      Man kann das Ganze aber auch ohne JSONATA Funkionen umsetzen:

                                      1038df46-912c-4380-b460-cde9f956b70e-image.png

                                      [
                                         {
                                             "id": "4bb2def3f08ebd30",
                                             "type": "inject",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "trigger um Mitternacht",
                                             "props": [
                                                 {
                                                     "p": "payload"
                                                 }
                                             ],
                                             "repeat": "",
                                             "crontab": "00 00 * * *",
                                             "once": false,
                                             "onceDelay": 0.1,
                                             "topic": "",
                                             "payload": "true",
                                             "payloadType": "bool",
                                             "x": 210,
                                             "y": 440,
                                             "wires": [
                                                 [
                                                     "551b8a4cf9ca56fa"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "16258346f6ff4528",
                                             "type": "change",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "aktuell",
                                                     "pt": "msg",
                                                     "to": "smartmeter.aktuell",
                                                     "tot": "flow"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 950,
                                             "y": 440,
                                             "wires": [
                                                 [
                                                     "d5fb6df94bac6441",
                                                     "10e449ba6576c606"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "10e449ba6576c606",
                                             "type": "change",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "Tagesverbrauch",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "payload",
                                                     "pt": "msg",
                                                     "to": "aktuell - vortag",
                                                     "tot": "jsonata"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 1200,
                                             "y": 420,
                                             "wires": [
                                                 [
                                                     "b6d1f4335392c4c1"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "d5fb6df94bac6441",
                                             "type": "change",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "aktuell => vortag",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "payload",
                                                     "pt": "msg",
                                                     "to": "aktuell",
                                                     "tot": "msg"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 1190,
                                             "y": 460,
                                             "wires": [
                                                 [
                                                     "b9f17858738e632f"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "551b8a4cf9ca56fa",
                                             "type": "switch",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "smartmeter.vortag definiert?",
                                             "property": "smartmeter.vortag",
                                             "propertyType": "flow",
                                             "rules": [
                                                 {
                                                     "t": "null"
                                                 },
                                                 {
                                                     "t": "nnull"
                                                 }
                                             ],
                                             "checkall": "true",
                                             "repair": false,
                                             "outputs": 2,
                                             "x": 480,
                                             "y": 440,
                                             "wires": [
                                                 [
                                                     "59f4a5f665f000f5"
                                                 ],
                                                 [
                                                     "7c6837d0718c7163"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "7c6837d0718c7163",
                                             "type": "change",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "vortag",
                                                     "pt": "msg",
                                                     "to": "smartmeter.vortag",
                                                     "tot": "flow"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 730,
                                             "y": 460,
                                             "wires": [
                                                 [
                                                     "16258346f6ff4528"
                                                 ]
                                             ]
                                         },
                                         {
                                             "id": "59f4a5f665f000f5",
                                             "type": "change",
                                             "z": "c7b1863ec3de5b58",
                                             "name": "",
                                             "rules": [
                                                 {
                                                     "t": "set",
                                                     "p": "vortag",
                                                     "pt": "msg",
                                                     "to": "0",
                                                     "tot": "num"
                                                 }
                                             ],
                                             "action": "",
                                             "property": "",
                                             "from": "",
                                             "to": "",
                                             "reg": false,
                                             "x": 730,
                                             "y": 420,
                                             "wires": [
                                                 [
                                                     "16258346f6ff4528"
                                                 ]
                                             ]
                                         }
                                      ]
                                      

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

                                        @mickym

                                        ... ich bin dir echt dankbar, leider melde ich mich erst jetzt wieder, unsere Familie ist größer geworden und deshalb bleibt für mein Hobby kaum noch Zeit.

                                        Ich werd mir deinen Flow hoffentlich am Abend genauer anschauen können. Außerdem hab ich dann auch noch eine Frage zu Daten persistent (über einen NR Neustart) halten/speichern in NR (Änderung in der settings.js). Dazu mache ich dann ein eigenes Thema auf.

                                        Danke und Lg

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

                                          @hpgo sagte in Smartmeter -> NR:

                                          @mickym

                                          ... ich bin dir echt dankbar, leider melde ich mich erst jetzt wieder, unsere Familie ist größer geworden und deshalb bleibt für mein Hobby kaum noch Zeit.

                                          Ich werd mir deinen Flow hoffentlich am Abend genauer anschauen können. Außerdem hab ich dann auch noch eine Frage zu Daten persistent (über einen NR Neustart) halten/speichern in NR (Änderung in der settings.js). Dazu mache ich dann ein eigenes Thema auf.

                                          Danke und Lg

                                          Da werde ich Dir nicht viel dazu sagen könne, da keine Daten im Dateisystem speichere. Bei mir sind die ja in der Regel im iobroker oder im mqtt.

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

                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          983
                                          Online

                                          31.7k
                                          Users

                                          79.8k
                                          Topics

                                          1.3m
                                          Posts

                                          2
                                          19
                                          683
                                          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