Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. JavaScript
  5. Textvariablen mit & - wie trennen?

NEWS

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    17
    1
    2.8k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.1k

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    25
    1
    2.4k

Textvariablen mit & - wie trennen?

Scheduled Pinned Locked Moved JavaScript
29 Posts 8 Posters 2.6k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F fastfoot

    Blockly macht mich mittlerweile ganz kirre :-) Alternative:

    const txtorg = "PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60";
    const txt = decodeURIComponent(txtorg);
    const json = '{"' + txt.replaceAll('&', '","').replaceAll('=', '":"') + '"}';
    const obj = JSON.parse(json);
    log(obj.tempf);
    log(obj.dateutc);
    log(obj.humidity);
    
    H Offline
    H Offline
    hendrik87
    wrote on last edited by
    #6

    @fastfoot Vielen Dank, das sieht gut aus ;)

    1 Reply Last reply
    0
    • HomoranH Homoran

      @fastfoot sagte in Textvariablen mit & - wie trennen?:

      Blockly macht mich mittlerweile ganz kirre

      SORRY!
      Hab die Unterkategorie nicht gesehen :-(

      F Offline
      F Offline
      fastfoot
      wrote on last edited by
      #7

      @homoran Och, ich seh das nicht so eng, Deine Lösung ist sicher für die Blockly-Fan Gemeinde interessant. Meine ersten Gehversuche mit Javascript waren hier im Forum, mit Blockly :-)

      iobroker läuft unter Docker auf QNAP TS-451+
      SkriptRecovery: https://forum.iobroker.net/post/930558

      HomoranH 1 Reply Last reply
      1
      • F fastfoot

        @homoran Och, ich seh das nicht so eng, Deine Lösung ist sicher für die Blockly-Fan Gemeinde interessant. Meine ersten Gehversuche mit Javascript waren hier im Forum, mit Blockly :-)

        HomoranH Offline
        HomoranH Offline
        Homoran
        Global Moderator Administrators
        wrote on last edited by
        #8

        @fastfoot ich hatte beim letzten Versuch anscheinend genau das versucht, was du da als js hast.
        bekam aber dauernd ' und " gemischt heraus, so dass ich kein valides json hinbekommen hatte.
        jetzt hatte uch es über Listen versucht.
        Hat mir aber keine Ruhe gelassen, mit Trick klappte s auch mit JSON Erstellung via Blockly.

        ich bin so frei
        Screenshot_20250419-223116_Firefox.jpg
        Ich musste in zwei Schritten ersetzen

        kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

        Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

        der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

        1 Reply Last reply
        1
        • F fastfoot

          Blockly macht mich mittlerweile ganz kirre :-) Alternative:

          const txtorg = "PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60";
          const txt = decodeURIComponent(txtorg);
          const json = '{"' + txt.replaceAll('&', '","').replaceAll('=', '":"') + '"}';
          const obj = JSON.parse(json);
          log(obj.tempf);
          log(obj.dateutc);
          log(obj.humidity);
          
          T Offline
          T Offline
          ticaki
          wrote on last edited by ticaki
          #9

          @fastfoot sagte in Textvariablen mit & - wie trennen?:

          Blockly macht mich mittlerweile ganz kirre :-) Alternative:

          const txtorg = "PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60";
          

          const txt = decodeURIComponent(txtorg);
          const json = '{"' + txt.replaceAll('&', '","').replaceAll('=', '":"') + '"}';
          const obj = JSON.parse(json);
          log(obj.tempf);
          log(obj.dateutc);
          log(obj.humidity);

          Gute Idee :)

          Da sollte ein try catch drum sein. Zur Sicherheit und das hier in Zeile 2:

          // EDIT - wegen Forumsdarstellungfehlern es wird nur 1 \ dargestellt in manchen Fällen
          // const txt = decodeURIComponent(txtorg).replaceAll(/[^
          // da müssen jetzt 2 \ eingefügt werden und dann nachfolgendes angehangen
          // ]"/g, '\\"');
          
          const txt = decodeURIComponent(txtorg).replaceAll(/[^\\]"/g, '\\"');
          

          Wenn da ein " im Text steht gibt es sonst nen Fehler.

          Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

          Spenden

          F 1 Reply Last reply
          0
          • T ticaki

            @fastfoot sagte in Textvariablen mit & - wie trennen?:

            Blockly macht mich mittlerweile ganz kirre :-) Alternative:

            const txtorg = "PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60";
            

            const txt = decodeURIComponent(txtorg);
            const json = '{"' + txt.replaceAll('&', '","').replaceAll('=', '":"') + '"}';
            const obj = JSON.parse(json);
            log(obj.tempf);
            log(obj.dateutc);
            log(obj.humidity);

            Gute Idee :)

            Da sollte ein try catch drum sein. Zur Sicherheit und das hier in Zeile 2:

            // EDIT - wegen Forumsdarstellungfehlern es wird nur 1 \ dargestellt in manchen Fällen
            // const txt = decodeURIComponent(txtorg).replaceAll(/[^
            // da müssen jetzt 2 \ eingefügt werden und dann nachfolgendes angehangen
            // ]"/g, '\\"');
            
            const txt = decodeURIComponent(txtorg).replaceAll(/[^\\]"/g, '\\"');
            

            Wenn da ein " im Text steht gibt es sonst nen Fehler.

            F Offline
            F Offline
            fastfoot
            wrote on last edited by
            #10

            @ticaki sagte in Textvariablen mit & - wie trennen?:

            Da sollte...

            vor Allem solltest Du deine Ratschläge testen, bevor du die veröffentlichst :-)

            iobroker läuft unter Docker auf QNAP TS-451+
            SkriptRecovery: https://forum.iobroker.net/post/930558

            T 1 Reply Last reply
            0
            • F fastfoot

              @ticaki sagte in Textvariablen mit & - wie trennen?:

              Da sollte...

              vor Allem solltest Du deine Ratschläge testen, bevor du die veröffentlichst :-)

              T Offline
              T Offline
              ticaki
              wrote on last edited by ticaki
              #11

              @fastfoot
              Verstehe ich nicht

              const txtorg = 'PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60';
              const txt = decodeURIComponent(txtorg).replaceAll(/[^\\]"/g, '\\"');
              try {
                  const json = '{"' + txt.replaceAll('&', '","').replaceAll('=', '":"') + '"}';
              const obj = JSON.parse(json);
              log(obj.tempf);
              log(obj.dateutc);
              log(obj.humidity);
              } catch (e) {
                  log(e)
              }
              

              so sieht das in meinen Skript aus - oben hab ich kein " ein "und ein \" eingefügt.

              Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

              Spenden

              F 1 Reply Last reply
              1
              • T ticaki

                @fastfoot
                Verstehe ich nicht

                const txtorg = 'PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60';
                const txt = decodeURIComponent(txtorg).replaceAll(/[^\\]"/g, '\\"');
                try {
                    const json = '{"' + txt.replaceAll('&', '","').replaceAll('=', '":"') + '"}';
                const obj = JSON.parse(json);
                log(obj.tempf);
                log(obj.dateutc);
                log(obj.humidity);
                } catch (e) {
                    log(e)
                }
                

                so sieht das in meinen Skript aus - oben hab ich kein " ein "und ein \" eingefügt.

                F Offline
                F Offline
                fastfoot
                wrote on last edited by
                #12

                @ticaki das kompiliert doch so gar nicht! Der Grund ist in Zeile 2

                iobroker läuft unter Docker auf QNAP TS-451+
                SkriptRecovery: https://forum.iobroker.net/post/930558

                T 1 Reply Last reply
                0
                • F fastfoot

                  @ticaki das kompiliert doch so gar nicht! Der Grund ist in Zeile 2

                  T Offline
                  T Offline
                  ticaki
                  wrote on last edited by ticaki
                  #13

                  @fastfoot
                  Da stehe ich jetzt auf dem Schlauch - der Code geht bei mir in typescript und javascript.

                  Bildschirmfoto 2025-04-21 um 13.42.45.png

                  JS Adapter v8.9.1 / nodejs 20.x.x

                  Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

                  Spenden

                  F 1 Reply Last reply
                  0
                  • haus-automatisierungH Online
                    haus-automatisierungH Online
                    haus-automatisierung
                    Developer Most Active
                    wrote on last edited by haus-automatisierung
                    #14

                    Warum alles selbst zerlegen? URLSearchParams ist genau dafür gedacht.

                    const url = require('node:url');
                    
                    const urlParams = 'PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60';
                    const params = new url.URLSearchParams(urlParams);
                    const obj = {};
                    
                    for (const key of params.keys()) {
                        obj[key] = params.get(key);
                    }
                    
                    console.log(JSON.stringify(obj));
                    

                    @hendrik87 sagte in Textvariablen mit & - wie trennen?:

                    Mit welchem Befehl kann ich hier einzelne Werte auslesen (z.B. "tempf")?

                    Das ist dann sogar noch einfacher:

                    const url = require('node:url');
                    
                    const urlParams = 'PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60';
                    const params = new url.URLSearchParams(urlParams);
                    
                    const tempf = params.get('tempf');
                    
                    console.log(tempf);
                    

                    🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                    🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                    📚 Meine inoffizielle ioBroker Dokumentation

                    1 Reply Last reply
                    2
                    • T Offline
                      T Offline
                      ticaki
                      wrote on last edited by
                      #15

                      Mein Beispiel oben um einen Kommentar ergänzt, der die richtige Schreibweise erklärt, ohne die nachfolgende Diskussion aus dem Kontext zu reissen.

                      Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

                      Spenden

                      1 Reply Last reply
                      0
                      • H hendrik87

                        Hallo

                        Ich bekomme von meiner Ecowitt Wetterstation die Werte per MQTT zugeschickt. Dies ist ein Text, wo die einzelnen Variablen durch $ getrennt sind.

                        PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60
                        

                        Mit welchem Befehl kann ich hier einzelne Werte auslesen (z.B. "tempf")?

                        Gruß Hendrik

                        mickymM Offline
                        mickymM Offline
                        mickym
                        Most Active
                        wrote on last edited by mickym
                        #16

                        @hendrik87 sagte in Textvariablen mit & - wie trennen?:

                        PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60

                        Ich würde so was natürlich mit JSONATA in ein Objekt überführen, dann kann einzelne Werte ganz bequem selektieren:
                        9bf5b934-2697-48c1-bfc6-323ccb3732f3-image.png

                        Hier der JSONATA Ausdruck

                        $split($,"&"){$substringBefore("="):$substringAfter("=")}
                        

                        <xml xmlns="https://developers.google.com/blockly/xml">
                         <variables>
                           <variable id="hu+F[F+=/+n6(w#b!bkk">Text</variable>
                           <variable id="8+=Mk?BD}YCcGl~4E)j|">Objekt</variable>
                         </variables>
                         <block type="variables_set" id="^~Sv#fxrrEl3v%:$_j(K" x="-137" y="63">
                           <field name="VAR" id="hu+F[F+=/+n6(w#b!bkk">Text</field>
                           <value name="VALUE">
                             <block type="text" id="}KJz}$Rs!%XxMZl%j4_w">
                               <field name="TEXT">PASSKEY=xxx&amp;stationtype=GW2000A_V3.2.2&amp;runtime=86732&amp;heap=82460&amp;dateutc=2025-04-19%2018%3A57%3A39&amp;tempinf=69.08&amp;humidityin=43&amp;baromrelin=29.740&amp;baromabsin=29.740&amp;tempf=46.40&amp;humidity=76&amp;vpd=0.076&amp;winddir=304&amp;windspeedmph=3.80&amp;windgustmph=7.38&amp;maxdailygust=13.65&amp;solarradiation=0.16&amp;uv=0&amp;rrain_piezo=0.000&amp;erain_piezo=0.000&amp;hrain_piezo=0.000&amp;drain_piezo=0.000&amp;wrain_piezo=0.409&amp;mrain_piezo=0.409&amp;yrain_piezo=0.409&amp;srain_piezo=0&amp;ws90cap_volt=5.2&amp;ws90_ver=133&amp;wh90batt=3.26&amp;freq=868M&amp;model=GW2000A&amp;interval=60</field>
                             </block>
                           </value>
                           <next>
                             <block type="variables_set" id="_D5~rAL,~%b==9Nf3*L`">
                               <field name="VAR" id="8+=Mk?BD}YCcGl~4E)j|">Objekt</field>
                               <value name="VALUE">
                                 <block type="convert_jsonata" id="u}[_Z`KWHAeHkdE@@V?=">
                                   <value name="EXPRESSION">
                                     <shadow type="text" id="eg-6.rV=oGTM`RArquVg">
                                       <field name="TEXT">$split($,"&amp;"){$substringBefore("="):$substringAfter("=")}</field>
                                     </shadow>
                                   </value>
                                   <value name="TARGET">
                                     <block type="variables_get" id="n+aI}jp_T]nxZ439rGaK">
                                       <field name="VAR" id="hu+F[F+=/+n6(w#b!bkk">Text</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                               <next>
                                 <block type="debug" id="k08ZC410l/7`T|+g_+w@">
                                   <field name="Severity">info</field>
                                   <value name="TEXT">
                                     <shadow type="text" id=",T!NCf4e|u/ADp:g1bn[">
                                       <field name="TEXT">test</field>
                                     </shadow>
                                     <block type="variables_get" id="xX[*0A$F`nN{~,hNEQSb">
                                       <field name="VAR" id="8+=Mk?BD}YCcGl~4E)j|">Objekt</field>
                                     </block>
                                   </value>
                                   <next>
                                     <block type="debug" id="$ZA{KAj::[0NO^}@r2f?">
                                       <field name="Severity">info</field>
                                       <value name="TEXT">
                                         <shadow type="text" id="v3S]^xo$QRpmTi_m:MiD">
                                           <field name="TEXT">test</field>
                                         </shadow>
                                         <block type="get_attr" id="sch|Vdte#46P|$E0N){b">
                                           <value name="PATH">
                                             <shadow type="text" id="S6Fmb#3I5odaK!_L3/Xx">
                                               <field name="TEXT">tempf</field>
                                             </shadow>
                                           </value>
                                           <value name="OBJECT">
                                             <shadow type="get_object" id="Z[Q*J-EZZlJA:5Q36$$z">
                                               <field name="OID">Object ID</field>
                                             </shadow>
                                             <block type="variables_get" id="}pfM{4G@w.%+V=RxDl|%">
                                               <field name="VAR" id="8+=Mk?BD}YCcGl~4E)j|">Objekt</field>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                     </block>
                                   </next>
                                 </block>
                               </next>
                             </block>
                           </next>
                         </block>
                         <block type="convert_json2object" id="1-ME3y(y.YrZvl:v}Pb`" x="388" y="438"></block>
                        </xml>
                        

                        EDIT: Geht sogar noch einfacher - nochmals korrigiert.

                        https://try.jsonata.org/sn8GeyHWc

                        oder auf den Code von @fastfoot angewandt:

                        const txtorg = "PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60";
                        const obj = (await jsonataExpression(txtorg, '$split($,"&"){$substringBefore("="):$substringAfter("=")}'));
                        log(obj.tempf);
                        log(obj.dateutc);
                        log(obj.humidity);
                        

                        b1ce9d44-913d-4bd6-955d-31b8da5eaac8-image.png

                        Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.

                        haus-automatisierungH 1 Reply Last reply
                        2
                        • mickymM mickym

                          @hendrik87 sagte in Textvariablen mit & - wie trennen?:

                          PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60

                          Ich würde so was natürlich mit JSONATA in ein Objekt überführen, dann kann einzelne Werte ganz bequem selektieren:
                          9bf5b934-2697-48c1-bfc6-323ccb3732f3-image.png

                          Hier der JSONATA Ausdruck

                          $split($,"&"){$substringBefore("="):$substringAfter("=")}
                          

                          <xml xmlns="https://developers.google.com/blockly/xml">
                           <variables>
                             <variable id="hu+F[F+=/+n6(w#b!bkk">Text</variable>
                             <variable id="8+=Mk?BD}YCcGl~4E)j|">Objekt</variable>
                           </variables>
                           <block type="variables_set" id="^~Sv#fxrrEl3v%:$_j(K" x="-137" y="63">
                             <field name="VAR" id="hu+F[F+=/+n6(w#b!bkk">Text</field>
                             <value name="VALUE">
                               <block type="text" id="}KJz}$Rs!%XxMZl%j4_w">
                                 <field name="TEXT">PASSKEY=xxx&amp;stationtype=GW2000A_V3.2.2&amp;runtime=86732&amp;heap=82460&amp;dateutc=2025-04-19%2018%3A57%3A39&amp;tempinf=69.08&amp;humidityin=43&amp;baromrelin=29.740&amp;baromabsin=29.740&amp;tempf=46.40&amp;humidity=76&amp;vpd=0.076&amp;winddir=304&amp;windspeedmph=3.80&amp;windgustmph=7.38&amp;maxdailygust=13.65&amp;solarradiation=0.16&amp;uv=0&amp;rrain_piezo=0.000&amp;erain_piezo=0.000&amp;hrain_piezo=0.000&amp;drain_piezo=0.000&amp;wrain_piezo=0.409&amp;mrain_piezo=0.409&amp;yrain_piezo=0.409&amp;srain_piezo=0&amp;ws90cap_volt=5.2&amp;ws90_ver=133&amp;wh90batt=3.26&amp;freq=868M&amp;model=GW2000A&amp;interval=60</field>
                               </block>
                             </value>
                             <next>
                               <block type="variables_set" id="_D5~rAL,~%b==9Nf3*L`">
                                 <field name="VAR" id="8+=Mk?BD}YCcGl~4E)j|">Objekt</field>
                                 <value name="VALUE">
                                   <block type="convert_jsonata" id="u}[_Z`KWHAeHkdE@@V?=">
                                     <value name="EXPRESSION">
                                       <shadow type="text" id="eg-6.rV=oGTM`RArquVg">
                                         <field name="TEXT">$split($,"&amp;"){$substringBefore("="):$substringAfter("=")}</field>
                                       </shadow>
                                     </value>
                                     <value name="TARGET">
                                       <block type="variables_get" id="n+aI}jp_T]nxZ439rGaK">
                                         <field name="VAR" id="hu+F[F+=/+n6(w#b!bkk">Text</field>
                                       </block>
                                     </value>
                                   </block>
                                 </value>
                                 <next>
                                   <block type="debug" id="k08ZC410l/7`T|+g_+w@">
                                     <field name="Severity">info</field>
                                     <value name="TEXT">
                                       <shadow type="text" id=",T!NCf4e|u/ADp:g1bn[">
                                         <field name="TEXT">test</field>
                                       </shadow>
                                       <block type="variables_get" id="xX[*0A$F`nN{~,hNEQSb">
                                         <field name="VAR" id="8+=Mk?BD}YCcGl~4E)j|">Objekt</field>
                                       </block>
                                     </value>
                                     <next>
                                       <block type="debug" id="$ZA{KAj::[0NO^}@r2f?">
                                         <field name="Severity">info</field>
                                         <value name="TEXT">
                                           <shadow type="text" id="v3S]^xo$QRpmTi_m:MiD">
                                             <field name="TEXT">test</field>
                                           </shadow>
                                           <block type="get_attr" id="sch|Vdte#46P|$E0N){b">
                                             <value name="PATH">
                                               <shadow type="text" id="S6Fmb#3I5odaK!_L3/Xx">
                                                 <field name="TEXT">tempf</field>
                                               </shadow>
                                             </value>
                                             <value name="OBJECT">
                                               <shadow type="get_object" id="Z[Q*J-EZZlJA:5Q36$$z">
                                                 <field name="OID">Object ID</field>
                                               </shadow>
                                               <block type="variables_get" id="}pfM{4G@w.%+V=RxDl|%">
                                                 <field name="VAR" id="8+=Mk?BD}YCcGl~4E)j|">Objekt</field>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                       </block>
                                     </next>
                                   </block>
                                 </next>
                               </block>
                             </next>
                           </block>
                           <block type="convert_json2object" id="1-ME3y(y.YrZvl:v}Pb`" x="388" y="438"></block>
                          </xml>
                          

                          EDIT: Geht sogar noch einfacher - nochmals korrigiert.

                          https://try.jsonata.org/sn8GeyHWc

                          oder auf den Code von @fastfoot angewandt:

                          const txtorg = "PASSKEY=xxx&stationtype=GW2000A_V3.2.2&runtime=86732&heap=82460&dateutc=2025-04-19%2018%3A57%3A39&tempinf=69.08&humidityin=43&baromrelin=29.740&baromabsin=29.740&tempf=46.40&humidity=76&vpd=0.076&winddir=304&windspeedmph=3.80&windgustmph=7.38&maxdailygust=13.65&solarradiation=0.16&uv=0&rrain_piezo=0.000&erain_piezo=0.000&hrain_piezo=0.000&drain_piezo=0.000&wrain_piezo=0.409&mrain_piezo=0.409&yrain_piezo=0.409&srain_piezo=0&ws90cap_volt=5.2&ws90_ver=133&wh90batt=3.26&freq=868M&model=GW2000A&interval=60";
                          const obj = (await jsonataExpression(txtorg, '$split($,"&"){$substringBefore("="):$substringAfter("=")}'));
                          log(obj.tempf);
                          log(obj.dateutc);
                          log(obj.humidity);
                          

                          b1ce9d44-913d-4bd6-955d-31b8da5eaac8-image.png

                          haus-automatisierungH Online
                          haus-automatisierungH Online
                          haus-automatisierung
                          Developer Most Active
                          wrote on last edited by
                          #17

                          Geht es in diesem Thread darum, wie man es möglichst kompliziert löst? Dann entschuldigt meinen simplen Ansatz :)

                          🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                          🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                          📚 Meine inoffizielle ioBroker Dokumentation

                          mickymM 1 Reply Last reply
                          3
                          • haus-automatisierungH haus-automatisierung

                            Geht es in diesem Thread darum, wie man es möglichst kompliziert löst? Dann entschuldigt meinen simplen Ansatz :)

                            mickymM Offline
                            mickymM Offline
                            mickym
                            Most Active
                            wrote on last edited by
                            #18

                            @haus-automatisierung sagte in Textvariablen mit & - wie trennen?:

                            Geht es in diesem Thread darum, wie man es möglichst kompliziert löst? Dann entschuldigt meinen simplen Ansatz :)

                            Nein - aber man muss halt wieder eine Bibliothek installieren, während JSONATA halt schon an Board ist.

                            Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.

                            T 1 Reply Last reply
                            0
                            • mickymM mickym

                              @haus-automatisierung sagte in Textvariablen mit & - wie trennen?:

                              Geht es in diesem Thread darum, wie man es möglichst kompliziert löst? Dann entschuldigt meinen simplen Ansatz :)

                              Nein - aber man muss halt wieder eine Bibliothek installieren, während JSONATA halt schon an Board ist.

                              T Offline
                              T Offline
                              ticaki
                              wrote on last edited by
                              #19

                              @mickym

                              Alles was mit node: anfängt ist in nodejs integriert.

                              Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

                              Spenden

                              mickymM 1 Reply Last reply
                              1
                              • T ticaki

                                @mickym

                                Alles was mit node: anfängt ist in nodejs integriert.

                                mickymM Offline
                                mickymM Offline
                                mickym
                                Most Active
                                wrote on last edited by
                                #20

                                @ticaki sagte in Textvariablen mit & - wie trennen?:

                                @mickym

                                Alles was mit node: anfängt ist in nodejs integriert.

                                Ok - wusste ich nicht

                                • aber mein Code ist auch nicht länger. Aber egal - könnt ja meine Lösung wieder löschen.

                                Jeder Flow bzw. jedes Script, das ich hier poste implementiert jeder auf eigene Gefahr. Flows und Scripts können Fehler aufweisen und weder der Seitenbetreiber noch ich persönlich können hierfür haftbar gemacht werden. Das gleiche gilt für Empfehlungen aller Art.

                                T W 2 Replies Last reply
                                0
                                • mickymM mickym

                                  @ticaki sagte in Textvariablen mit & - wie trennen?:

                                  @mickym

                                  Alles was mit node: anfängt ist in nodejs integriert.

                                  Ok - wusste ich nicht

                                  • aber mein Code ist auch nicht länger. Aber egal - könnt ja meine Lösung wieder löschen.
                                  T Offline
                                  T Offline
                                  ticaki
                                  wrote on last edited by
                                  #21

                                  @mickym
                                  Ich habs dir nur mitgeteilt ohne wertung :)

                                  Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

                                  Spenden

                                  bahnuhrB 1 Reply Last reply
                                  2
                                  • T ticaki

                                    @mickym
                                    Ich habs dir nur mitgeteilt ohne wertung :)

                                    bahnuhrB Online
                                    bahnuhrB Online
                                    bahnuhr
                                    Forum Testing Most Active
                                    wrote on last edited by
                                    #22

                                    @ticaki
                                    @haus-automatisierung

                                    Gibts da irgendwo ne Beschreibung wie man dies anwendet und was damit möglich ist ?


                                    Wenn ich helfen konnte, dann Daumen hoch (Pfeil nach oben)!
                                    Danke.
                                    gute Forenbeiträge: https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge
                                    ScreenToGif :https://www.screentogif.com/downloads.html

                                    T 1 Reply Last reply
                                    0
                                    • bahnuhrB bahnuhr

                                      @ticaki
                                      @haus-automatisierung

                                      Gibts da irgendwo ne Beschreibung wie man dies anwendet und was damit möglich ist ?

                                      T Offline
                                      T Offline
                                      ticaki
                                      wrote on last edited by
                                      #23

                                      @bahnuhr

                                      Jo auf der nodejs/api/url seite :D

                                      https://nodejs.org/api/url.html

                                      Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

                                      Spenden

                                      HomoranH 1 Reply Last reply
                                      1
                                      • T ticaki

                                        @bahnuhr

                                        Jo auf der nodejs/api/url seite :D

                                        https://nodejs.org/api/url.html

                                        HomoranH Offline
                                        HomoranH Offline
                                        Homoran
                                        Global Moderator Administrators
                                        wrote on last edited by
                                        #24

                                        @ticaki node v23??

                                        kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                                        Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                                        der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                                        T 1 Reply Last reply
                                        0
                                        • HomoranH Offline
                                          HomoranH Offline
                                          Homoran
                                          Global Moderator Administrators
                                          wrote on last edited by
                                          #25

                                          Ich habe den Exkurs wegen der Darstellungsprobleme in code-tags bei eckigen Klammern ausgegliedert nach
                                          https://forum.iobroker.net/topic/80809/code-in-code-tags-unvollständig-bei-eckigen-klammern/1

                                          ich hoffe ich habe nicht zuviel Kontext zerstört

                                          kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                                          Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                                          der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                                          1 Reply Last reply
                                          2
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          288

                                          Online

                                          32.6k

                                          Users

                                          82.3k

                                          Topics

                                          1.3m

                                          Posts
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Home
                                          • Recent
                                          • Tags
                                          • Unread 0
                                          • Categories
                                          • Unreplied
                                          • Popular
                                          • GitHub
                                          • Docu
                                          • Hilfe