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. Zwei Strings zusammenführen

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Zwei Strings zusammenführen

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

      Hallo Leute!
      Da mir das letzte mal schnell und umkompliziert geholfen wurde bin ich mal wieder zurückgekehrt.

      Folgendes:

      Ich bekomme vom KNX-BUS zwei Werte (als String), jeweils ein Datum und die Tage bis zum Datum, und würde diese gerne in einem String zusammenfassen. Der Soll dann wiefolgt aussehen:
      27.01.25 (13d) > Datum (Tage"d")
      Habe mir nach einigem Lesen im Internet die Methode rausgesucht, in welcher ich die zwei payloads in jeweils einen flow umwandle und diese dann in einer Funktion zusammensetze. Nur leider will das nicht so richtig.

      1.png
      2.png
      3.png

      Erkennt jemand meinen Fehler, oder kennt eine einfachere möglichkeit?

      Vielen Dank!

      J 1 Reply Last reply Reply Quote 0
      • J
        JU_ @JU_ last edited by

        @ju_

        So sieht der Output der Funktion aus:

        Output Funktion.png

        und so der Output von Datum und Tage nach der umwandlung mit der change node

        Datum_Tage.png

        P 1 Reply Last reply Reply Quote 0
        • P
          peterfido @JU_ last edited by peterfido

          @ju_

          Du hast einen Typo drin. GelbeDatum statt GelbDatum. Somit passt die Meldung, dass GelbeDatum nicht definiert ist.

          Das korrigieren und dann nochmal probieren. Ich würde statt

          flow.GelbeTage
          

          einfach eine Variable nehmen, oder direkt zuweisen.

          msg.payload = flow.get("GelbDatum") +  " (" + flow.get("GelbTage")+")";
          
          J 2 Replies Last reply Reply Quote 0
          • J
            JU_ @peterfido last edited by

            @peterfido vielen Dank, probiere es sofort am Freitag. 🙂

            1 Reply Last reply Reply Quote 0
            • J
              JU_ @peterfido last edited by

              @peterfido

              Die Funktion "msg.payload = flow.get("GelbDatum") + " (" + flow.get("GelbTage")+")";" funktioniert super (siehe Payload auf dem Bild). Nur leider erkennt die KNX Node den Payload nur zur hälfte (siehe Wert unter der Node). Hast du eine Ahnung wie es dazu kommt? Zu lang ist die Nachricht nicht. Sie ist genau 14 Werte Lang - so wie als maximum erlaubt.

              10.png

              P 1 Reply Last reply Reply Quote 0
              • P
                peterfido @JU_ last edited by

                @ju_
                mangels KNX kann ich da nur spekulieren. Evtl. mag es die Leerzeichen nicht, die Klammer, oder irgendwas anderes. Da stehen nichtdruckbare Zeichen im Node. Wo kommen die her? Evtl. mal dessen Werte posten.

                J 1 Reply Last reply Reply Quote 0
                • J
                  JU_ @peterfido last edited by JU_

                  @peterfido habe es bereits ohne Klammern und leerzeichen probiert. Bringt alles nichts. Aber die Debug Node zeigt immer das korrekte an. Ich weis nicht wieso die KNX Node die eigentlich druckbaren zeichen als nicht druckbare wertet. 😞

                  P 1 Reply Last reply Reply Quote 0
                  • P
                    peterfido @JU_ last edited by peterfido

                    @ju_ Ich habe eben mal geschaut. Du kannst wohl wählen, welches Datenformat Du willst. ASCII Zeichen, UTF8 Zeichen, etc.

                    Bei mir zeigt er aber keine Vorschau am Node selbst an. Habe ja auch keinen KNX-Bus, wohin das gesendet werden kann. Du kannst Dein Node-Diagramm ja mal exportieren und hier posten.

                    Bei mir sieht es so aus:
                    Bildschirmfoto 2025-01-17 um 16.38.33.png

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      JU_ @peterfido last edited by JU_

                      @peterfido kannst du mir erklären, wie ich ein "Node-Diagramm" exportiere? Dachte es geht nur über Bilder. Übrigend wenn ich über eine Inject Node direkt "27.01.25 (10d)" als "msg.payload" auf die KNX Node schicke funktioniert es. Also scheint sie irgendwas gegen den Output der Funktion zu haben.

                      11.png

                      P 1 Reply Last reply Reply Quote 0
                      • P
                        peterfido @JU_ last edited by

                        @ju_ ja, bei mir geht es auch. Ich frage mich, mit welchem KNX sich die Node standardmäßig verbindet.

                        Exportieren geht über das Menü oben rechts in Node-Red.

                        J 1 Reply Last reply Reply Quote 0
                        • J
                          JU_ @peterfido last edited by JU_

                          @peterfido und dann als JSON?

                          P 1 Reply Last reply Reply Quote 0
                          • P
                            peterfido @JU_ last edited by

                            @ju_ ja. Per JSON in die Zwischenablage und dann hier in Code-Tags posten.

                            J 1 Reply Last reply Reply Quote 0
                            • J
                              JU_ @peterfido last edited by JU_

                              @peterfido ist drin, musste ihn nochmal fix bearbeiten.

                              P 1 Reply Last reply Reply Quote 0
                              • P
                                peterfido @JU_ last edited by

                                @ju_ probiere es mal als Code. So lässt es sich nicht importieren. Code-Symbol ist </>

                                J 1 Reply Last reply Reply Quote 0
                                • J
                                  JU_ @peterfido last edited by JU_

                                  @peterfido ```
                                  [{"id":"90489d5f43af09b5","type":"knxUltimate","z":"de15a47dbea6c285","server":"98b73fada3be00aa","topic":"8/1/0","setTopicType":"str","outputtopic":"","dpt":"16.001","initialread":"1","notifyreadrequest":false,"notifyresponse":true,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","name":"Gelbe Tonne Datum","outputtype":"write","outputRBE":"true","inputRBE":"false","formatmultiplyvalue":1,"formatnegativevalue":"leave","formatdecimalsvalue":999,"passthrough":"no","sendMsgToKNXCode":"","receiveMsgFromKNXCode":"","listenallga":false,"x":130,"y":100,"wires":[["02034f10ed38c317"]]},{"id":"a2dbe9c2f590573a","type":"knxUltimate","z":"de15a47dbea6c285","server":"98b73fada3be00aa","topic":"8/2/0","setTopicType":"str","outputtopic":"","dpt":"16.001","initialread":"1","notifyreadrequest":false,"notifyresponse":true,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","name":"Gelbe Tonne Tage","outputtype":"write","outputRBE":"true","inputRBE":"false","formatmultiplyvalue":1,"formatnegativevalue":"leave","formatdecimalsvalue":999,"passthrough":"no","sendMsgToKNXCode":"","receiveMsgFromKNXCode":"","listenallga":false,"x":130,"y":160,"wires":[["4ea9b5ca4631e2ce"]]},{"id":"02034f10ed38c317","type":"change","z":"de15a47dbea6c285","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Datum","tot":"str"},{"t":"set","p":"GelbDatum","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":100,"wires":[["5b74298a9d871858"]]},{"id":"4ea9b5ca4631e2ce","type":"change","z":"de15a47dbea6c285","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Tage","tot":"str"},{"t":"set","p":"GelbTage","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":160,"wires":[["5b74298a9d871858"]]},{"id":"58a426e6d74f6020","type":"knxUltimate","z":"de15a47dbea6c285","server":"98b73fada3be00aa","topic":"8/3/0","setTopicType":"str","outputtopic":"","dpt":"16.001","initialread":0,"notifyreadrequest":false,"notifyresponse":false,"notifywrite":true,"notifyreadrequestalsorespondtobus":false,"notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized":"0","name":"Zusammengesetztes Datum Gelb","outputtype":"write","outputRBE":"true","inputRBE":"false","formatmultiplyvalue":1,"formatnegativevalue":"leave","formatdecimalsvalue":999,"passthrough":"no","sendMsgToKNXCode":"","receiveMsgFromKNXCode":"","listenallga":false,"x":1230,"y":100,"wires":[[]]},{"id":"2861740aaba0f1c9","type":"inject","z":"de15a47dbea6c285","name":"Manuelle Betätigung","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"27.01.25 (10d)","payloadType":"str","x":890,"y":20,"wires":[["58a426e6d74f6020"]]},{"id":"d22d4525c542b4d0","type":"debug","z":"de15a47dbea6c285","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1140,"y":180,"wires":[]},{"id":"cccfb4eb94a27733","type":"change","z":"de15a47dbea6c285","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"8/3/0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":100,"wires":[["58a426e6d74f6020","d22d4525c542b4d0"]]},{"id":"5b74298a9d871858","type":"function","z":"de15a47dbea6c285","name":"function 3","func":"msg.payload = flow.get("GelbDatum") + " (" + flow.get("GelbTage") + "d)";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":100,"wires":[["cccfb4eb94a27733"]]},{"id":"141076626e9e6cf8","type":"inject","z":"de15a47dbea6c285","name":"Manuelle Betätigung","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":350,"y":40,"wires":[["5b74298a9d871858"]]},{"id":"98b73fada3be00aa","type":"knxUltimate-config","host":"10.0.0.2","port":"3671","physAddr":"1.1.64","hostProtocol":"TunnelUDP","suppressACKRequest":false,"csv":"","KNXEthInterface":"Auto","KNXEthInterfaceManuallyInput":"","stopETSImportIfNoDatapoint":"fake","loglevel":"error","name":"KNX Gateway","localEchoInTunneling":true,"delaybetweentelegrams":"50","ignoreTelegramsWithRepeatedFlag":false,"autoReconnect":"yes"}]

                                  P 1 Reply Last reply Reply Quote 0
                                  • P
                                    peterfido @JU_ last edited by

                                    @ju_ Das Symbol anklicken und dann zwischen den '' einfügen.
                                    Bildschirmfoto 2025-01-17 um 16.52.44.png

                                    J 1 Reply Last reply Reply Quote 0
                                    • J
                                      JU_ @peterfido last edited by

                                      @peterfido habe ich verstanden, ist oben geändert. Sorry 😄

                                      P 1 Reply Last reply Reply Quote 0
                                      • P
                                        peterfido @JU_ last edited by

                                        @ju_ Fast 🙂

                                        Sollte so aussehen:

                                        [
                                            {
                                                "id": "076b7140f384fc31",
                                                "type": "tab",
                                                "label": "Flow 2",
                                                "disabled": false,
                                                "info": "",
                                                "env": []
                                            },
                                            {
                                                "id": "4be12d8e923cd33b",
                                                "type": "knxUltimate",
                                                "z": "076b7140f384fc31",
                                                "server": "2e5af07acfd111fe",
                                                "topic": "8/3/0",
                                                "setTopicType": "str",
                                                "outputtopic": "",
                                                "dpt": "16.000",
                                                "initialread": 0,
                                                "notifyreadrequest": false,
                                                "notifyresponse": false,
                                                "notifywrite": true,
                                                "notifyreadrequestalsorespondtobus": false,
                                                "notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized": "0",
                                                "name": "",
                                                "outputtype": "write",
                                                "outputRBE": "true",
                                                "inputRBE": "false",
                                                "formatmultiplyvalue": 1,
                                                "formatnegativevalue": "leave",
                                                "formatdecimalsvalue": 999,
                                                "passthrough": "yes",
                                                "sendMsgToKNXCode": "",
                                                "receiveMsgFromKNXCode": "",
                                                "listenallga": false,
                                                "x": 360,
                                                "y": 100,
                                                "wires": [
                                                    [
                                                        "2d3c593b7f85b176"
                                                    ]
                                                ]
                                            },
                                            {
                                                "id": "b0b348a7ad1db526",
                                                "type": "inject",
                                                "z": "076b7140f384fc31",
                                                "name": "",
                                                "props": [
                                                    {
                                                        "p": "payload"
                                                    },
                                                    {
                                                        "p": "topic",
                                                        "vt": "str"
                                                    }
                                                ],
                                                "repeat": "",
                                                "crontab": "",
                                                "once": false,
                                                "onceDelay": 0.1,
                                                "topic": "",
                                                "payload": "30.01.25 (13d)",
                                                "payloadType": "str",
                                                "x": 170,
                                                "y": 100,
                                                "wires": [
                                                    [
                                                        "4be12d8e923cd33b"
                                                    ]
                                                ]
                                            },
                                            {
                                                "id": "2d3c593b7f85b176",
                                                "type": "debug",
                                                "z": "076b7140f384fc31",
                                                "name": "debug 2",
                                                "active": true,
                                                "tosidebar": true,
                                                "console": false,
                                                "tostatus": false,
                                                "complete": "true",
                                                "targetType": "full",
                                                "statusVal": "",
                                                "statusType": "auto",
                                                "x": 560,
                                                "y": 100,
                                                "wires": []
                                            },
                                            {
                                                "id": "2e5af07acfd111fe",
                                                "type": "knxUltimate-config",
                                                "host": "224.0.23.12",
                                                "port": "3671",
                                                "physAddr": "15.15.22",
                                                "hostProtocol": "Auto",
                                                "suppressACKRequest": false,
                                                "csv": "",
                                                "KNXEthInterface": "Auto",
                                                "KNXEthInterfaceManuallyInput": "",
                                                "stopETSImportIfNoDatapoint": "fake",
                                                "loglevel": "error",
                                                "name": "KNX Gateway",
                                                "localEchoInTunneling": true,
                                                "delaybetweentelegrams": "25",
                                                "ignoreTelegramsWithRepeatedFlag": false,
                                                "autoReconnect": "yes"
                                            }
                                        ]
                                        
                                        J 1 Reply Last reply Reply Quote 0
                                        • J
                                          JU_ @peterfido last edited by JU_

                                          @peterfido jetzt 😄

                                          [
                                              {
                                                  "id": "90489d5f43af09b5",
                                                  "type": "knxUltimate",
                                                  "z": "de15a47dbea6c285",
                                                  "server": "98b73fada3be00aa",
                                                  "topic": "8/1/0",
                                                  "setTopicType": "str",
                                                  "outputtopic": "",
                                                  "dpt": "16.001",
                                                  "initialread": "1",
                                                  "notifyreadrequest": false,
                                                  "notifyresponse": true,
                                                  "notifywrite": true,
                                                  "notifyreadrequestalsorespondtobus": false,
                                                  "notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized": "0",
                                                  "name": "Gelbe Tonne Datum",
                                                  "outputtype": "write",
                                                  "outputRBE": "true",
                                                  "inputRBE": "false",
                                                  "formatmultiplyvalue": 1,
                                                  "formatnegativevalue": "leave",
                                                  "formatdecimalsvalue": 999,
                                                  "passthrough": "no",
                                                  "sendMsgToKNXCode": "",
                                                  "receiveMsgFromKNXCode": "",
                                                  "listenallga": false,
                                                  "x": 130,
                                                  "y": 100,
                                                  "wires": [
                                                      [
                                                          "02034f10ed38c317"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "a2dbe9c2f590573a",
                                                  "type": "knxUltimate",
                                                  "z": "de15a47dbea6c285",
                                                  "server": "98b73fada3be00aa",
                                                  "topic": "8/2/0",
                                                  "setTopicType": "str",
                                                  "outputtopic": "",
                                                  "dpt": "16.001",
                                                  "initialread": "1",
                                                  "notifyreadrequest": false,
                                                  "notifyresponse": true,
                                                  "notifywrite": true,
                                                  "notifyreadrequestalsorespondtobus": false,
                                                  "notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized": "0",
                                                  "name": "Gelbe Tonne Tage",
                                                  "outputtype": "write",
                                                  "outputRBE": "true",
                                                  "inputRBE": "false",
                                                  "formatmultiplyvalue": 1,
                                                  "formatnegativevalue": "leave",
                                                  "formatdecimalsvalue": 999,
                                                  "passthrough": "no",
                                                  "sendMsgToKNXCode": "",
                                                  "receiveMsgFromKNXCode": "",
                                                  "listenallga": false,
                                                  "x": 130,
                                                  "y": 160,
                                                  "wires": [
                                                      [
                                                          "4ea9b5ca4631e2ce"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "02034f10ed38c317",
                                                  "type": "change",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "",
                                                  "rules": [
                                                      {
                                                          "t": "set",
                                                          "p": "topic",
                                                          "pt": "msg",
                                                          "to": "Datum",
                                                          "tot": "str"
                                                      },
                                                      {
                                                          "t": "set",
                                                          "p": "GelbDatum",
                                                          "pt": "flow",
                                                          "to": "payload",
                                                          "tot": "msg"
                                                      }
                                                  ],
                                                  "action": "",
                                                  "property": "",
                                                  "from": "",
                                                  "to": "",
                                                  "reg": false,
                                                  "x": 360,
                                                  "y": 100,
                                                  "wires": [
                                                      [
                                                          "5b74298a9d871858"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "4ea9b5ca4631e2ce",
                                                  "type": "change",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "",
                                                  "rules": [
                                                      {
                                                          "t": "set",
                                                          "p": "topic",
                                                          "pt": "msg",
                                                          "to": "Tage",
                                                          "tot": "str"
                                                      },
                                                      {
                                                          "t": "set",
                                                          "p": "GelbTage",
                                                          "pt": "flow",
                                                          "to": "payload",
                                                          "tot": "msg"
                                                      }
                                                  ],
                                                  "action": "",
                                                  "property": "",
                                                  "from": "",
                                                  "to": "",
                                                  "reg": false,
                                                  "x": 360,
                                                  "y": 160,
                                                  "wires": [
                                                      [
                                                          "5b74298a9d871858"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "58a426e6d74f6020",
                                                  "type": "knxUltimate",
                                                  "z": "de15a47dbea6c285",
                                                  "server": "98b73fada3be00aa",
                                                  "topic": "8/3/0",
                                                  "setTopicType": "str",
                                                  "outputtopic": "",
                                                  "dpt": "16.001",
                                                  "initialread": 0,
                                                  "notifyreadrequest": false,
                                                  "notifyresponse": false,
                                                  "notifywrite": true,
                                                  "notifyreadrequestalsorespondtobus": false,
                                                  "notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized": "0",
                                                  "name": "Zusammengesetztes Datum Gelb",
                                                  "outputtype": "write",
                                                  "outputRBE": "true",
                                                  "inputRBE": "false",
                                                  "formatmultiplyvalue": 1,
                                                  "formatnegativevalue": "leave",
                                                  "formatdecimalsvalue": 999,
                                                  "passthrough": "no",
                                                  "sendMsgToKNXCode": "",
                                                  "receiveMsgFromKNXCode": "",
                                                  "listenallga": false,
                                                  "x": 1230,
                                                  "y": 100,
                                                  "wires": [
                                                      []
                                                  ]
                                              },
                                              {
                                                  "id": "2861740aaba0f1c9",
                                                  "type": "inject",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "Manuelle Betätigung",
                                                  "props": [
                                                      {
                                                          "p": "payload"
                                                      }
                                                  ],
                                                  "repeat": "",
                                                  "crontab": "",
                                                  "once": false,
                                                  "onceDelay": 0.1,
                                                  "topic": "",
                                                  "payload": "27.01.25 (10d)",
                                                  "payloadType": "str",
                                                  "x": 890,
                                                  "y": 20,
                                                  "wires": [
                                                      [
                                                          "58a426e6d74f6020"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "d22d4525c542b4d0",
                                                  "type": "debug",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "debug 1",
                                                  "active": true,
                                                  "tosidebar": true,
                                                  "console": false,
                                                  "tostatus": false,
                                                  "complete": "true",
                                                  "targetType": "full",
                                                  "statusVal": "",
                                                  "statusType": "auto",
                                                  "x": 1140,
                                                  "y": 180,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "cccfb4eb94a27733",
                                                  "type": "change",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "",
                                                  "rules": [
                                                      {
                                                          "t": "set",
                                                          "p": "topic",
                                                          "pt": "msg",
                                                          "to": "8/3/0",
                                                          "tot": "str"
                                                      }
                                                  ],
                                                  "action": "",
                                                  "property": "",
                                                  "from": "",
                                                  "to": "",
                                                  "reg": false,
                                                  "x": 850,
                                                  "y": 100,
                                                  "wires": [
                                                      [
                                                          "58a426e6d74f6020",
                                                          "d22d4525c542b4d0"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "5b74298a9d871858",
                                                  "type": "function",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "function 3",
                                                  "func": "msg.payload = flow.get(\"GelbDatum\") + \" (\" + flow.get(\"GelbTage\") + \"d)\";\nreturn msg;",
                                                  "outputs": 1,
                                                  "timeout": 0,
                                                  "noerr": 0,
                                                  "initialize": "",
                                                  "finalize": "",
                                                  "libs": [],
                                                  "x": 620,
                                                  "y": 100,
                                                  "wires": [
                                                      [
                                                          "cccfb4eb94a27733"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "141076626e9e6cf8",
                                                  "type": "inject",
                                                  "z": "de15a47dbea6c285",
                                                  "name": "Manuelle Betätigung",
                                                  "props": [
                                                      {
                                                          "p": "topic",
                                                          "vt": "str"
                                                      }
                                                  ],
                                                  "repeat": "",
                                                  "crontab": "",
                                                  "once": false,
                                                  "onceDelay": 0.1,
                                                  "topic": "",
                                                  "x": 350,
                                                  "y": 40,
                                                  "wires": [
                                                      [
                                                          "5b74298a9d871858"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "98b73fada3be00aa",
                                                  "type": "knxUltimate-config",
                                                  "host": "10.0.0.2",
                                                  "port": "3671",
                                                  "physAddr": "1.1.64",
                                                  "hostProtocol": "TunnelUDP",
                                                  "suppressACKRequest": false,
                                                  "csv": "",
                                                  "KNXEthInterface": "Auto",
                                                  "KNXEthInterfaceManuallyInput": "",
                                                  "stopETSImportIfNoDatapoint": "fake",
                                                  "loglevel": "error",
                                                  "name": "KNX Gateway",
                                                  "localEchoInTunneling": true,
                                                  "delaybetweentelegrams": "50",
                                                  "ignoreTelegramsWithRepeatedFlag": false,
                                                  "autoReconnect": "yes"
                                              }
                                          ]
                                          
                                          P 1 Reply Last reply Reply Quote 0
                                          • P
                                            peterfido @JU_ last edited by peterfido

                                            @ju_ probiere mal:

                                            [
                                                {
                                                    "id": "5b74298a9d871858",
                                                    "type": "function",
                                                    "z": "e85adb77025ff03d",
                                                    "name": "function 3",
                                                    "func": "if(msg.topic==\"Datum\"){\n    flow.set(\"GelbDatum\", msg.payload.slice(0,8));\n}\nif(msg.topic==\"Tage\"){\n    var s = msg.payload;\n    for(var i=1;i<s.length;i++){\n        var x = s.slice(i,i+1);\n        if(isNaN(x)){\n            flow.set(\"GelbTage\", s.slice(0,i-1));\n            break;\n        }\n    }\n}\nnode.status({ text: flow.get(\"GelbDatum\") + flow.get(\"GelbTage\") + \" \" + x });\n\nif(flow.get(\"GelbDatum\").length > 0  && flow.get(\"GelbTage\").length > 0) {\n    msg.payload = flow.get(\"GelbDatum\").slice(0,8) + \" (\" + flow.get(\"GelbTage\") + \"d)\";\n    node.status({text: msg.payload});\n    return msg;\n}",
                                                    "outputs": 1,
                                                    "timeout": 0,
                                                    "noerr": 0,
                                                    "initialize": "// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\nflow.set(\"GelbDatum\",\"\");\nflow.set(\"GelbTage\", \"\");\n",
                                                    "finalize": "",
                                                    "libs": [],
                                                    "x": 620,
                                                    "y": 200,
                                                    "wires": [
                                                        [
                                                            "cccfb4eb94a27733"
                                                        ]
                                                    ]
                                                }
                                            ]
                                            

                                            Ich habe die Strings jetzt nach der erwarteten Länge abgeschnitten.

                                            Im Prinzip nur die Function Node:

                                            if(msg.topic=="Datum"){
                                                flow.set("GelbDatum", msg.payload.slice(0,8));
                                            }
                                            if(msg.topic=="Tage"){
                                                var s = msg.payload;
                                                for(var i=1;i<s.length;i++){
                                                    var x = s.slice(i,i+1);
                                                    if(isNaN(x)){
                                                        flow.set("GelbTage", s.slice(0,i-1));
                                                        break;
                                                    }
                                                }
                                            }
                                            node.status({ text: flow.get("GelbDatum") + flow.get("GelbTage") + " " + x });
                                            
                                            if(flow.get("GelbDatum").length > 0  && flow.get("GelbTage").length > 0) {
                                                msg.payload = flow.get("GelbDatum").slice(0,8) + " (" + flow.get("GelbTage") + "d)";
                                                node.status({text: msg.payload});
                                                return msg;
                                            }
                                            

                                            Ich habe es nochmal editiert.

                                            Im Start-Bereich der Function die Variablen zurücksetzen. Sonst bleiben die alten Werte.

                                            flow.set("GelbDatum","");
                                            flow.set("GelbTage", "");
                                            
                                            J 2 Replies Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            810
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            2
                                            23
                                            712
                                            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