Skip to content
  • Home
  • 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
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. ioBroker Allgemein
  4. ehemalige Historydaten finden

NEWS

  • Neuer ioBroker-Blog online: Monatsrückblick März/April 2026
    BluefoxB
    Bluefox
    5
    1
    115

  • Verwendung von KI bitte immer deutlich kennzeichnen
    HomoranH
    Homoran
    8
    1
    159

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    866

ehemalige Historydaten finden

Scheduled Pinned Locked Moved ioBroker Allgemein
148 Posts 7 Posters 9.4k Views 7 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 Matt77CHE

    @mcu

    Ich habe den
    History-Adapter V3.0.1
    Javascript-adapter V8.8.3

    und bekomme folgende Fehlermeldung im Javascript-Adapter :

    14.10.2024, 19:46:32.458	[error]: javascript.0 (436) script.js.common.Alte_history_dp_löschen: TypeError: Cannot read properties of undefined (reading 'length')
    14.10.2024, 19:46:32.459	[error]: javascript.0 (436)     at script.js.common.Alte_history_dp_löschen:238:18
    14.10.2024, 19:46:32.986	[error]: host.iobroker Caught by controller[0]:     at script.js.common.Alte_history_dp_löschen:239:18
    

    Habe ich da was falsch gemacht?

    • habe das Script im allgemeinen Ordner vom Javascript-Adapter in ein Java-script - Skript eingefügt; das Script ausgeführt und dann den Start-Button gedrückt.....
    M Online
    M Online
    MCU
    wrote on last edited by
    #123

    @matt77che Muss ich mir anschauen, komme aber erst Mittwoch dazu.

    NUC i7 64GB mit Proxmox ---- Jarvis Infos Aktualisierungen der Doku auf Instagram verfolgen -> mcuiobroker Instagram
    Wenn Euch mein Vorschlag geholfen hat, bitte rechts "^" klicken.

    1 Reply Last reply
    0
    • HomoranH Homoran

      @matt77che sagte in ehemalige Historydaten finden:

      und dann den Start-Button gedrückt..

      hast du die notwendigen Werte in die Datenpunkte eingetragen?

      M Offline
      M Offline
      Matt77CHE
      wrote on last edited by
      #124

      @homoran
      dirStart 0
      dirEnd 10 ?

      Ja

      HomoranH 1 Reply Last reply
      0
      • M Matt77CHE

        @homoran
        dirStart 0
        dirEnd 10 ?

        Ja

        HomoranH Do not disturb
        HomoranH Do not disturb
        Homoran
        Global Moderator Administrators
        wrote on last edited by
        #125

        @matt77che sagte in ehemalige Historydaten finden:

        @homoran
        dirStart 0
        dirEnd 10 ?

        Ja

        ich weiss nicht mehr alles, bitte zeigen!

        auch was in

        @matt77che sagte in ehemalige Historydaten finden:

        script.js.common.Alte_history_dp_löschen:239:18

        steht

        kein Support per PN! - Fragen im Forum stellen -
        Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
        Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
        der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

        M 2 Replies Last reply
        0
        • HomoranH Homoran

          @matt77che sagte in ehemalige Historydaten finden:

          @homoran
          dirStart 0
          dirEnd 10 ?

          Ja

          ich weiss nicht mehr alles, bitte zeigen!

          auch was in

          @matt77che sagte in ehemalige Historydaten finden:

          script.js.common.Alte_history_dp_löschen:239:18

          steht

          M Offline
          M Offline
          Matt77CHE
          wrote on last edited by
          #126

          @homoran

          // ********************************
          // findOldHistoryDPs v1.0.5
          // Copyright ©MCU
          // ********************************
          // v1.0.1 directDelete-> true  Möglichkeit die DatenDateien direkt löschen
          // v1.0.2 aliasId berücksichtigt bei enabledDPs
          // v1.0.3 zusätzliche Funktion listHistoryDPsWithaliasId('history.0');
          // v1.0.4 zusätzlich: fillAlias -> alle aktiven history-DPs mit alias in Array withAliasIdInEnabled
          //        fillEnabled_DPs -> nur die akitven History DPs in Array füllen -> enabled_DPs
          //        useAliasIdInEnabled -> true -> AliasId wird in enabled_DPs verwendet (was richtig ist, da die history-Werte mit alias geschrieben werden)
          // v1.0.5 zusätzliche Funktion: alias-Suche in allen ioBroker-DPs (unabhängig von history)
          
          let findOldDP                       = '0_userdata.0.history.findOldDPs';
          let findOldDPs_Old                  = findOldDP + '.old_DPs';
          let findOldDPs_Enabled              = findOldDP + '.enabled_DPs';
          let findOldDPs_InDB                 = findOldDP + '.inDB_DPS';
          let findOldDPs_BeginTS              = findOldDP + '.dirStart';
          let findOldDPs_EndTS                = findOldDP + '.dirEnd';
          let findOldDPs_Start                = findOldDP + '.start';
          let findOldDPs_DirectDel            = findOldDP + '.directDelete';
          let findOldDPs_fillEnabled          = findOldDP + '.fillEnabled_DPs';
          let findOldDPs_fillAlias            = findOldDP + '.fillWithAliasId';
          let findoldDPs_withAliasId          = findOldDP + '.withAliasId_DPs';
          let findOldDPs_useAliasInEnabled    = findOldDP + '.useAliasIdInEnabled';
          
          let findOldDPs_aliasDPs             = findOldDP + '.aliasDPs';
          let findOldDPs_aliasDPs_search      = findOldDP + '.aliasDPs_search'; 
          createStateAsync(findOldDPs_aliasDPs, {read: true, write: true, name: "ioBroker-DPs mit aliasId (unabhängig history)", type: "string", role: "text", def: JSON.stringify([]) });
          createStateAsync(findOldDPs_aliasDPs_search, {read: true, write: true, name: "Start Suche aliasIds in all ioBroker DPs", type: "boolean", role: "button", def: false });
          
          let dbNamespace = 'history.0';
          
          
          //createStateAsync(findOldDPs_Old, {read: true, write: true, name: "JSON für nicht genutzte DPs noch in DB", type: "string", role: "text", def: JSON.stringify([]) });
          createStateAsync(findOldDPs_Enabled, {read: true, write: true, name: "Aktive History-DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
          createStateAsync(findoldDPs_withAliasId, {read: true, write: true, name: "Aktive History-DPs mit aliasId", type: "string", role: "text", def: JSON.stringify([]) });
          //createStateAsync(findOldDPs_InDB, {read: true, write: true, name: "Genutzte DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
          createStateAsync(findOldDPs_BeginTS, {read: true, write: true, name: "Startverzeichnis", type: "number", role: "", def: 0 });
          createStateAsync(findOldDPs_EndTS, {read: true, write: true, name: "Endverzeichnis", type: "number", role: "", def: 10 }); //new Date().getTime()
          createStateAsync(findOldDPs_Start, {read: true, write: true, name: "Start Suche", type: "boolean", role: "button", def: false });
          createStateAsync(findOldDPs_fillEnabled, {read: true, write: true, name: "enabled_DPs suchen", type: "boolean", role: "button", def: false });
          createStateAsync(findOldDPs_fillAlias, {read: true, write: true, name: "withAliasId suchen", type: "boolean", role: "button", def: false });
          createStateAsync(findOldDPs_DirectDel, {read: true, write: true, name: "!!! Daten direkt löschen !!!", type: "boolean", role: "", def: false });
          createStateAsync(findOldDPs_useAliasInEnabled, {read: true, write: true, name: "AliasId in Enabled_DPs", type: "boolean", role: "", def: false });
          
          on({id: findOldDPs_Start, change: "any"}, function (obj) {
              let value = obj.state.val;
              if (value){
                  //setState(findOldDPs_EndTS,parseInt(new Date().getTime()),false);
                  getEnabledHistoryDPs(dbNamespace);
                  let fromDir = getState(findOldDPs_BeginTS).val;
                  let toDir = getState(findOldDPs_EndTS).val;
                  setTimeout(function(){
                      searchDir(fromDir,toDir);
                  },5000);
                  setStateDelayed(findOldDPs_Start,false,3000,false);
              }
          });
          
          on({id: findOldDPs_fillEnabled, change: "any"}, function (obj) {
              let value = obj.state.val;
              if (value){
                  getEnabledHistoryDPs(dbNamespace);
                  setStateDelayed(findOldDPs_fillEnabled,false,3000,false);
              }
          });
          
          on({id: findOldDPs_fillAlias, change: "any"}, function (obj) {
              let value = obj.state.val;
              if (value){
                  listHistoryDPsWithaliasId(dbNamespace);
                  setStateDelayed(findOldDPs_fillAlias,false,3000,false);
              }
          });
          
          on({id: findOldDPs_aliasDPs_search, change: "any"}, function (obj) {
              let value = obj.state.val;
              if (value){
                  findDPsWithAliasId(); 
                  setStateDelayed(findOldDPs_aliasDPs_search,false,3000,false);
              }
          });
          //listHistoryDPsWithaliasId('history.0');
          
          function listHistoryDPsWithaliasId(adp){
              let arr =[];
              sendTo(adp, 'getEnabledDPs', {}, function (result) {
                  let count = 0;
                  for ( let dp in result){
                      let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                      if (dpHistoryAlias != '' && dpHistoryAlias != undefined){
                          arr.push({'dpId':dp,'aliasId':dpHistoryAlias});
                          count++;
                      }
                  }
                  log('Anzahl der aktiv geloggten DPs mit aliasId: '+count);        
                  // setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                  //log(JSON.stringify(arr));
                  setState(findoldDPs_withAliasId,JSON.stringify(arr),false);
              });
          }
          
          //findDPsWithAliasId(); 
          
          function findDPsWithAliasId(){
              let allDPs = $('*');
              let arr = [];
              log('Anzahl der States: '+allDPs.length);
              for (let i=0;i<allDPs.length;i++){
                  if (existsObject(allDPs[i])){
                      if (getObject(allDPs[i]).common != undefined){
                          if (getObject(allDPs[i]).common.alias!= undefined){
                              let aliasId = getObject(allDPs[i]).common.alias.id;
                              if (aliasId != undefined){
                                  //log(allDPs[i] +' mit aliasId: '+aliasId);
                                  //break;
                                  arr.push({'id':allDPs[i],'aliasId':aliasId});
                              }
                          }
                      }
                  }
              }
              //log(arr);
              setState(findOldDPs_aliasDPs,JSON.stringify(arr),false);
          }
          
          
          /*
          setTimeout(function(){
              getEnabledHistoryDPs(db);
              getHistoryDPinDB(db);
          },3000);
          */
          
          // getEnabledHistoryDPs('history.0');
          
          function getEnabledHistoryDPs(adp){
              let arr =[];
              let useAliasIdInenabled = getState(findOldDPs_useAliasInEnabled).val;
              sendTo(adp, 'getEnabledDPs', {}, function (result) {
                  let count = 0;
                  for ( let dp in result){
                      let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                      if (dpHistoryAlias != '' && dpHistoryAlias != undefined && useAliasIdInenabled){
                          arr.push(dpHistoryAlias);
                      }else{
                          arr.push(dp);
                      }
                      count++;
                  }
                  log('Anzahl der aktiv geloggten DPs: '+count);        
                  setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
              });
          }
          
          // getHistoryDPinDB('history.0');
          
          function getHistoryDPinDB(db){
              //Die 50 zuletzt gespeicherte Ereignisse für alle IDs holen:
              let beginTS = getState(findOldDPs_BeginTS).val;
              if (beginTS == 0){
                  beginTS = parseInt(new Date().getTime()) - 30*24*60*60*1000;
              }
              let endTS = getState(findOldDPs_EndTS).val;
              if(endTS == 0){
                  endTS = parseInt(new Date().getTime());
              }
              sendTo(db, 'getHistory', {
                  id: '*',
                  options: {
                      begin: beginTS,
                      end:   endTS,
                      /* count:     50,*/
                      addId:     true
                  }
              }, function (result) {
                  let dpArr =[];
                  let count = 0;
                  for (var i = 0; i < result.result.length; i++) {
                      if (!isObjInArray(dpArr,result.result[i].id)){
                          dpArr.push(result.result[i].id);
                          count++;
                      }
                      //console.log(JSON.stringify(result.result[i]) + ' ' + new Date(result.result[i].ts).toISOString());
                  }
                  dpArr = dpArr.sort(function(a, b) {
                          return a > b;
                          });
                  setStateAsync(findOldDPs_InDB,JSON.stringify(dpArr),false);
                  //log('Anzahl der DPs in dem durchsuchten Bereich:'+count);
                  log(count+' unterschiedliche DPs in "inDB" von '+ formatDate(beginTS,'DD.MM.YYYY hh:mm:ss')+' - '+formatDate(endTS,'DD.MM.YYYY hh:mm:ss'));
                  //Vergleich der DPs
                  let nonActiveArr = [];
                  let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                  for (let i=0; i< dpArr.length;i++){
                      // dpArr[i]
                      let vorhanden = false;
                      for (let  j=0; j< activeDPs.length;j++ ){
                          if (dpArr[i] === activeDPs[j]){
                              vorhanden = true;
                              break; // vorhanden
                          }
                      }
                      if (!vorhanden){
                          // wird nicht mehr geloggt von active
                          nonActiveArr.push(dpArr[i]);
                      }
                  }
                  setState(findOldDPs_Old,JSON.stringify(nonActiveArr),false);
              });
          }
          
          
          
          
          function isObjInArray(arr,itemObj){
              if (arr.length>0){
                  for (let x=0;x<arr.length-1;x++){
                      if (JSON.stringify(arr[x]) === JSON.stringify(itemObj)){
                          return true;
                      }
                  }
                  return false;
              }else{
                  return false;
              }
          }
          
          // searchDir(0,10);
          
          function searchDir(fromDir, toDir){
              let fs = require('fs');
              let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
              let notActiveDPs = [];
              let sysAdaptDir = getObject('system.adapter.'+dbNamespace).native.storeDir;
              fs.readdir(sysAdaptDir , function (erro, file) {
                  log(file.length+' Verzeichnisse wurde(n) gelesen!');
                  log('fromDir und toDir dürfen nur im Bereich von 0 bis '+file.length +' sein! Bitte in 10er-Schritten verwenden!');
                  log('Es wurde ein Bereich von '+fromDir +' bis '+ toDir+' gewählt-> es dauert '+(toDir-fromDir)*2 +' Sekunden');
                  if (fromDir <0 || toDir >file.length){
          
                  }else{
                      for (let j=fromDir; j<toDir; j++){
                          //log(file[j]);
                          if (file[j].indexOf('.')>=0 && file[j].length >8){
          
                          }else{
                              fs.readdir(sysAdaptDir+'/'+file[j] , function (error, files) {
                                  log(files.length+' DPs im Verzeichnis: '+file[j]);
                                  for (let i=0;i< files.length; i++){
                                      let dpFiles = files[i].substring(8,files[i].length-5);
                                      if (isObjInArray(activeDPs,dpFiles)){
                                      }else{
                                          notActiveDPs.push({'id':dpFiles,'dir':file[j]});
                                      }
                                  }
                              });
                              //fs.unlinkSync('/opt/iobroker/iobroker-data/files/vis.0/'+jarvisDirName+'/'+files[i]+'/'+file[j]);
                          }
                      }
                      setTimeout(function(){
                          log('Nicht aktive DPs in den ausgewählten Verzeichnissen: '+notActiveDPs.length);
                          let olddir= '';
                          let directDelete = getState(findOldDPs_DirectDel).val;
                          for (let i=0;i<notActiveDPs.length;i++){
                              if (directDelete){
                                  // Direkt löschen
                                  fs.unlinkSync(sysAdaptDir+'/'+notActiveDPs[i].dir+'/history.'+notActiveDPs[i].id+'.json');
                              }
                              if (notActiveDPs[i].dir != olddir){
                                  if (directDelete){
                                      log('Im Verzeichnis: '+notActiveDPs[i].dir +' folgende Dateien sind gelöscht!:','warn');
                                  }else{
                                      log('Im Verzeichnis: '+notActiveDPs[i].dir +' können folgende Dateien gelöscht werden:','warn');
                                  }
                                  olddir = notActiveDPs[i].dir;
                              }
                              log(notActiveDPs[i].id);
                          }
                      },2000 * (toDir-fromDir)); // file.length
                  }
              });
              
          }
          
          HomoranH 1 Reply Last reply
          0
          • M Matt77CHE

            @homoran

            // ********************************
            // findOldHistoryDPs v1.0.5
            // Copyright ©MCU
            // ********************************
            // v1.0.1 directDelete-> true  Möglichkeit die DatenDateien direkt löschen
            // v1.0.2 aliasId berücksichtigt bei enabledDPs
            // v1.0.3 zusätzliche Funktion listHistoryDPsWithaliasId('history.0');
            // v1.0.4 zusätzlich: fillAlias -> alle aktiven history-DPs mit alias in Array withAliasIdInEnabled
            //        fillEnabled_DPs -> nur die akitven History DPs in Array füllen -> enabled_DPs
            //        useAliasIdInEnabled -> true -> AliasId wird in enabled_DPs verwendet (was richtig ist, da die history-Werte mit alias geschrieben werden)
            // v1.0.5 zusätzliche Funktion: alias-Suche in allen ioBroker-DPs (unabhängig von history)
            
            let findOldDP                       = '0_userdata.0.history.findOldDPs';
            let findOldDPs_Old                  = findOldDP + '.old_DPs';
            let findOldDPs_Enabled              = findOldDP + '.enabled_DPs';
            let findOldDPs_InDB                 = findOldDP + '.inDB_DPS';
            let findOldDPs_BeginTS              = findOldDP + '.dirStart';
            let findOldDPs_EndTS                = findOldDP + '.dirEnd';
            let findOldDPs_Start                = findOldDP + '.start';
            let findOldDPs_DirectDel            = findOldDP + '.directDelete';
            let findOldDPs_fillEnabled          = findOldDP + '.fillEnabled_DPs';
            let findOldDPs_fillAlias            = findOldDP + '.fillWithAliasId';
            let findoldDPs_withAliasId          = findOldDP + '.withAliasId_DPs';
            let findOldDPs_useAliasInEnabled    = findOldDP + '.useAliasIdInEnabled';
            
            let findOldDPs_aliasDPs             = findOldDP + '.aliasDPs';
            let findOldDPs_aliasDPs_search      = findOldDP + '.aliasDPs_search'; 
            createStateAsync(findOldDPs_aliasDPs, {read: true, write: true, name: "ioBroker-DPs mit aliasId (unabhängig history)", type: "string", role: "text", def: JSON.stringify([]) });
            createStateAsync(findOldDPs_aliasDPs_search, {read: true, write: true, name: "Start Suche aliasIds in all ioBroker DPs", type: "boolean", role: "button", def: false });
            
            let dbNamespace = 'history.0';
            
            
            //createStateAsync(findOldDPs_Old, {read: true, write: true, name: "JSON für nicht genutzte DPs noch in DB", type: "string", role: "text", def: JSON.stringify([]) });
            createStateAsync(findOldDPs_Enabled, {read: true, write: true, name: "Aktive History-DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
            createStateAsync(findoldDPs_withAliasId, {read: true, write: true, name: "Aktive History-DPs mit aliasId", type: "string", role: "text", def: JSON.stringify([]) });
            //createStateAsync(findOldDPs_InDB, {read: true, write: true, name: "Genutzte DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
            createStateAsync(findOldDPs_BeginTS, {read: true, write: true, name: "Startverzeichnis", type: "number", role: "", def: 0 });
            createStateAsync(findOldDPs_EndTS, {read: true, write: true, name: "Endverzeichnis", type: "number", role: "", def: 10 }); //new Date().getTime()
            createStateAsync(findOldDPs_Start, {read: true, write: true, name: "Start Suche", type: "boolean", role: "button", def: false });
            createStateAsync(findOldDPs_fillEnabled, {read: true, write: true, name: "enabled_DPs suchen", type: "boolean", role: "button", def: false });
            createStateAsync(findOldDPs_fillAlias, {read: true, write: true, name: "withAliasId suchen", type: "boolean", role: "button", def: false });
            createStateAsync(findOldDPs_DirectDel, {read: true, write: true, name: "!!! Daten direkt löschen !!!", type: "boolean", role: "", def: false });
            createStateAsync(findOldDPs_useAliasInEnabled, {read: true, write: true, name: "AliasId in Enabled_DPs", type: "boolean", role: "", def: false });
            
            on({id: findOldDPs_Start, change: "any"}, function (obj) {
                let value = obj.state.val;
                if (value){
                    //setState(findOldDPs_EndTS,parseInt(new Date().getTime()),false);
                    getEnabledHistoryDPs(dbNamespace);
                    let fromDir = getState(findOldDPs_BeginTS).val;
                    let toDir = getState(findOldDPs_EndTS).val;
                    setTimeout(function(){
                        searchDir(fromDir,toDir);
                    },5000);
                    setStateDelayed(findOldDPs_Start,false,3000,false);
                }
            });
            
            on({id: findOldDPs_fillEnabled, change: "any"}, function (obj) {
                let value = obj.state.val;
                if (value){
                    getEnabledHistoryDPs(dbNamespace);
                    setStateDelayed(findOldDPs_fillEnabled,false,3000,false);
                }
            });
            
            on({id: findOldDPs_fillAlias, change: "any"}, function (obj) {
                let value = obj.state.val;
                if (value){
                    listHistoryDPsWithaliasId(dbNamespace);
                    setStateDelayed(findOldDPs_fillAlias,false,3000,false);
                }
            });
            
            on({id: findOldDPs_aliasDPs_search, change: "any"}, function (obj) {
                let value = obj.state.val;
                if (value){
                    findDPsWithAliasId(); 
                    setStateDelayed(findOldDPs_aliasDPs_search,false,3000,false);
                }
            });
            //listHistoryDPsWithaliasId('history.0');
            
            function listHistoryDPsWithaliasId(adp){
                let arr =[];
                sendTo(adp, 'getEnabledDPs', {}, function (result) {
                    let count = 0;
                    for ( let dp in result){
                        let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                        if (dpHistoryAlias != '' && dpHistoryAlias != undefined){
                            arr.push({'dpId':dp,'aliasId':dpHistoryAlias});
                            count++;
                        }
                    }
                    log('Anzahl der aktiv geloggten DPs mit aliasId: '+count);        
                    // setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                    //log(JSON.stringify(arr));
                    setState(findoldDPs_withAliasId,JSON.stringify(arr),false);
                });
            }
            
            //findDPsWithAliasId(); 
            
            function findDPsWithAliasId(){
                let allDPs = $('*');
                let arr = [];
                log('Anzahl der States: '+allDPs.length);
                for (let i=0;i<allDPs.length;i++){
                    if (existsObject(allDPs[i])){
                        if (getObject(allDPs[i]).common != undefined){
                            if (getObject(allDPs[i]).common.alias!= undefined){
                                let aliasId = getObject(allDPs[i]).common.alias.id;
                                if (aliasId != undefined){
                                    //log(allDPs[i] +' mit aliasId: '+aliasId);
                                    //break;
                                    arr.push({'id':allDPs[i],'aliasId':aliasId});
                                }
                            }
                        }
                    }
                }
                //log(arr);
                setState(findOldDPs_aliasDPs,JSON.stringify(arr),false);
            }
            
            
            /*
            setTimeout(function(){
                getEnabledHistoryDPs(db);
                getHistoryDPinDB(db);
            },3000);
            */
            
            // getEnabledHistoryDPs('history.0');
            
            function getEnabledHistoryDPs(adp){
                let arr =[];
                let useAliasIdInenabled = getState(findOldDPs_useAliasInEnabled).val;
                sendTo(adp, 'getEnabledDPs', {}, function (result) {
                    let count = 0;
                    for ( let dp in result){
                        let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                        if (dpHistoryAlias != '' && dpHistoryAlias != undefined && useAliasIdInenabled){
                            arr.push(dpHistoryAlias);
                        }else{
                            arr.push(dp);
                        }
                        count++;
                    }
                    log('Anzahl der aktiv geloggten DPs: '+count);        
                    setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                });
            }
            
            // getHistoryDPinDB('history.0');
            
            function getHistoryDPinDB(db){
                //Die 50 zuletzt gespeicherte Ereignisse für alle IDs holen:
                let beginTS = getState(findOldDPs_BeginTS).val;
                if (beginTS == 0){
                    beginTS = parseInt(new Date().getTime()) - 30*24*60*60*1000;
                }
                let endTS = getState(findOldDPs_EndTS).val;
                if(endTS == 0){
                    endTS = parseInt(new Date().getTime());
                }
                sendTo(db, 'getHistory', {
                    id: '*',
                    options: {
                        begin: beginTS,
                        end:   endTS,
                        /* count:     50,*/
                        addId:     true
                    }
                }, function (result) {
                    let dpArr =[];
                    let count = 0;
                    for (var i = 0; i < result.result.length; i++) {
                        if (!isObjInArray(dpArr,result.result[i].id)){
                            dpArr.push(result.result[i].id);
                            count++;
                        }
                        //console.log(JSON.stringify(result.result[i]) + ' ' + new Date(result.result[i].ts).toISOString());
                    }
                    dpArr = dpArr.sort(function(a, b) {
                            return a > b;
                            });
                    setStateAsync(findOldDPs_InDB,JSON.stringify(dpArr),false);
                    //log('Anzahl der DPs in dem durchsuchten Bereich:'+count);
                    log(count+' unterschiedliche DPs in "inDB" von '+ formatDate(beginTS,'DD.MM.YYYY hh:mm:ss')+' - '+formatDate(endTS,'DD.MM.YYYY hh:mm:ss'));
                    //Vergleich der DPs
                    let nonActiveArr = [];
                    let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                    for (let i=0; i< dpArr.length;i++){
                        // dpArr[i]
                        let vorhanden = false;
                        for (let  j=0; j< activeDPs.length;j++ ){
                            if (dpArr[i] === activeDPs[j]){
                                vorhanden = true;
                                break; // vorhanden
                            }
                        }
                        if (!vorhanden){
                            // wird nicht mehr geloggt von active
                            nonActiveArr.push(dpArr[i]);
                        }
                    }
                    setState(findOldDPs_Old,JSON.stringify(nonActiveArr),false);
                });
            }
            
            
            
            
            function isObjInArray(arr,itemObj){
                if (arr.length>0){
                    for (let x=0;x<arr.length-1;x++){
                        if (JSON.stringify(arr[x]) === JSON.stringify(itemObj)){
                            return true;
                        }
                    }
                    return false;
                }else{
                    return false;
                }
            }
            
            // searchDir(0,10);
            
            function searchDir(fromDir, toDir){
                let fs = require('fs');
                let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                let notActiveDPs = [];
                let sysAdaptDir = getObject('system.adapter.'+dbNamespace).native.storeDir;
                fs.readdir(sysAdaptDir , function (erro, file) {
                    log(file.length+' Verzeichnisse wurde(n) gelesen!');
                    log('fromDir und toDir dürfen nur im Bereich von 0 bis '+file.length +' sein! Bitte in 10er-Schritten verwenden!');
                    log('Es wurde ein Bereich von '+fromDir +' bis '+ toDir+' gewählt-> es dauert '+(toDir-fromDir)*2 +' Sekunden');
                    if (fromDir <0 || toDir >file.length){
            
                    }else{
                        for (let j=fromDir; j<toDir; j++){
                            //log(file[j]);
                            if (file[j].indexOf('.')>=0 && file[j].length >8){
            
                            }else{
                                fs.readdir(sysAdaptDir+'/'+file[j] , function (error, files) {
                                    log(files.length+' DPs im Verzeichnis: '+file[j]);
                                    for (let i=0;i< files.length; i++){
                                        let dpFiles = files[i].substring(8,files[i].length-5);
                                        if (isObjInArray(activeDPs,dpFiles)){
                                        }else{
                                            notActiveDPs.push({'id':dpFiles,'dir':file[j]});
                                        }
                                    }
                                });
                                //fs.unlinkSync('/opt/iobroker/iobroker-data/files/vis.0/'+jarvisDirName+'/'+files[i]+'/'+file[j]);
                            }
                        }
                        setTimeout(function(){
                            log('Nicht aktive DPs in den ausgewählten Verzeichnissen: '+notActiveDPs.length);
                            let olddir= '';
                            let directDelete = getState(findOldDPs_DirectDel).val;
                            for (let i=0;i<notActiveDPs.length;i++){
                                if (directDelete){
                                    // Direkt löschen
                                    fs.unlinkSync(sysAdaptDir+'/'+notActiveDPs[i].dir+'/history.'+notActiveDPs[i].id+'.json');
                                }
                                if (notActiveDPs[i].dir != olddir){
                                    if (directDelete){
                                        log('Im Verzeichnis: '+notActiveDPs[i].dir +' folgende Dateien sind gelöscht!:','warn');
                                    }else{
                                        log('Im Verzeichnis: '+notActiveDPs[i].dir +' können folgende Dateien gelöscht werden:','warn');
                                    }
                                    olddir = notActiveDPs[i].dir;
                                }
                                log(notActiveDPs[i].id);
                            }
                        },2000 * (toDir-fromDir)); // file.length
                    }
                });
                
            }
            
            HomoranH Do not disturb
            HomoranH Do not disturb
            Homoran
            Global Moderator Administrators
            wrote on last edited by Homoran
            #127

            @matt77che da steht kein length an der genannten Stelle

            @matt77che sagte in ehemalige Historydaten finden:

            let fs = require('fs');

            kann es sein, dass du fs noch als npm modul hinzufügen musst?

            kein Support per PN! - Fragen im Forum stellen -
            Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
            Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
            der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

            M 2 Replies Last reply
            0
            • HomoranH Homoran

              @matt77che sagte in ehemalige Historydaten finden:

              @homoran
              dirStart 0
              dirEnd 10 ?

              Ja

              ich weiss nicht mehr alles, bitte zeigen!

              auch was in

              @matt77che sagte in ehemalige Historydaten finden:

              script.js.common.Alte_history_dp_löschen:239:18

              steht

              M Offline
              M Offline
              Matt77CHE
              wrote on last edited by
              #128

              @homoran

              Im To Do steht, die dirStart und dirEnd setzen und dann den Start Button drücken; mehr nicht

              1 Reply Last reply
              0
              • HomoranH Homoran

                @matt77che da steht kein length an der genannten Stelle

                @matt77che sagte in ehemalige Historydaten finden:

                let fs = require('fs');

                kann es sein, dass du fs noch als npm modul hinzufügen musst?

                M Offline
                M Offline
                Matt77CHE
                wrote on last edited by
                #129

                @homoran sagte in ehemalige Historydaten finden:

                @matt77che da steht kein length an der genannten Stelle

                @matt77che sagte in ehemalige Historydaten finden:

                let fs = require('fs');

                kann es sein, dass du fs noch als npm modul hinzufügen musst?

                habe ich gerade kontrolliert - ja dem ist so, das fehlt noch! - was muss ich da genau eintragen?

                HomoranH 1 Reply Last reply
                0
                • M Matt77CHE

                  @homoran sagte in ehemalige Historydaten finden:

                  @matt77che da steht kein length an der genannten Stelle

                  @matt77che sagte in ehemalige Historydaten finden:

                  let fs = require('fs');

                  kann es sein, dass du fs noch als npm modul hinzufügen musst?

                  habe ich gerade kontrolliert - ja dem ist so, das fehlt noch! - was muss ich da genau eintragen?

                  HomoranH Do not disturb
                  HomoranH Do not disturb
                  Homoran
                  Global Moderator Administrators
                  wrote on last edited by
                  #130

                  @matt77che sagte in ehemalige Historydaten finden:

                  was muss ich da genau eintragen?

                  fs <enter>

                  kein Support per PN! - Fragen im Forum stellen -
                  Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
                  Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
                  der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                  M 1 Reply Last reply
                  0
                  • HomoranH Homoran

                    @matt77che sagte in ehemalige Historydaten finden:

                    was muss ich da genau eintragen?

                    fs <enter>

                    M Offline
                    M Offline
                    Matt77CHE
                    wrote on last edited by
                    #131

                    @homoran
                    fs hinzugefügt, adapter neu gestartet;

                    14.10.2024, 20:41:24.871	[error]: javascript.0 (623441) script.js.common.Alte_history_dp_löschen: TypeError: Cannot read properties of undefined (reading 'length')
                    14.10.2024, 20:41:24.872	[error]: javascript.0 (623441)     at script.js.common.Alte_history_dp_löschen:238:18
                    14.10.2024, 20:41:25.376	[error]: host.iobroker Caught by controller[0]:     at script.js.common.Alte_history_dp_löschen:239:18
                    
                    1 Reply Last reply
                    0
                    • HomoranH Homoran

                      @matt77che da steht kein length an der genannten Stelle

                      @matt77che sagte in ehemalige Historydaten finden:

                      let fs = require('fs');

                      kann es sein, dass du fs noch als npm modul hinzufügen musst?

                      M Offline
                      M Offline
                      Matt77CHE
                      wrote on last edited by
                      #132

                      @homoran sagte in ehemalige Historydaten finden:

                      @matt77che da steht kein length an der genannten Stelle

                      Das habe ich auch festgestellt. Die Angegebenen falschen Zeilen stimmen nicht überein

                      HomoranH 1 Reply Last reply
                      0
                      • M Matt77CHE

                        @homoran sagte in ehemalige Historydaten finden:

                        @matt77che da steht kein length an der genannten Stelle

                        Das habe ich auch festgestellt. Die Angegebenen falschen Zeilen stimmen nicht überein

                        HomoranH Do not disturb
                        HomoranH Do not disturb
                        Homoran
                        Global Moderator Administrators
                        wrote on last edited by
                        #133

                        @matt77che hast du Scripte in global?

                        kein Support per PN! - Fragen im Forum stellen -
                        Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
                        Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
                        der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                        M 1 Reply Last reply
                        0
                        • HomoranH Homoran

                          @matt77che hast du Scripte in global?

                          M Offline
                          M Offline
                          Matt77CHE
                          wrote on last edited by
                          #134

                          @homoran

                          nein, der Ordner Global ist leer

                          HomoranH 1 Reply Last reply
                          0
                          • M Matt77CHE

                            @homoran

                            nein, der Ordner Global ist leer

                            HomoranH Do not disturb
                            HomoranH Do not disturb
                            Homoran
                            Global Moderator Administrators
                            wrote on last edited by
                            #135

                            @matt77che sind die zeilennummern hier im Post denn identisch mit denen von deinem Script?

                            kein Support per PN! - Fragen im Forum stellen -
                            Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
                            Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
                            der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                            M 1 Reply Last reply
                            0
                            • HomoranH Homoran

                              @matt77che sind die zeilennummern hier im Post denn identisch mit denen von deinem Script?

                              M Offline
                              M Offline
                              Matt77CHE
                              wrote on last edited by
                              #136

                              @homoran

                              Ja - Also im Script stimmt es auch nicht überein

                              HomoranH M 2 Replies Last reply
                              0
                              • M Matt77CHE

                                @homoran

                                Ja - Also im Script stimmt es auch nicht überein

                                HomoranH Do not disturb
                                HomoranH Do not disturb
                                Homoran
                                Global Moderator Administrators
                                wrote on last edited by
                                #137

                                @matt77che sagte in ehemalige Historydaten finden:

                                @homoran

                                Ja - Also im Script stimmt es auch nicht überein

                                dann zeig doch bitte die Zeilen deines Skripts (+/- 3) die angemeckert werden

                                kein Support per PN! - Fragen im Forum stellen -
                                Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
                                Das Forum freut sich über eine Spende. Benutzt dazu den Spendenbutton oben rechts. Danke!
                                der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                                1 Reply Last reply
                                0
                                • M Matt77CHE

                                  @homoran

                                  Ja - Also im Script stimmt es auch nicht überein

                                  M Online
                                  M Online
                                  MCU
                                  wrote on last edited by MCU
                                  #138

                                  @matt77che Hab es gerade mal probiert und es läuft ohne Probleme.
                                  Zeig mal bitte die History-Einstellungen.
                                  Auch mit
                                  History-Adapter V3.0.1
                                  Javascript-Adapter V8.8.3

                                  Es gibt in der 237 ein file.length
                                  10c211ff-67a2-4639-857b-88ae6f4aa264-image.png

                                  Verwendest du eine andere History-Instanz?
                                  51590510-401e-4733-844d-dbd1e0789b10-image.png

                                  NEUE VERSION v1.0.6 reingestellt -> automatische Suche der History-Instanzen.

                                  NUC i7 64GB mit Proxmox ---- Jarvis Infos Aktualisierungen der Doku auf Instagram verfolgen -> mcuiobroker Instagram
                                  Wenn Euch mein Vorschlag geholfen hat, bitte rechts "^" klicken.

                                  1 Reply Last reply
                                  0
                                  • M Offline
                                    M Offline
                                    Matt77CHE
                                    wrote on last edited by
                                    #139

                                    Ja, ich habe zwei instanzen; history.0 und eine history.1

                                    Also ich habe mir die v1.0.6 gezogen und es noch einmal versucht:
                                    Fehlermeldung:

                                    16.10.2024, 17:36:27.155	[error]: javascript.0 (1767186) script.js.common.Alte_history_dp_löschen: Fehler beim Lesen des Verzeichnisses: Error: ENOENT: no such file or directory, scandir ''
                                    
                                    M 1 Reply Last reply
                                    0
                                    • M Matt77CHE

                                      Ja, ich habe zwei instanzen; history.0 und eine history.1

                                      Also ich habe mir die v1.0.6 gezogen und es noch einmal versucht:
                                      Fehlermeldung:

                                      16.10.2024, 17:36:27.155	[error]: javascript.0 (1767186) script.js.common.Alte_history_dp_löschen: Fehler beim Lesen des Verzeichnisses: Error: ENOENT: no such file or directory, scandir ''
                                      
                                      M Online
                                      M Online
                                      MCU
                                      wrote on last edited by
                                      #140

                                      @matt77che Was steht im Log?

                                      Ablage für History
                                      

                                      NUC i7 64GB mit Proxmox ---- Jarvis Infos Aktualisierungen der Doku auf Instagram verfolgen -> mcuiobroker Instagram
                                      Wenn Euch mein Vorschlag geholfen hat, bitte rechts "^" klicken.

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        Matt77CHE
                                        wrote on last edited by
                                        #141

                                        Im >Script zeigt es mit bei den Zeilen
                                        148
                                        214
                                        218
                                        238
                                        einen Fehler an

                                        // ********************************
                                        // findOldHistoryDPs v1.0.6
                                        // Copyright ©MCU
                                        // ********************************
                                        // v1.0.1 directDelete-> true  Möglichkeit die DatenDateien direkt löschen
                                        // v1.0.2 aliasId berücksichtigt bei enabledDPs
                                        // v1.0.3 zusätzliche Funktion listHistoryDPsWithaliasId('history.0');
                                        // v1.0.4 zusätzlich: fillAlias -> alle aktiven history-DPs mit alias in Array withAliasIdInEnabled
                                        //        fillEnabled_DPs -> nur die akitven History DPs in Array füllen -> enabled_DPs
                                        //        useAliasIdInEnabled -> true -> AliasId wird in enabled_DPs verwendet (was richtig ist, da die history-Werte mit alias geschrieben werden)
                                        // v1.0.5 zusätzliche Funktion: alias-Suche in allen ioBroker-DPs (unabhängig von history)
                                        // v1.0.6 error-Handling bei searchDir(),activeHistory, DP-Auswahl History
                                        
                                        
                                        let findOldDP                       = '0_userdata.0.history.findOldDPs';
                                        let findOldDPs_Old                  = findOldDP + '.old_DPs';
                                        let findOldDPs_Enabled              = findOldDP + '.enabled_DPs';
                                        let findOldDPs_InDB                 = findOldDP + '.inDB_DPS';
                                        let findOldDPs_BeginTS              = findOldDP + '.dirStart';
                                        let findOldDPs_EndTS                = findOldDP + '.dirEnd';
                                        let findOldDPs_Start                = findOldDP + '.start';
                                        let findOldDPs_DirectDel            = findOldDP + '.directDelete';
                                        let findOldDPs_fillEnabled          = findOldDP + '.fillEnabled_DPs';
                                        let findOldDPs_fillAlias            = findOldDP + '.fillWithAliasId';
                                        let findoldDPs_withAliasId          = findOldDP + '.withAliasId_DPs';
                                        let findOldDPs_useAliasInEnabled    = findOldDP + '.useAliasIdInEnabled';
                                        let activeHistoryDP                 = findOldDP + '.activeHistory';
                                        let findOldDPs_aliasDPs             = findOldDP + '.aliasDPs';
                                        let findOldDPs_aliasDPs_search      = findOldDP + '.aliasDPs_search'; 
                                        createStateAsync(findOldDPs_aliasDPs, {read: true, write: true, name: "ioBroker-DPs mit aliasId (unabhängig history)", type: "string", role: "text", def: JSON.stringify([]) });
                                        createStateAsync(findOldDPs_aliasDPs_search, {read: true, write: true, name: "Start Suche aliasIds in all ioBroker DPs", type: "boolean", role: "button", def: false });
                                        
                                        let dbNamespace = 'history.0';
                                        
                                        
                                        //createStateAsync(findOldDPs_Old, {read: true, write: true, name: "JSON für nicht genutzte DPs noch in DB", type: "string", role: "text", def: JSON.stringify([]) });
                                        createStateAsync(findOldDPs_Enabled, {read: true, write: true, name: "Aktive History-DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
                                        createStateAsync(findoldDPs_withAliasId, {read: true, write: true, name: "Aktive History-DPs mit aliasId", type: "string", role: "text", def: JSON.stringify([]) });
                                        //createStateAsync(findOldDPs_InDB, {read: true, write: true, name: "Genutzte DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
                                        createStateAsync(findOldDPs_BeginTS, {read: true, write: true, name: "Startverzeichnis", type: "number", role: "", def: 0 });
                                        createStateAsync(findOldDPs_EndTS, {read: true, write: true, name: "Endverzeichnis", type: "number", role: "", def: 10 }); //new Date().getTime()
                                        createStateAsync(findOldDPs_Start, {read: true, write: true, name: "Start Suche", type: "boolean", role: "button", def: false });
                                        createStateAsync(findOldDPs_fillEnabled, {read: true, write: true, name: "enabled_DPs suchen", type: "boolean", role: "button", def: false });
                                        createStateAsync(findOldDPs_fillAlias, {read: true, write: true, name: "withAliasId suchen", type: "boolean", role: "button", def: false });
                                        createStateAsync(findOldDPs_DirectDel, {read: true, write: true, name: "!!! Daten direkt löschen !!!", type: "boolean", role: "", def: false });
                                        createStateAsync(findOldDPs_useAliasInEnabled, {read: true, write: true, name: "AliasId in Enabled_DPs", type: "boolean", role: "", def: false });
                                        
                                        
                                        setTimeout(function(){
                                            findHistoryInstance()
                                        },3000)
                                        
                                        
                                        
                                        on({id: findOldDPs_Start, change: "any"}, function (obj) {
                                            let value = obj.state.val;
                                            if (value){
                                                //setState(findOldDPs_EndTS,parseInt(new Date().getTime()),false);
                                                let dbNamespace = getState(activeHistoryDP).val
                                                if(dbNamespace !=''){
                                                    getEnabledHistoryDPs(dbNamespace);
                                                    let fromDir = getState(findOldDPs_BeginTS).val;
                                                    let toDir = getState(findOldDPs_EndTS).val;
                                                    setTimeout(function(){
                                                        searchDir(fromDir,toDir);
                                                    },5000);
                                                }else{
                                                    console.warn('Es wurde keine History-Instanz ausgewählt!')
                                                }
                                                setStateDelayed(findOldDPs_Start,false,3000,false);
                                            }
                                        });
                                        
                                        on({id: findOldDPs_fillEnabled, change: "any"}, function (obj) {
                                            let value = obj.state.val;
                                            if (value){
                                                let dbNamespace = getState(activeHistoryDP).val
                                                if(dbNamespace !=''){
                                                    getEnabledHistoryDPs(dbNamespace);
                                                }else{
                                                    console.warn('Es wurde keine History-Instanz ausgewählt!')
                                                }
                                                setStateDelayed(findOldDPs_fillEnabled,false,3000,false);
                                            }
                                        });
                                        
                                        on({id: findOldDPs_fillAlias, change: "any"}, function (obj) {
                                            let value = obj.state.val;
                                            if (value){
                                                let dbNamespace = getState(activeHistoryDP).val
                                                if(dbNamespace !=''){
                                                    listHistoryDPsWithaliasId(dbNamespace);
                                                }else{
                                                    console.warn('Es wurde keine History-Instanz ausgewählt!')
                                                }
                                                setStateDelayed(findOldDPs_fillAlias,false,3000,false);
                                            }
                                        });
                                        
                                        on({id: findOldDPs_aliasDPs_search, change: "any"}, function (obj) {
                                            let value = obj.state.val;
                                            if (value){
                                                findDPsWithAliasId(); 
                                                setStateDelayed(findOldDPs_aliasDPs_search,false,3000,false);
                                            }
                                        });
                                        //listHistoryDPsWithaliasId('history.0');
                                        
                                        function listHistoryDPsWithaliasId(adp){
                                            let arr =[];
                                            sendTo(adp, 'getEnabledDPs', {}, function (result) {
                                                let count = 0;
                                                for ( let dp in result){
                                                    let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                                                    if (dpHistoryAlias != '' && dpHistoryAlias != undefined){
                                                        arr.push({'dpId':dp,'aliasId':dpHistoryAlias});
                                                        count++;
                                                    }
                                                }
                                                log('Anzahl der aktiv geloggten DPs mit aliasId: '+count);        
                                                // setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                                                //log(JSON.stringify(arr));
                                                setState(findoldDPs_withAliasId,JSON.stringify(arr),false);
                                            });
                                        }
                                        
                                        
                                        
                                        
                                        function findHistoryInstance(){
                                            let historyDPs = $('system.adapter.history.*.alive')
                                            let arr = []
                                            for(let i=0;i< historyDPs.length;i++){
                                                let instance = historyDPs[i].split('.')[3]
                                                arr.push(instance)
                                                //console.log(historyDPs[i])
                                            }
                                            console.log('Gefundene History Instanzen: '+arr)
                                            let obj = {'':'History auswählen'}
                                            for (let i=0;i<arr.length;i++){
                                                obj['history.'+arr[i]] = 'history.'+arr[i]
                                            }
                                            // console.log(obj)
                                            let firstHistory = 'history.'+arr[0]
                                            
                                            if(existsState(activeHistoryDP)){
                                                let histObj = getObject(activeHistoryDP)
                                                histObj.common.states = obj
                                                setObject(activeHistoryDP,histObj)
                                            }else{
                                                createStateAsync(activeHistoryDP, {read: true, write: true, name: "Auswahl aktive History", type: "string", role: "", def: firstHistory, states: JSON.stringify(obj) });
                                            }
                                        }
                                        
                                        //findDPsWithAliasId(); 
                                        
                                        function findDPsWithAliasId(){
                                            let allDPs = $('*');
                                            let arr = [];
                                            log('Anzahl der States: '+allDPs.length);
                                            for (let i=0;i<allDPs.length;i++){
                                                if (existsObject(allDPs[i])){
                                                    if (getObject(allDPs[i]).common != undefined){
                                                        if (getObject(allDPs[i]).common.alias!= undefined){
                                                            let aliasId = getObject(allDPs[i]).common.alias.id;
                                                            if (aliasId != undefined){
                                                                //log(allDPs[i] +' mit aliasId: '+aliasId);
                                                                //break;
                                                                arr.push({'id':allDPs[i],'aliasId':aliasId});
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            //log(arr);
                                            setState(findOldDPs_aliasDPs,JSON.stringify(arr),false);
                                        }
                                        
                                        
                                        /*
                                        setTimeout(function(){
                                            getEnabledHistoryDPs(db);
                                            getHistoryDPinDB(db);
                                        },3000);
                                        */
                                        
                                        // getEnabledHistoryDPs('history.0');
                                        
                                        function getEnabledHistoryDPs(adp){
                                            let arr =[];
                                            let useAliasIdInenabled = getState(findOldDPs_useAliasInEnabled).val;
                                            sendTo(adp, 'getEnabledDPs', {}, function (result) {
                                                let count = 0;
                                                for ( let dp in result){
                                                    let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                                                    if (dpHistoryAlias != '' && dpHistoryAlias != undefined && useAliasIdInenabled){
                                                        arr.push(dpHistoryAlias);
                                                    }else{
                                                        arr.push(dp);
                                                    }
                                                    count++;
                                                }
                                                log('Anzahl der aktiv geloggten DPs: '+count);        
                                                setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                                            });
                                        }
                                        
                                        // getHistoryDPinDB('history.0');
                                        
                                        function getHistoryDPinDB(db){
                                            //Die 50 zuletzt gespeicherte Ereignisse für alle IDs holen:
                                            let beginTS = getState(findOldDPs_BeginTS).val;
                                            if (beginTS == 0){
                                                beginTS = parseInt(new Date().getTime()) - 30*24*60*60*1000;
                                            }
                                            let endTS = getState(findOldDPs_EndTS).val;
                                            if(endTS == 0){
                                                endTS = parseInt(new Date().getTime());
                                            }
                                            sendTo(db, 'getHistory', {
                                                id: '*',
                                                options: {
                                                    begin: beginTS,
                                                    end:   endTS,
                                                    /* count:     50,*/
                                                    addId:     true
                                                }
                                            }, function (result) {
                                                let dpArr =[];
                                                let count = 0;
                                                for (var i = 0; i < result.result.length; i++) {
                                                    if (!isObjInArray(dpArr,result.result[i].id)){
                                                        dpArr.push(result.result[i].id);
                                                        count++;
                                                    }
                                                    //console.log(JSON.stringify(result.result[i]) + ' ' + new Date(result.result[i].ts).toISOString());
                                                }
                                                dpArr = dpArr.sort(function(a, b) {
                                                        return a > b;
                                                        });
                                                setStateAsync(findOldDPs_InDB,JSON.stringify(dpArr),false);
                                                //log('Anzahl der DPs in dem durchsuchten Bereich:'+count);
                                                log(count+' unterschiedliche DPs in "inDB" von '+ formatDate(beginTS,'DD.MM.YYYY hh:mm:ss')+' - '+formatDate(endTS,'DD.MM.YYYY hh:mm:ss'));
                                                //Vergleich der DPs
                                                let nonActiveArr = [];
                                                let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                                                for (let i=0; i< dpArr.length;i++){
                                                    // dpArr[i]
                                                    let vorhanden = false;
                                                    for (let  j=0; j< activeDPs.length;j++ ){
                                                        if (dpArr[i] === activeDPs[j]){
                                                            vorhanden = true;
                                                            break; // vorhanden
                                                        }
                                                    }
                                                    if (!vorhanden){
                                                        // wird nicht mehr geloggt von active
                                                        nonActiveArr.push(dpArr[i]);
                                                    }
                                                }
                                                setState(findOldDPs_Old,JSON.stringify(nonActiveArr),false);
                                            });
                                        }
                                        
                                        
                                        
                                        
                                        function isObjInArray(arr,itemObj){
                                            if (arr.length>0){
                                                for (let x=0;x<arr.length-1;x++){
                                                    if (JSON.stringify(arr[x]) === JSON.stringify(itemObj)){
                                                        return true;
                                                    }
                                                }
                                                return false;
                                            }else{
                                                return false;
                                            }
                                        }
                                        
                                        // searchDir(0,10);
                                        
                                        function searchDir(fromDir, toDir){
                                            let fs = require('fs');
                                            let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                                            let notActiveDPs = [];
                                            let dbNamespace = getState(activeHistoryDP).val
                                            if(dbNamespace !=''){
                                                let sysAdaptDir = getObject('system.adapter.'+dbNamespace).native.storeDir;
                                                console.warn('Ablage für History: '+dbNamespace+' im Verzeichnis: '+sysAdaptDir)
                                                fs.readdir(sysAdaptDir , function (erro, file) {
                                                    if (erro) {
                                                        log('Fehler beim Lesen des Verzeichnisses: ' + erro, 'error');
                                                        return;
                                                    }
                                                    log(file.length+' Verzeichnisse wurde(n) gelesen!');
                                                    log('fromDir und toDir dürfen nur im Bereich von 0 bis '+file.length +' sein! Bitte in 10er-Schritten verwenden!');
                                                    log('Es wurde ein Bereich von '+fromDir +' bis '+ toDir+' gewählt-> es dauert '+(toDir-fromDir)*2 +' Sekunden');
                                                    if (fromDir <0 || toDir >file.length){
                                        
                                                    }else{
                                                        for (let j=fromDir; j<toDir; j++){
                                                            //log(file[j]);
                                                            if (file[j].indexOf('.')>=0 && file[j].length >8){
                                        
                                                            }else{
                                                                fs.readdir(sysAdaptDir+'/'+file[j] , function (error, files) {
                                                                    log(files.length+' DPs im Verzeichnis: '+file[j]);
                                                                    for (let i=0;i< files.length; i++){
                                                                        let dpFiles = files[i].substring(8,files[i].length-5);
                                                                        if (isObjInArray(activeDPs,dpFiles)){
                                                                        }else{
                                                                            notActiveDPs.push({'id':dpFiles,'dir':file[j]});
                                                                        }
                                                                    }
                                                                });
                                                                //fs.unlinkSync('/opt/iobroker/iobroker-data/files/vis.0/'+jarvisDirName+'/'+files[i]+'/'+file[j]);
                                                            }
                                                        }
                                                        setTimeout(function(){
                                                            log('Nicht aktive DPs in den ausgewählten Verzeichnissen: '+notActiveDPs.length);
                                                            let olddir= '';
                                                            let directDelete = getState(findOldDPs_DirectDel).val;
                                                            for (let i=0;i<notActiveDPs.length;i++){
                                                                if (directDelete){
                                                                    // Direkt löschen
                                                                    fs.unlinkSync(sysAdaptDir+'/'+notActiveDPs[i].dir+'/history.'+notActiveDPs[i].id+'.json');
                                                                }
                                                                if (notActiveDPs[i].dir != olddir){
                                                                    if (directDelete){
                                                                        log('Im Verzeichnis: '+notActiveDPs[i].dir +' folgende Dateien sind gelöscht!:','warn');
                                                                    }else{
                                                                        log('Im Verzeichnis: '+notActiveDPs[i].dir +' können folgende Dateien gelöscht werden:','warn');
                                                                    }
                                                                    olddir = notActiveDPs[i].dir;
                                                                }
                                                                log(notActiveDPs[i].id);
                                                            }
                                                        },2000 * (toDir-fromDir)); // file.length
                                                    }
                                                });
                                            }else{
                                                console.warn('Es wurde keine History-Instanz ausgewählt!')
                                            }
                                        }
                                        
                                        M HomoranH 3 Replies Last reply
                                        0
                                        • M Matt77CHE

                                          Im >Script zeigt es mit bei den Zeilen
                                          148
                                          214
                                          218
                                          238
                                          einen Fehler an

                                          // ********************************
                                          // findOldHistoryDPs v1.0.6
                                          // Copyright ©MCU
                                          // ********************************
                                          // v1.0.1 directDelete-> true  Möglichkeit die DatenDateien direkt löschen
                                          // v1.0.2 aliasId berücksichtigt bei enabledDPs
                                          // v1.0.3 zusätzliche Funktion listHistoryDPsWithaliasId('history.0');
                                          // v1.0.4 zusätzlich: fillAlias -> alle aktiven history-DPs mit alias in Array withAliasIdInEnabled
                                          //        fillEnabled_DPs -> nur die akitven History DPs in Array füllen -> enabled_DPs
                                          //        useAliasIdInEnabled -> true -> AliasId wird in enabled_DPs verwendet (was richtig ist, da die history-Werte mit alias geschrieben werden)
                                          // v1.0.5 zusätzliche Funktion: alias-Suche in allen ioBroker-DPs (unabhängig von history)
                                          // v1.0.6 error-Handling bei searchDir(),activeHistory, DP-Auswahl History
                                          
                                          
                                          let findOldDP                       = '0_userdata.0.history.findOldDPs';
                                          let findOldDPs_Old                  = findOldDP + '.old_DPs';
                                          let findOldDPs_Enabled              = findOldDP + '.enabled_DPs';
                                          let findOldDPs_InDB                 = findOldDP + '.inDB_DPS';
                                          let findOldDPs_BeginTS              = findOldDP + '.dirStart';
                                          let findOldDPs_EndTS                = findOldDP + '.dirEnd';
                                          let findOldDPs_Start                = findOldDP + '.start';
                                          let findOldDPs_DirectDel            = findOldDP + '.directDelete';
                                          let findOldDPs_fillEnabled          = findOldDP + '.fillEnabled_DPs';
                                          let findOldDPs_fillAlias            = findOldDP + '.fillWithAliasId';
                                          let findoldDPs_withAliasId          = findOldDP + '.withAliasId_DPs';
                                          let findOldDPs_useAliasInEnabled    = findOldDP + '.useAliasIdInEnabled';
                                          let activeHistoryDP                 = findOldDP + '.activeHistory';
                                          let findOldDPs_aliasDPs             = findOldDP + '.aliasDPs';
                                          let findOldDPs_aliasDPs_search      = findOldDP + '.aliasDPs_search'; 
                                          createStateAsync(findOldDPs_aliasDPs, {read: true, write: true, name: "ioBroker-DPs mit aliasId (unabhängig history)", type: "string", role: "text", def: JSON.stringify([]) });
                                          createStateAsync(findOldDPs_aliasDPs_search, {read: true, write: true, name: "Start Suche aliasIds in all ioBroker DPs", type: "boolean", role: "button", def: false });
                                          
                                          let dbNamespace = 'history.0';
                                          
                                          
                                          //createStateAsync(findOldDPs_Old, {read: true, write: true, name: "JSON für nicht genutzte DPs noch in DB", type: "string", role: "text", def: JSON.stringify([]) });
                                          createStateAsync(findOldDPs_Enabled, {read: true, write: true, name: "Aktive History-DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
                                          createStateAsync(findoldDPs_withAliasId, {read: true, write: true, name: "Aktive History-DPs mit aliasId", type: "string", role: "text", def: JSON.stringify([]) });
                                          //createStateAsync(findOldDPs_InDB, {read: true, write: true, name: "Genutzte DPs in DB", type: "string", role: "text", def: JSON.stringify([]) });
                                          createStateAsync(findOldDPs_BeginTS, {read: true, write: true, name: "Startverzeichnis", type: "number", role: "", def: 0 });
                                          createStateAsync(findOldDPs_EndTS, {read: true, write: true, name: "Endverzeichnis", type: "number", role: "", def: 10 }); //new Date().getTime()
                                          createStateAsync(findOldDPs_Start, {read: true, write: true, name: "Start Suche", type: "boolean", role: "button", def: false });
                                          createStateAsync(findOldDPs_fillEnabled, {read: true, write: true, name: "enabled_DPs suchen", type: "boolean", role: "button", def: false });
                                          createStateAsync(findOldDPs_fillAlias, {read: true, write: true, name: "withAliasId suchen", type: "boolean", role: "button", def: false });
                                          createStateAsync(findOldDPs_DirectDel, {read: true, write: true, name: "!!! Daten direkt löschen !!!", type: "boolean", role: "", def: false });
                                          createStateAsync(findOldDPs_useAliasInEnabled, {read: true, write: true, name: "AliasId in Enabled_DPs", type: "boolean", role: "", def: false });
                                          
                                          
                                          setTimeout(function(){
                                              findHistoryInstance()
                                          },3000)
                                          
                                          
                                          
                                          on({id: findOldDPs_Start, change: "any"}, function (obj) {
                                              let value = obj.state.val;
                                              if (value){
                                                  //setState(findOldDPs_EndTS,parseInt(new Date().getTime()),false);
                                                  let dbNamespace = getState(activeHistoryDP).val
                                                  if(dbNamespace !=''){
                                                      getEnabledHistoryDPs(dbNamespace);
                                                      let fromDir = getState(findOldDPs_BeginTS).val;
                                                      let toDir = getState(findOldDPs_EndTS).val;
                                                      setTimeout(function(){
                                                          searchDir(fromDir,toDir);
                                                      },5000);
                                                  }else{
                                                      console.warn('Es wurde keine History-Instanz ausgewählt!')
                                                  }
                                                  setStateDelayed(findOldDPs_Start,false,3000,false);
                                              }
                                          });
                                          
                                          on({id: findOldDPs_fillEnabled, change: "any"}, function (obj) {
                                              let value = obj.state.val;
                                              if (value){
                                                  let dbNamespace = getState(activeHistoryDP).val
                                                  if(dbNamespace !=''){
                                                      getEnabledHistoryDPs(dbNamespace);
                                                  }else{
                                                      console.warn('Es wurde keine History-Instanz ausgewählt!')
                                                  }
                                                  setStateDelayed(findOldDPs_fillEnabled,false,3000,false);
                                              }
                                          });
                                          
                                          on({id: findOldDPs_fillAlias, change: "any"}, function (obj) {
                                              let value = obj.state.val;
                                              if (value){
                                                  let dbNamespace = getState(activeHistoryDP).val
                                                  if(dbNamespace !=''){
                                                      listHistoryDPsWithaliasId(dbNamespace);
                                                  }else{
                                                      console.warn('Es wurde keine History-Instanz ausgewählt!')
                                                  }
                                                  setStateDelayed(findOldDPs_fillAlias,false,3000,false);
                                              }
                                          });
                                          
                                          on({id: findOldDPs_aliasDPs_search, change: "any"}, function (obj) {
                                              let value = obj.state.val;
                                              if (value){
                                                  findDPsWithAliasId(); 
                                                  setStateDelayed(findOldDPs_aliasDPs_search,false,3000,false);
                                              }
                                          });
                                          //listHistoryDPsWithaliasId('history.0');
                                          
                                          function listHistoryDPsWithaliasId(adp){
                                              let arr =[];
                                              sendTo(adp, 'getEnabledDPs', {}, function (result) {
                                                  let count = 0;
                                                  for ( let dp in result){
                                                      let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                                                      if (dpHistoryAlias != '' && dpHistoryAlias != undefined){
                                                          arr.push({'dpId':dp,'aliasId':dpHistoryAlias});
                                                          count++;
                                                      }
                                                  }
                                                  log('Anzahl der aktiv geloggten DPs mit aliasId: '+count);        
                                                  // setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                                                  //log(JSON.stringify(arr));
                                                  setState(findoldDPs_withAliasId,JSON.stringify(arr),false);
                                              });
                                          }
                                          
                                          
                                          
                                          
                                          function findHistoryInstance(){
                                              let historyDPs = $('system.adapter.history.*.alive')
                                              let arr = []
                                              for(let i=0;i< historyDPs.length;i++){
                                                  let instance = historyDPs[i].split('.')[3]
                                                  arr.push(instance)
                                                  //console.log(historyDPs[i])
                                              }
                                              console.log('Gefundene History Instanzen: '+arr)
                                              let obj = {'':'History auswählen'}
                                              for (let i=0;i<arr.length;i++){
                                                  obj['history.'+arr[i]] = 'history.'+arr[i]
                                              }
                                              // console.log(obj)
                                              let firstHistory = 'history.'+arr[0]
                                              
                                              if(existsState(activeHistoryDP)){
                                                  let histObj = getObject(activeHistoryDP)
                                                  histObj.common.states = obj
                                                  setObject(activeHistoryDP,histObj)
                                              }else{
                                                  createStateAsync(activeHistoryDP, {read: true, write: true, name: "Auswahl aktive History", type: "string", role: "", def: firstHistory, states: JSON.stringify(obj) });
                                              }
                                          }
                                          
                                          //findDPsWithAliasId(); 
                                          
                                          function findDPsWithAliasId(){
                                              let allDPs = $('*');
                                              let arr = [];
                                              log('Anzahl der States: '+allDPs.length);
                                              for (let i=0;i<allDPs.length;i++){
                                                  if (existsObject(allDPs[i])){
                                                      if (getObject(allDPs[i]).common != undefined){
                                                          if (getObject(allDPs[i]).common.alias!= undefined){
                                                              let aliasId = getObject(allDPs[i]).common.alias.id;
                                                              if (aliasId != undefined){
                                                                  //log(allDPs[i] +' mit aliasId: '+aliasId);
                                                                  //break;
                                                                  arr.push({'id':allDPs[i],'aliasId':aliasId});
                                                              }
                                                          }
                                                      }
                                                  }
                                              }
                                              //log(arr);
                                              setState(findOldDPs_aliasDPs,JSON.stringify(arr),false);
                                          }
                                          
                                          
                                          /*
                                          setTimeout(function(){
                                              getEnabledHistoryDPs(db);
                                              getHistoryDPinDB(db);
                                          },3000);
                                          */
                                          
                                          // getEnabledHistoryDPs('history.0');
                                          
                                          function getEnabledHistoryDPs(adp){
                                              let arr =[];
                                              let useAliasIdInenabled = getState(findOldDPs_useAliasInEnabled).val;
                                              sendTo(adp, 'getEnabledDPs', {}, function (result) {
                                                  let count = 0;
                                                  for ( let dp in result){
                                                      let dpHistoryAlias = getObject(dp).common.custom[adp].aliasId;
                                                      if (dpHistoryAlias != '' && dpHistoryAlias != undefined && useAliasIdInenabled){
                                                          arr.push(dpHistoryAlias);
                                                      }else{
                                                          arr.push(dp);
                                                      }
                                                      count++;
                                                  }
                                                  log('Anzahl der aktiv geloggten DPs: '+count);        
                                                  setStateAsync(findOldDPs_Enabled,JSON.stringify(arr),false);
                                              });
                                          }
                                          
                                          // getHistoryDPinDB('history.0');
                                          
                                          function getHistoryDPinDB(db){
                                              //Die 50 zuletzt gespeicherte Ereignisse für alle IDs holen:
                                              let beginTS = getState(findOldDPs_BeginTS).val;
                                              if (beginTS == 0){
                                                  beginTS = parseInt(new Date().getTime()) - 30*24*60*60*1000;
                                              }
                                              let endTS = getState(findOldDPs_EndTS).val;
                                              if(endTS == 0){
                                                  endTS = parseInt(new Date().getTime());
                                              }
                                              sendTo(db, 'getHistory', {
                                                  id: '*',
                                                  options: {
                                                      begin: beginTS,
                                                      end:   endTS,
                                                      /* count:     50,*/
                                                      addId:     true
                                                  }
                                              }, function (result) {
                                                  let dpArr =[];
                                                  let count = 0;
                                                  for (var i = 0; i < result.result.length; i++) {
                                                      if (!isObjInArray(dpArr,result.result[i].id)){
                                                          dpArr.push(result.result[i].id);
                                                          count++;
                                                      }
                                                      //console.log(JSON.stringify(result.result[i]) + ' ' + new Date(result.result[i].ts).toISOString());
                                                  }
                                                  dpArr = dpArr.sort(function(a, b) {
                                                          return a > b;
                                                          });
                                                  setStateAsync(findOldDPs_InDB,JSON.stringify(dpArr),false);
                                                  //log('Anzahl der DPs in dem durchsuchten Bereich:'+count);
                                                  log(count+' unterschiedliche DPs in "inDB" von '+ formatDate(beginTS,'DD.MM.YYYY hh:mm:ss')+' - '+formatDate(endTS,'DD.MM.YYYY hh:mm:ss'));
                                                  //Vergleich der DPs
                                                  let nonActiveArr = [];
                                                  let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                                                  for (let i=0; i< dpArr.length;i++){
                                                      // dpArr[i]
                                                      let vorhanden = false;
                                                      for (let  j=0; j< activeDPs.length;j++ ){
                                                          if (dpArr[i] === activeDPs[j]){
                                                              vorhanden = true;
                                                              break; // vorhanden
                                                          }
                                                      }
                                                      if (!vorhanden){
                                                          // wird nicht mehr geloggt von active
                                                          nonActiveArr.push(dpArr[i]);
                                                      }
                                                  }
                                                  setState(findOldDPs_Old,JSON.stringify(nonActiveArr),false);
                                              });
                                          }
                                          
                                          
                                          
                                          
                                          function isObjInArray(arr,itemObj){
                                              if (arr.length>0){
                                                  for (let x=0;x<arr.length-1;x++){
                                                      if (JSON.stringify(arr[x]) === JSON.stringify(itemObj)){
                                                          return true;
                                                      }
                                                  }
                                                  return false;
                                              }else{
                                                  return false;
                                              }
                                          }
                                          
                                          // searchDir(0,10);
                                          
                                          function searchDir(fromDir, toDir){
                                              let fs = require('fs');
                                              let activeDPs = JSON.parse(getState(findOldDPs_Enabled).val);
                                              let notActiveDPs = [];
                                              let dbNamespace = getState(activeHistoryDP).val
                                              if(dbNamespace !=''){
                                                  let sysAdaptDir = getObject('system.adapter.'+dbNamespace).native.storeDir;
                                                  console.warn('Ablage für History: '+dbNamespace+' im Verzeichnis: '+sysAdaptDir)
                                                  fs.readdir(sysAdaptDir , function (erro, file) {
                                                      if (erro) {
                                                          log('Fehler beim Lesen des Verzeichnisses: ' + erro, 'error');
                                                          return;
                                                      }
                                                      log(file.length+' Verzeichnisse wurde(n) gelesen!');
                                                      log('fromDir und toDir dürfen nur im Bereich von 0 bis '+file.length +' sein! Bitte in 10er-Schritten verwenden!');
                                                      log('Es wurde ein Bereich von '+fromDir +' bis '+ toDir+' gewählt-> es dauert '+(toDir-fromDir)*2 +' Sekunden');
                                                      if (fromDir <0 || toDir >file.length){
                                          
                                                      }else{
                                                          for (let j=fromDir; j<toDir; j++){
                                                              //log(file[j]);
                                                              if (file[j].indexOf('.')>=0 && file[j].length >8){
                                          
                                                              }else{
                                                                  fs.readdir(sysAdaptDir+'/'+file[j] , function (error, files) {
                                                                      log(files.length+' DPs im Verzeichnis: '+file[j]);
                                                                      for (let i=0;i< files.length; i++){
                                                                          let dpFiles = files[i].substring(8,files[i].length-5);
                                                                          if (isObjInArray(activeDPs,dpFiles)){
                                                                          }else{
                                                                              notActiveDPs.push({'id':dpFiles,'dir':file[j]});
                                                                          }
                                                                      }
                                                                  });
                                                                  //fs.unlinkSync('/opt/iobroker/iobroker-data/files/vis.0/'+jarvisDirName+'/'+files[i]+'/'+file[j]);
                                                              }
                                                          }
                                                          setTimeout(function(){
                                                              log('Nicht aktive DPs in den ausgewählten Verzeichnissen: '+notActiveDPs.length);
                                                              let olddir= '';
                                                              let directDelete = getState(findOldDPs_DirectDel).val;
                                                              for (let i=0;i<notActiveDPs.length;i++){
                                                                  if (directDelete){
                                                                      // Direkt löschen
                                                                      fs.unlinkSync(sysAdaptDir+'/'+notActiveDPs[i].dir+'/history.'+notActiveDPs[i].id+'.json');
                                                                  }
                                                                  if (notActiveDPs[i].dir != olddir){
                                                                      if (directDelete){
                                                                          log('Im Verzeichnis: '+notActiveDPs[i].dir +' folgende Dateien sind gelöscht!:','warn');
                                                                      }else{
                                                                          log('Im Verzeichnis: '+notActiveDPs[i].dir +' können folgende Dateien gelöscht werden:','warn');
                                                                      }
                                                                      olddir = notActiveDPs[i].dir;
                                                                  }
                                                                  log(notActiveDPs[i].id);
                                                              }
                                                          },2000 * (toDir-fromDir)); // file.length
                                                      }
                                                  });
                                              }else{
                                                  console.warn('Es wurde keine History-Instanz ausgewählt!')
                                              }
                                          }
                                          
                                          M Online
                                          M Online
                                          MCU
                                          wrote on last edited by MCU
                                          #142

                                          @matt77che Die angezeigten Fehler sind nicht das Problem.
                                          Es geht um das Verzeichnis in dem die Daten liegen.
                                          Was steht im Log?
                                          -> Ablage für History
                                          Welche Instanz wurde ausgewählt

                                          Wie sind die Einstellungen in den History-Instanzen.

                                          NUC i7 64GB mit Proxmox ---- Jarvis Infos Aktualisierungen der Doku auf Instagram verfolgen -> mcuiobroker Instagram
                                          Wenn Euch mein Vorschlag geholfen hat, bitte rechts "^" klicken.

                                          1 Reply Last reply
                                          0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate
                                          FAQ Cloud / IOT
                                          HowTo: Node.js-Update
                                          HowTo: Backup/Restore
                                          Downloads
                                          BLOG

                                          531

                                          Online

                                          32.8k

                                          Users

                                          82.7k

                                          Topics

                                          1.3m

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

                                          • Don't have an account? Register

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