Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Json parsen mit Javascript - Speicherort ändern

    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

    Json parsen mit Javascript - Speicherort ändern

    This topic has been deleted. Only users with topic management privileges can see it.
    • Christoph und Sara Wind
      Christoph und Sara Wind last edited by

      Hallo,

      ich muss gleich vorweg zugeben ich habe keine Ahnung von Javascript.
      Ich lese einen Smartzähler per Json aus. Der String wird mit einem Javascript in "seine Bestandteile " zerlegt, damit ich die Einzelnen Daten an die Datenbank bzw Grafana schicken kann
      Das ist der String den ich vom Zähler auslese: {"1.8.0":25683123,"2.8.0":0,"3.8.1":382320,"4.8.1":8439002,"1.7.0":314,"2.7.0":0,"3.7.0":0,"4.7.0":273,"1.128.0":0}

      Ich habe das Script im Internet gefunden - und es hat bis zu einem Update auch perfekt funktioniert.
      Ich vermute dass der Speicherort ( javascript.o.mqtt. ... ) gesperrt ist . Es wird einmal hingeschrieben, aber die Daten nicht aktualisiert.
      Meine Frage nun - kann man in dem Script den Speicherort ändern - oder was könnte sonst das Problem sein??

      Danke für eure Hilfe !!

      function iter(name, obj) {
         for(let i in obj) {
            if(typeof obj[i] == 'object') iter(name + '.' + i, obj[i]);
            else {
               log(name + '.' + i + ': ' + obj[i]);
               if(existsState(name + '.' + i)) setState(name + '.' + i, obj[i]);
               else createState(name + '.' + i, obj[i]); // type: "mixed"
            }
         }
      }
       
      function SendRequest(){
          var options = {
              url: 'http://192.168.0.155/rest'
          };
          request(options, function (error, response, body){
              if (!error) iter('mqtt.1.amis.out', JSON.parse(body));
              else console.error(error);
          });
      }
       
      schedule('*/5 * * * * *', SendRequest);
      
      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Christoph und Sara Wind last edited by

        @christoph-und-sara-wind

        Versuche es mal mit geänderter Zeile 17:

                if (!error) iter('0_userdata.0.amis.out', JSON.parse(body));
        
        Christoph und Sara Wind 1 Reply Last reply Reply Quote 0
        • Christoph und Sara Wind
          Christoph und Sara Wind @paul53 last edited by

          @paul53

          ja so einfach kanns gehen wenn man eine Ahnung davon hat .

          Danke dir - aber frag nicht wie lange ich schon davor sitzte... und wieviele Sachen ich da schon probiert habe ..

          LG Christoph

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

          Support us

          ioBroker
          Community Adapters
          Donate

          672
          Online

          31.8k
          Users

          80.0k
          Topics

          1.3m
          Posts

          2
          3
          128
          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