Skip to content
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Logo
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Zeile aus JSON löschen

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.0k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    1.8k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    15
    1
    2.0k

Zeile aus JSON löschen

Scheduled Pinned Locked Moved Skripten / Logik
javascript
4 Posts 2 Posters 240 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michihorn
    wrote on last edited by
    #1

    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

    paul53P 1 Reply Last reply
    0
    • M michihorn

      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

      paul53P Offline
      paul53P Offline
      paul53
      wrote on last edited by
      #2

      @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);
      });
      

      Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
      Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

      M 1 Reply Last reply
      0
      • paul53P paul53

        @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 Offline
        M Offline
        michihorn
        wrote on last edited by
        #3

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

        paul53P 1 Reply Last reply
        0
        • M michihorn

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

          paul53P Offline
          paul53P Offline
          paul53
          wrote on last edited by paul53
          #4

          @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);
              }
          });
          

          Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
          Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          Support us

          ioBroker
          Community Adapters
          Donate

          648

          Online

          32.4k

          Users

          81.4k

          Topics

          1.3m

          Posts
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          ioBroker Community 2014-2025
          logo
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Unread 0
          • Categories
          • Unreplied
          • Popular
          • GitHub
          • Docu
          • Hilfe