Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Brauche bitte Hilfe zu Json String

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Brauche bitte Hilfe zu Json String

    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      Yoshi @paul53 last edited by

      @paul53
      ok, das habe ich schon beim suchen irgendwo gelesen.
      Aber bei mir scheitert es gerade dabei, wo ich genau das eintragen muss ?

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

        @yoshi sagte: wo ich genau das eintragen muss ?

        Das ist ein Javascript. Der Datenpunkt mit dem JSON ist der Trigger und die neuen Datenpunkte vom Typ "Zahl" erstellt man vorher unter "0_userdata.0".

        1 Reply Last reply Reply Quote 0
        • M
          MCU @Yoshi last edited by MCU

          @yoshi So?
          e0b86331-3b93-4b03-b4e7-2d29f2341745-image.png

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

            @mcu sagte: So?
            Oder so (nur einige Datenpunkte):

            Bild_2022-06-01_161019032.png

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

              @paul53

              Hab nun diese Skript laufen.

              on(idJson, function(mqtt.0.Seplos.SEPLOS_dfc47.AllJsonData) {
              const obj = JSON.parse(dp.state.val);
              setState(idCellTemp2, obj.Temperatures.CellTemp2, true);
              });

              Bildschirmfoto 2022-06-01 um 16.55.35.png

              Und diesen Datenpunkt erstellt.

              Aber er kommt mit der Fehlermeldung: und schreibt nichts rein.
              javascript.0 (8856) script.js.Übergreifendes.Batterie compile failed:
              at script.js.Übergreifendes.Batterie:1

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

                @yoshi sagte: Hab nun diese Skript laufen.

                Korrektur:

                const idJson = 'mqtt.0.Seplos.SEPLOS_dfc47.AllJsonData';
                const path = '0_userdata.0.Batterie.'
                
                on(idJson, function(dp) {
                    const obj = JSON.parse(dp.state.val);
                    setState(path + 'Temperatures.CellTemp1', obj.Temperatures.CellTemp1, true);
                    setState(path + 'Temperatures.CellTemp2', obj.Temperatures.CellTemp2, true);
                    // usw.
                });
                
                Y 1 Reply Last reply Reply Quote 0
                • Y
                  Yoshi @paul53 last edited by

                  @paul53

                  Genial, funktioniert.
                  Muss ich für jeden Wert ein eigenes Skript bauen, oder kann ich das irgendwie fortlaufend machen ?

                  Vielen Dank für die schnelle Hilfe

                  paul53 2 Replies Last reply Reply Quote 0
                  • paul53
                    paul53 @Yoshi last edited by paul53

                    @yoshi sagte: kann ich das irgendwie fortlaufend machen ?

                    Fortlaufend ein setState() unter dem anderen (habe oben um "CellTemp1" ergänzt).

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

                      @paul53
                      VIELEN DANK!!

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

                        @yoshi
                        Für die 16 Zellenspannungen kann man eine Schleife verwenden:

                            for(let i = 1; i <= 16; i++) {
                                setState(path + 'CellVoltages.Cell' + i, obj.CellVoltages['Cell' + i], true);
                            }
                        
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        378
                        Online

                        31.8k
                        Users

                        80.0k
                        Topics

                        1.3m
                        Posts

                        3
                        12
                        490
                        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