Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Zeile aus JSON löschen

    NEWS

    • Amazon Alexa - ioBroker Skill läuft aus ?

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    Zeile aus JSON löschen

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

      Hallo ich erstelle eine JSON Tabelle

      const idkommt = '0_userdata.0.Haus.AW.Noel_kommt';
      const idgeht = '0_userdata.0.Haus.AW.Noel_geht';
      const idJSON = '0_userdata.0.Haus.AW.Noel_JSON';
      
      
      const idTable = '0_userdata.0.Haus.AW.Noel_JSON'; // ID JSON-Tabelle
      const ids = ['0_userdata.0.Haus.AW.Noel_kommt','0_userdata.0.Haus.AW.Noel_geht']; 
       
      var table = [];
      for(let i = 0; i < ids.length; i++) {
          table[i] = {};
          table[i].Name = getObject(ids[i]).common.name;
          table[i].Wert = getState(ids[i]).val;
      }
      setState(idTable, JSON.stringify(table), true);
       
      on(ids, function(dp) {
          let idx = ids.indexOf(dp.id);
          table[idx].Wert = dp.state.val;
          setState(idTable, JSON.stringify(table), true);
      });
      

      json.png
      Wie kann ich nach einer bestimmten Zeit etwa bei Tageswechsel die erste Zeile löschen?
      Gruß
      Michael

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

        @michihorn sagte: bei Tageswechsel die erste Zeile löschen?

        const idTable = '0_userdata.0.Haus.AW.Noel_JSON'; // ID JSON-Tabelle
        
        schedule('59 23 * * *', function() {
            const arr = JSON.parse(getState(idTable).val);
            arr.shift();
            setState(idTable, JSON.stringify(arr), true);
        });
        
        M 1 Reply Last reply Reply Quote 0
        • M
          michihorn @paul53 last edited by

          @paul53 Danke Dir das klappt, kann ich auch löschen nach "_geht" oder "_kommt"?

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

            @michihorn sagte: auch löschen nach "_geht" oder "_kommt"?

            Den ersten Eintrag?

            const idTable = '0_userdata.0.Haus.AW.Noel_JSON'; // ID JSON-Tabelle
            
            schedule('59 23 * * *', function() {
                const arr = JSON.parse(getState(idTable).val);
                if(arr[0].includes('_geht')) {
                    arr.shift();
                    setState(idTable, JSON.stringify(arr), true);
                }
            });
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate

            553
            Online

            32.3k
            Users

            81.0k
            Topics

            1.3m
            Posts

            javascript
            2
            4
            93
            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