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.
    • 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
                  • J
                    JU_ @peterfido last edited by

                    @peterfido vielen Dank, probiere es gleich morgen früh aus! Melde mich. 🙂

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

                      @peterfido Es funktioniert! Vielen lieben Dank für deine Hilfe und deine Gedult!! ❤

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

                        @ju_ Prima. Danke für die Rückmeldung.

                        Edit: In den beiden Change-Nodes kann die Regel, wo die Werte nach flow.Datum und flow.Tage geschrieben werden, raus. Da brauchts nur das Topic. Den Rest macht die Function.

                        Die nimmt vom Datum die ersten 8 Stellen und vom Tage sucht die sich nur die Ziffern am Anfang raus. Wenn beides gefunden wurde, wird es weitergeleitet.

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        709
                        Online

                        31.7k
                        Users

                        79.7k
                        Topics

                        1.3m
                        Posts

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