Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. mqtt JSON in Datenpunkt schreiben

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    mqtt JSON in Datenpunkt schreiben

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

      Hallo zusammen,

      Ich hatte lange ein Script im IoBroker laufen welches mir die Daten meines Lesekopfes in Datenpunkte geschrieben hat. Durch ein Update und die damit verbundenen Änderungen in der Bezeichnung werden die DP´s nun aber nicht mehr aktualisiert.

      Kann dort mal jemand drüber schauen? Bin nicht so beflügelt in Javascript.

      Danke im Voraus!2025-08-21 18_42_29-MQTT.fx - 1.7.1.png

      on('mqtt.0.tele.ISKRA_MT681_Grewe.SENSOR', function(dp) {
      
          let strom = JSON.parse(dp.state.val);
      
          if(strom['total_in']) {
      
              let val = strom['total_in'];
      
              setState('0_userdata.0.Stromzähler.Verbrauch_gesamt', val, true);
      
          } if(strom['total_out']) {
      
              let val = strom['total_out'];
      
              setState('0_userdata.0.Stromzähler.Einspeisung', val, true);
      
          } if(strom['power_curr']) {
      
              let val = strom['power_curr'];
      
              setState('0_userdata.0.Stromzähler.Verbrauch_aktuell', val, true);
      
          }
      
        });
      
      Asgothian 1 Reply Last reply Reply Quote 0
      • Asgothian
        Asgothian Developer @Feinfinger last edited by

        @feinfinger poste auch auch den Wert des DP Malala text - nicht als Screenshot - dann kann das auch wer lesen.

        A.

        F 1 Reply Last reply Reply Quote 0
        • F
          Feinfinger @Asgothian last edited by

          @asgothian ```
          tele/ISKRA_MT681_Grewe/SENSOR

          {"Time":"2025-08-21T19:07:32","":{"total_in":2562.26,"total_out":6391.15,"power_curr":7}}

          paul53 1 Reply Last reply Reply Quote 0
          • paul53
            paul53 @Feinfinger last edited by paul53

            @feinfinger

            Ändere Zeile 3:

                const strom = JSON.parse(dp.state.val)[''];
            
            bahnuhr F 2 Replies Last reply Reply Quote 1
            • bahnuhr
              bahnuhr Forum Testing Most Active @paul53 last edited by

              @paul53 sagte in mqtt JSON in Datenpunkt schreiben:

              ['']

              Das ist cool.
              Ich habs probiert und dann so gelöst.

              x = dp.state.val;
              x = x.split('","":'); x = x[1].substring(0,x[1].length-1)
              

              Hat dann auch funktioniert.

              @paul53
              Deine Lösung ist natürlich eleganter.

              1 Reply Last reply Reply Quote 0
              • F
                Feinfinger @paul53 last edited by

                @paul53

                Ich danke dir Paul 😉

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

                Support us

                ioBroker
                Community Adapters
                Donate

                520
                Online

                32.0k
                Users

                80.4k
                Topics

                1.3m
                Posts

                4
                6
                32
                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