Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Gelöst: JSON Tabelle tägliche Werte

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Gelöst: JSON Tabelle tägliche Werte

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

      Hallo ich möchte eine Json Tabelle erstellen, die täglich mit Datum abgespeichert wird.

      const idGET ="0_userdata.0.Garten.Rasen.StatusGET"
      const idSET ="0_userdata.0.Garten.Rasen.StatusSET"
      const idJSON = '0_userdata.0.Garten.Rasen.StatusJSON';
      
      
      var arr = JSON.parse(getState(idJSON).val);
          schedule("*/1 * * * *", function () {    //Testzwecke
      
              const obj = {
                  'Tag': formatDate(new Date(), 'DD.MM.YYYY'),
                  'Zähler SET': getState(idSET).val,
                  'ZählerGET': getState(idGET).val
              };
              arr.push(obj);
              setState(idJSON, JSON.stringify(arr), true);
              log("done")
          
      });
      

      Jede Zeile soll also, DATUM, GET,SET, enthalten.
      Kann mir jemand helfen?
      Michael

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

        @michihorn sagte: Kann mir jemand helfen?

        Was funktioniert nicht?
        Wie wurde der Datenpunkt '0_userdata.0.Garten.Rasen.StatusJSON' initialisiert?
        Falls er zu Beginn nur einen Leerstring enthält, dann ergänze

        const idGET ="0_userdata.0.Garten.Rasen.StatusGET"
        const idSET ="0_userdata.0.Garten.Rasen.StatusSET"
        const idJSON = '0_userdata.0.Garten.Rasen.StatusJSON';
         
        var arr = [];
        const json = getState(idJSON).val;
        if(json) arr = JSON.parse(json);
        
        M 2 Replies Last reply Reply Quote 1
        • M
          michihorn @paul53 last edited by michihorn

          @paul53 sagte in JSON Tabelle tägliche Werte:

          const idGET ="0_userdata.0.Garten.Rasen.StatusGET" const idSET ="0_userdata.0.Garten.Rasen.StatusSET" const idJSON = '0_userdata.0.Garten.Rasen.StatusJSON'; var arr = []; const json = getState(idJSON).val; if(json) arr = JSON.parse(json);

          Danke das war es schon.

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

            @paul53 Hallo Paul kann man evtl. die Differenz von einem Monat zum anderen Monat als 3. Spalte anfügen?
            HWR.png

            haus-automatisierung 1 Reply Last reply Reply Quote 0
            • haus-automatisierung
              haus-automatisierung Developer Most Active @michihorn last edited by

              @michihorn Dafür würde ich mir immer den letzten Wert holen, wenn eine neue Zeile geschrieben wird und die Differenz berechnen und speichern.

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

              Support us

              ioBroker
              Community Adapters
              Donate

              672
              Online

              31.7k
              Users

              79.6k
              Topics

              1.3m
              Posts

              javascript
              3
              5
              145
              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