Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Script - Info über Datenpunkte sammeln

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Script - Info über Datenpunkte sammeln

    This topic has been deleted. Only users with topic management privileges can see it.
    • sigi234
      sigi234 Forum Testing Most Active @liv-in-sky last edited by sigi234

      @liv-in-sky

      Super arbeit, funktioniert. Jetzt werden nur die Objekte gezählt die angegeben sind.

      Objekte in Instanz  	Anzahl  
      Eigene_datenpunkte.0  	0  
      alexa2.0  	2040  
      Gesamt geprüfte Objekte in Instanzen  	2040  
      

      Vergleich mit ioBroker Ansicht : 2455

      Info 2:

      ical.3  	nicht aktiviert  
      ical.2  	nicht aktiviert  
      ical.1  	nicht aktiviert  
      ical.0  	nicht aktiviert  
      

      Diese Instanzen sind zwar aktiviert ( Grün) , gehe davon aus weil sie erst bei einen Cron starten sind sie bei dir als nicht aktiviert gekennzeichnet.Sind nur Beispiele , da gibt es mehrere.

      liv-in-sky 1 Reply Last reply Reply Quote 0
      • liv-in-sky
        liv-in-sky @sigi234 last edited by

        @sigi234 die webseite funktioniert auch wieder ?

        wegen der ical beispiele

        ich verstehe das script folgendermaßen:

        es läuft nicht immer, sondern nur bei bedarf, um mal zu sehen, wie es um die datenpunkte steht - besonders für die eigenen datenpunkte und die unter javascript.

        • z.b habe ich einige leere dp gefunden, welche ich auch löschen kann, weil sie nicht mehr in benutzung sind - das gilt nicht für adapter (da kann ich ja die datenpunkte nicht definieren)
        • oder nachdem ich mal alle datenpunkte einer instanz gelöscht habe (daswetter.com) bin ich von 1400 auf 900 datenpunkte gekommen - alle diese punkte müssen ja irgendwo/wie verwaltet werden und benötigin resourcen dafür - es kann also nicht schaden, die datenpunkte zu minimieren
        • entwickler können checken, ob alle datenpunkte richtig deklariert worden sind und nur den gewünschen adapter zu überwachen
        • entwickler können einzelne ordner in der struktut überwachen - also nicht eine ganze instanz, sondern nur die ordner (siehe bild) , die ich gerade bearbeite durch ein script (ist noch in entwicklung)

        Image 5.png

        sigi234 1 Reply Last reply Reply Quote 0
        • sigi234
          sigi234 Forum Testing Most Active @liv-in-sky last edited by

          @liv-in-sky sagte in Script - Info über Datenpunkte sammeln:

          die webseite funktioniert auch wieder ?

          JA👍

          1 Reply Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @Dutchman last edited by

            @Dutchman sagte in Script - Info über Datenpunkte sammeln:

            @liv-in-sky sagte in Script - Info über Datenpunkte sammeln:

            beim aufsuchen der datenpunkte kann es zu vielen warnungen im log kommen - ist nicht verhinderbar

            koenntest dus eventuell mit nem

            try {
               hier der code
            }
            

            abfangen

            moin - hast du da mehr kenntnisse?

            viele warnungen kommen bei der abfrage ob ein wert vorhanden ist

            var valType =  getState(id).val;
            

            wenn ich nun das versuche, ändert sich nichts - die warnungen kommen - es wird kein error ausgegeben

             try {
                    var valType =  getState(id).val;
                    } catch (e) {console.log("------------ERROR: "+e)}
            

            ich glaube, dass man das nicht verhindern kann

            1 Reply Last reply Reply Quote 0
            • liv-in-sky
              liv-in-sky last edited by liv-in-sky

              es gibt ein update - u.a gibt es jetzt eine directSearch ! mehrim ersten post

              wünsche - anregungen werden gerne angenommen

              bitte alles unter const instanzArr=... ersetzen

              sigi234 1 Reply Last reply Reply Quote 0
              • sigi234
                sigi234 Forum Testing Most Active @liv-in-sky last edited by sigi234

                @liv-in-sky

                <p style="color:red;font-family:Helvetica;"><i>!!! ohne Javascript Instanzen !!! kann enabled werden</i></p>undefined<p style="color:red;font-family:Helvetica;"><i>Script hat Fehler - bitte Log checken !!!</i></p>
                

                Skript:

                // @Liv-in-sky Okt.  2019
                
                
                
                
                                                           // WICHTIG
                                                           // hier muss die instanz der eigenen datenpunkte angegeben werden oder zusätzlich, die man prüfen möchte    , "alexa2.0"
                                                           //oder auch nur einzelne ornder in der datenstruktur z.b. "javascript.2.WLANUnifi"
                const instanzArr=[ "Eigene_Datenpunkte.0", "ping.0"];       
                                                           // beispiel const instanzArr=[ "eigeneDatenpunkte.0", "ping.0", "javascript.2.WLANUnifi"];
                
                
                var color_in_table="black"         // Farbe text in webseite
                let schriftart="Helvetica";        // möglich: Helvetica,Serif
                var color_gradient1="#819FF7";     // Hintergrund webseite 
                var colorHeadlines="darkblue";     // Farbe Überschriften in der VIS Anzeige
                var colorHeadlinesDP="#36d5ec ";   // Farbe Überschriften in der WebSeite Anzeige     
                var warnFarbe = "#36d5ec";         //Farbe für Warnungen in vis und Webseite
                
                
                javascript.0	2019-10-18 15:29:46.244	info	(12524) script.js.System.Objekte: ================================schreibe file
                javascript.0	2019-10-18 15:29:46.242	info	(12524) script.js.System.Objekte: ----------select: ping.0.*
                javascript.0	2019-10-18 15:29:46.242	info	(12524) script.js.System.Objekte: ---------: *
                javascript.0	2019-10-18 15:29:46.241	info	(12524) script.js.System.Objekte: ----------select: Eigene_Datenpunkte.0.*
                javascript.0	2019-10-18 15:29:46.241	info	(12524) script.js.System.Objekte: ---------: *
                javascript.0	2019-10-18 15:29:26.841	info	(12524) script.js.System.Objekte: registered 2 subscriptions and 0 schedules
                javascript.0	2019-10-18 15:29:26.838	info	(12524) Start javascript script.js.System.Objekte
                javascript.0	2019-10-18 15:29:26.835	info	(12524) Stop script script.js.System.Objekte
                javascript.0	2019-10-18 15:29:02.734	info	(12524) script.js.System.Objekte: registered 2 subscriptions and 0 schedules
                javascript.0	2019-10-18 15:29:02.728	info	(12524) Start javascript script.js.System.Objekte
                

                Schaut jetzt besser aus:
                Im DP OrdnerCheck war ein true drinnen

                Screenshot (327).png

                liv-in-sky 1 Reply Last reply Reply Quote 0
                • sigi234
                  sigi234 Forum Testing Most Active @liv-in-sky last edited by sigi234

                  @liv-in-sky sagte in Script - Info über Datenpunkte sammeln:

                  zumindest müßte einmal ein webseite (wenn auch mit fehlermeldung) erzeugt werden

                  Ja, aber wenn ich die instanzArr ändere wir keine Webseite geschrieben? Sollte doch sein.

                  Ich habe die Webadresse zu den Favoriten hinzugefügt und rufe diese dann auf. Vielleicht setzt er da einen Cookie und aktualisiert nicht?

                  1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @sigi234 last edited by

                    @sigi234

                    hast du das ganze script ersetzt - hatte ich vergessen zu erwähnen - es gibt auch eine änderung über ab hier nichts mehr ändern

                    nur const instanzArr kannst du später wieder reinkopieren

                    sigi234 1 Reply Last reply Reply Quote 0
                    • sigi234
                      sigi234 Forum Testing Most Active @liv-in-sky last edited by

                      @liv-in-sky sagte in Script - Info über Datenpunkte sammeln:

                      hast du das ganze script ersetzt

                      Ja

                      liv-in-sky 3 Replies Last reply Reply Quote 0
                      • liv-in-sky
                        liv-in-sky @sigi234 last edited by liv-in-sky

                        @sigi234

                        hier nochmal eine ganze version - bitte ganz ersetzen und anschliessend dein settings für const instanzArr wieder hernehmen

                        // @Liv-in-sky Okt.  2019
                        
                        
                        
                        
                                                                  // WICHTIG
                                                                  // hier muss die instanz der eigenen datenpunkte angegeben werden oder zusätzlich, die man prüfen möchte    , "alexa2.0"
                                                                  //oder auch nur einzelne ornder in der datenstruktur z.b. "javascript.2.WLANUnifi"
                        const instanzArr=[ "javascript.2.WLANUnifi", "javascript.0.ProofingDatapoints", "controll-own.0"];      
                                                                  // beispiel const instanzArr=[ "eigeneDatenpunkte.0", "ping.0",];
                        
                        var color_in_table="black"         // Farbe text in webseite
                        let schriftart="Helvetica";        // möglich: Helvetica,Serif
                        var color_gradient1="#819FF7";     // Hintergrund webseite 
                        var colorHeadlines="darkblue";     // Farbe Überschriften in der VIS Anzeige
                        var colorHeadlinesDP="#36d5ec ";   // Farbe Überschriften in der WebSeite Anzeige     
                        var warnFarbe = "#36d5ec";         //Farbe für Warnungen in vis und Webseite
                        
                        
                        //------------------------------------------AB HIER NICHTS ÄNDERN--------------------------------------------------------
                        
                        
                        
                        const versionNr = "15102019-1.1"
                        const warnColor = warnFarbe ;
                        
                        const format = "<!DOCTYPE html><html lang=\"de\"><head><title>Putzer</title><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head><body>";
                        const htmlTable="<table style=\"color:"+color_in_table+";text-align:left; font-family:"+schriftart+";background-image: linear-gradient(67deg,transparent,"+color_gradient1+");\">";
                        const htmlReset="<p style=\"color:red;font-family:"+schriftart+";\"><i>!!! ohne Javascript Instanzen !!! kann enabled werden</i></p>"
                        const htmlHeaders = "style=\"color:"+colorHeadlines+";\""; 
                        const htmlHeadersDP = "style=\"color:"+colorHeadlinesDP+";\""; 
                        
                        //  var htmlOhneAnzahl="<p style=\"color:red;font-family:"+schriftart+";\"><i>!!! ohne DatenpunktZählung !!! kann enabled werden</i></p>"
                        const htmlError="<p style=\"color:red;font-family:"+schriftart+";\"><i>Script hat Fehler - bitte Log checken !!!</i></p>"
                        var allInstArr=[];
                        var  instanzArrHelp=[];
                        const dpPrefix = "javascript."+ instance +".";
                        var mylogs=false;
                        var htmlDP=[];
                        var htmlMSG=[];
                        var counterAll=0;
                        var directSearch=false;
                        
                        
                        var htmlHelper="";
                        var htmlHelperFile="";
                        
                        createState(dpPrefix + "ProofingDatapoints.HTMLTable", { name: 'HTMLTable',  type: 'string', read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.ScriptVersion", versionNr,{ name: 'ScriptVersion',  type: 'string', read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.RunScript", { name: 'RunScript',  type: 'boolean', role:"switch", read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.JavaInstanzCheck", true,{ name: 'JavaInstanzCheck',  type: 'boolean', role:"switch", read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.ObjectAnzahlCheck", true,{ name: 'ObjectAnzahlCheck',  type: 'boolean', role:"switch", read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.MonsterSearch", false,{ name: 'MonsterSearch',  type: 'boolean', role:"switch", read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige", false,{ name: 'ohneInstanzAnzeige',  type: 'boolean', role:"switch", read:  true,  write: true,});
                        createState(dpPrefix + "ProofingDatapoints.OrdnerCheck", { name: 'OrdnerCheck',  type: 'string', read:  true,  write: true,});
                        
                        
                        //------------------------------------------CHECK INSTANZEN--------------------------------------------------------
                        
                        function instanzCount(){
                          var ohneInstanz = getState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige").val;
                          
                           var counter=0; var counter2=0;var counter3=0; 
                        $('system.adapter.*.alive').each(function(id, i) {
                        
                        
                            var ida = id.split('.');
                             allInstArr.push(ida[2]+"."+ida[3]);
                        
                          if (!ohneInstanz && !directSearch) {
                           
                           if(!id.includes("vis")){
                           
                        
                           counter++;
                        
                           if (getState(id).val==null) {;counter2++; mylog(ida[2]+ida[3]+"--------------------der hier wurde nie gestartet"); 
                              htmlDP.push(ida[2]+"."+ida[3]);
                              htmlMSG.push("Instanzen ohne Werte");} //else{instanzArr.push(ida[2]+"."+ida[3])}
                           if (getState(id).val==false) {counter3++;mylog(ida[2]+ida[3]+"-----------------------der hier ist ausgeschalten"); 
                              htmlDP.push(ida[2]+"."+ida[3]);
                              htmlMSG.push("nicht aktiviert");} /*else{instanzArr.push(ida[2]+"."+ida[3])}*/
                           }}
                        });
                         if (!ohneInstanz) {
                        mylog("______________________________________________Anzahl Instanzen: " + counter.toString());
                        htmlDP.push("");
                        htmlMSG.push("");
                        htmlDP.push("Anzahl Instanzen");
                        htmlMSG.push(counter.toString());
                        
                        mylog("______________________________________________Anzahl gestoppter Instanzen ohne Werte: " + counter2.toString())
                        htmlDP.push("Instanzen ohne Werte");
                        htmlMSG.push(counter2.toString());
                        htmlDP.push("Instanzen nicht aktiviert");
                        htmlMSG.push(counter3.toString());
                        
                         }
                        
                        }
                        
                        
                        //------------------------------------------CHECK ZUORDNUNG--------------------------------------------------------
                        
                        function checkTypes(select) {
                            mylog("bin in check types");
                           var counter=0; 
                           htmlMSG.push("");
                           htmlDP.push("");
                           var sub= select.substring(select.length-1, select.length); log("---------: "+sub);log("----------select: "+select);
                           mylog(select)
                           $(select).each(function (id, i) {
                               counter++
                        
                               
                                  
                           if (!id.includes('scriptEnabled') && !id.includes('scriptProblem')  && getState(id).val !== null /*&& !id.includes('Log-Script')  && !id.includes('Ereignisliste') && !id.includes('GETPROCESS')*/ ){
                        
                               if (!JSON.stringify(getObject(id)).includes("type")) {
                              
                                    var valType = typeof getState(id).val;
                                     htmlDP.push(id+": "+valType);
                                     htmlMSG.push("<b>missing TYPE !!</b>" );}
                               
                                else{ var dpType = getObject(id).common.type;
                                      var valType = typeof getState(id).val;
                                      if(dpType != "mixed" ) {
                                      if(dpType !== valType && !(dpType == 'array' && valType == 'object') /*&& !(dpType =='text' && valType=='string') && !(dpType =='string' && valType=='text')*/ ) {
                                         mylog(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                                         htmlDP.push(id+": "+valType);
                                         htmlMSG.push(dpType );
                        
                                         /* später testing)
                                         console.log("======1=============no type: "+id +"object: "+JSON.stringify(getObject(id)));
                                         if(!getObject(id).common.hasOwnProperty("type")) console.log("--------------kein TYPE: "+id) ;
                                         console.log("======2=============no type: "+id +"object: "+JSON.stringify(getObject(id).common));
                                       */
                                         
                                         }
                                       
                               }}
                             /*
                               if(dpType != valType && !(dpType == 'array' && valType == 'object')) {
                                   log(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                                   htmlDP.push(dpType);
                                   htmlMSG.push(valType);
                               }*/
                           }
                           });
                           htmlDP.push("<i>ID + IST-WERT</i>");
                           htmlMSG.push("<i>SOLL-WERT</i>");
                           htmlDP.push("-col-<b>geprüfte Instanz</b>");
                           htmlMSG.push("-col-<i><b>"+select+"</b></i>");
                           mylog("fertg" + counter.toString())
                          
                        }
                        
                        //------------------------------------------CHECK  WERTE--------------------------------------------------------
                        
                        function checkWerte(select) {
                           mylog("bin in check Werte");
                           var counter=0; 
                        
                           mylog(select);
                           $(select).each(function (id, i) {
                               counter++
                               
                           if (!id.includes('scriptEnabled') && !id.includes('scriptProblem') /* )  && !id.includes('Ereignisliste') && !id.includes('GETPROCESS')*/ ){
                              //var dpType = getObject(id).common.type;
                               try {
                               var valType =  getState(id).val;
                               } catch (e) {console.log("------------ERROR: "+e)}
                        
                        
                              // if(dpType != "mixed" ) {}
                        
                                   if(valType === null) {mylog(id + ': Datenpunkttyp: ' /*+ dpType */+ ", Wert: "+valType);
                                       htmlDP.push(id);
                                       var ddd = new Date().getTime()-getObject(id).ts;
                                       htmlMSG.push("missing seit " + Math.floor((ddd)/1000/60/60/24)+"d "+Math.floor((ddd)/1000/60/60 %24)+"h "+Math.floor((ddd)/1000/60 %60)+"m ");
                                   } 
                               
                            
                           }
                           });
                         
                            mylog("bin raus aus check Werte");
                          
                        }
                        //---------------------------------------------------------------------------------------------------------------------
                        
                        
                        function mylog(message) {
                          if(mylogs)
                              console.log(message);
                        }
                        
                        //------------------------------------------Zähle Objecte der  INSTANZEN--------------------------------------------------------
                        function countDP(idb){
                           mylog("bin richtig in count");
                           var counter4=0;
                        
                           $(idb+".*").each(function(id, i) {
                           counter4++; })
                        
                        mylog(idb+counter4);
                        htmlDP.unshift(idb);
                        htmlMSG.unshift(counter4.toString());
                        counterAll=counterAll+counter4;
                        mylog("bin raus aus count");
                        }
                        
                        //----------------------------------------------Direct Suchen
                        
                        on({id:dpPrefix + "ProofingDatapoints.OrdnerCheck", change: "any"}, function (obj) {
                           
                            directSearch=true;
                             instanzArrHelp=[];
                            setState(dpPrefix + "ProofingDatapoints.RunScript",true);
                        
                        
                            });
                        
                        //-----------------------------------------------SCHALTER MAIN------------------------------------------------
                        on({id:dpPrefix + "ProofingDatapoints.RunScript",  val: true}, function (obj) { 
                           let java= getState(dpPrefix + "ProofingDatapoints.JavaInstanzCheck").val;
                           let instanzAnzahl= getState(dpPrefix + "ProofingDatapoints.ObjectAnzahlCheck").val;
                           let monster= getState(dpPrefix + "ProofingDatapoints.MonsterSearch").val;
                           var ohneInstanz = getState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige").val;
                           var endehtmlConst=   "<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\">Letztes File Update: "+formatDate(getDateObject((parseFloat((new Date().getTime())))), "SS:mm:ss")+"</p>";
                           var endehtmlDPConst=   "<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\">Letztes Table Update: "+formatDate(getDateObject((parseFloat((new Date().getTime())))), "SS:mm:ss")+"</p>";
                           setState(dpPrefix + "ProofingDatapoints.ScriptVersion",versionNr);
                           htmlHelper="";
                           htmlHelperFile="";
                           setState(dpPrefix + "ProofingDatapoints.HTMLTable",htmlReset+endehtml+htmlError);
                           writeFile(null, "/ProofingDatapoints/htmlputz.html" ,htmlReset+endehtml+htmlError+"</body>", function (error) {mylog('file written'); });
                          
                           counterAll=0;
                           instanzArrHelp=[];
                           allInstArr=[];
                        
                        
                        setStateDelayed(dpPrefix + "ProofingDatapoints.RunScript",false,2500);
                        
                        htmlDP=[];
                        htmlMSG=[];
                        
                        instanzCount();  //überprüft instanzen und stellt allInstArr her
                        
                        htmlDP.push("-col-<b>INSTANZ INFO</b>"); htmlMSG.push(""); htmlDP.push(""); htmlMSG.push("");
                        mylog(instanzArr.length+"==================="+instanzArr.toString());
                        
                        
                        if (monster) {instanzArrHelp=allInstArr;} else {instanzArrHelp=instanzArr}  //ACHTUNG MONSTERSEARCH
                        if (directSearch) {instanzArrHelp=[]; instanzArrHelp.push(getState(dpPrefix + "ProofingDatapoints.OrdnerCheck").val);}
                        
                        for(let name in instanzArrHelp){
                           checkWerte(instanzArrHelp[name]+".*")                   //checkt alle werte in intanzArr
                            mylog("!!!!!!!!!!!!!!!!!!!!:  "+instanzArrHelp[name]);}
                        
                            if (instanzAnzahl){
                                  htmlDP.unshift(""); htmlMSG.unshift("");htmlDP.unshift("<b>OBJECTE IN INSTANZ</b>"); htmlMSG.unshift("Anzahl"); 
                                   
                                  for(let name in instanzArrHelp){
                                    countDP(instanzArrHelp[name]);mylog("bin in zhlen");}
                                    if (java && !monster) countDP("javascript")
                                  htmlDP.unshift("-col-<b>GESAMT GEPRÜFTE OBJECTE IN INSTANZEN</b>"); htmlMSG.unshift("-col-<b>"+counterAll.toString()+"</b>"); 
                                  
                                  }
                                  mylog("=============: "+counterAll);
                        
                        if (java && !monster && !ohneInstanz && !directSearch) checkWerte('javascript.*');                //checkt alle javainstanzen
                        
                        
                         htmlDP.push("-col-<b>ID's OHNE WERT:</b>");
                         htmlMSG.push("");
                        
                        for(let name in instanzArrHelp){
                           checkTypes(instanzArrHelp[name]+".*")
                           mylog("!!!!!!!!!!!!!!!!!!!!:  "+instanzArrHelp[name])};
                             htmlDP.push("");
                             htmlMSG.push("");
                             htmlDP.push("-col-<b>IDs MIT FALSCHEN TYPE:</b>");
                             htmlMSG.push("");
                        
                        
                         if (java && !monster && !ohneInstanz && !directSearch ) checkTypes('javascript.*');
                        
                        for(var i= htmlDP.length-1; i>-1; i--) {
                            let htmlDPVis; let htmlDPFile;let htmlMSGVis;let htmlMSGFile;
                              if(htmlDP[i].includes("-col-")) {htmlDPVis=htmlDP[i].replace("-col-", (htmlHeadersDP+">"));  htmlDPVis=" "+htmlDPVis } else {htmlDPVis=">"+htmlDP[i]}
                              if(htmlMSG[i].includes("-col-")) {htmlMSGVis=htmlMSG[i].replace("-col-", (htmlHeadersDP+">"));htmlMSGVis=" "+htmlMSGVis } else {htmlMSGVis=">"+htmlMSG[i]}
                              htmlHelper= htmlHelper+"<tr><td"+htmlDPVis+"&ensp;&ensp;</td><td"+htmlMSGVis+"&ensp;&ensp;</td></tr>"
                        
                            //  if(htmlDP[i].includes("-col-")) {htmlDP[i]=htmlDP[i].replace("-col-", (htmlHeaders+">")); htmlDPFile=htmlDP[i]; htmlDPFile= " "+htmlDPFile ; } else {htmlDPFile=">"+htmlDP[i]}
                                    if(htmlDP[i].includes("-col-")) {htmlDPFile=htmlDP[i].replace("-col-", (htmlHeaders+">"));  htmlDPFile= " "+htmlDPFile ; } else {htmlDPFile=">"+htmlDP[i]}
                        
                              if(htmlMSG[i].includes("-col-")) {htmlMSGFile=htmlMSG[i].replace("-col-", (htmlHeaders+">")); htmlMSGFile=" "+htmlMSGFile; } else {htmlMSGFile=">"+htmlMSG[i]}    
                              htmlHelperFile= htmlHelperFile+"<tr><td"+htmlDPFile+"&ensp;&ensp;</td><td"+htmlMSGFile+"&ensp;&ensp;</td></tr>"
                        }
                           var   endehtml=endehtmlConst;
                           var   endehtmlDP=endehtmlDPConst;                       
                            
                        
                           if (monster){endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Monster Suche wird automatisch  deaktiviert !!!</i></p>"+endehtml;
                                     endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! ACHTUNG: SYSTEM WIRD BELASTET !!! </br></br>!!! Monster Suche wird automatisch  deaktiviert !!! </br></br> BERICHT/AUSWERTUNG NUR ÜBER WEBSEITE</i></p>"+endehtmlDP;}
                        
                        
                           if (!instanzAnzahl){endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne DatenpunktZählung !!! kann enabled werden</i></p>"+endehtml;
                                     endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne DatenpunktZählung !!! kann enabled werden</i></p>"+endehtmlDP;}
                        
                           if (!java){ endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne Javascript Instanzen !!! kann enabled werden</i></p>"+endehtml;
                                     endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne Javascript Instanzen !!! kann enabled werden</i></p>"+endehtmlDP;}
                           
                           if(!monster) { setStateDelayed(dpPrefix + "ProofingDatapoints.HTMLTable",endehtmlDP+"<table>"+htmlHelper,900);} else{setStateDelayed(dpPrefix + "ProofingDatapoints.HTMLTable",endehtmlDP,900);}
                          
                           console.log("================================schreibe file")  ; 
                           if(true)  writeFile(null, "/ProofingDatapoints/htmlputz.html" ,format+endehtml+htmlTable+htmlHelperFile+"</table></body>", function (error) { mylog('file written'); });
                        
                          // endehtml=endehtmlConst;
                          // endehtmlDP=endehtmlDPConst;
                        
                           setState(dpPrefix + "ProofingDatapoints.MonsterSearch",false);  //setzt monstersearch zurück
                          directSearch=false;
                        
                        
                        });
                        
                        

                        1 Reply Last reply Reply Quote 0
                        • liv-in-sky
                          liv-in-sky @sigi234 last edited by

                          @sigi234

                          warte mal kurz - checke noch was !

                          1 Reply Last reply Reply Quote 0
                          • liv-in-sky
                            liv-in-sky @sigi234 last edited by

                            @sigi234

                            sorry - jetzt damit mal

                            // @Liv-in-sky Okt.  2019
                            
                            
                            
                            
                                                                      // WICHTIG
                                                                      // hier muss die instanz der eigenen datenpunkte angegeben werden oder zusätzlich, die man prüfen möchte    , "alexa2.0"
                                                                      //oder auch nur einzelne ornder in der datenstruktur z.b. "javascript.2.WLANUnifi"
                            const instanzArr=[ "javascript.2.WLANUnifi", "javascript.0.ProofingDatapoints", "controll-own.0"];      
                                                                      // beispiel const instanzArr=[ "eigeneDatenpunkte.0", "ping.0",];
                            
                            var color_in_table="black"         // Farbe text in webseite
                            let schriftart="Helvetica";        // möglich: Helvetica,Serif
                            var color_gradient1="#819FF7";     // Hintergrund webseite 
                            var colorHeadlines="darkblue";     // Farbe Überschriften in der VIS Anzeige
                            var colorHeadlinesDP="#36d5ec ";   // Farbe Überschriften in der WebSeite Anzeige     
                            var warnFarbe = "#36d5ec";         //Farbe für Warnungen in vis und Webseite
                            
                            
                            //------------------------------------------AB HIER NICHTS ÄNDERN--------------------------------------------------------
                            
                            
                            
                            const versionNr = "15102019-1.1"
                            const warnColor = warnFarbe ;
                            
                            const format = "<!DOCTYPE html><html lang=\"de\"><head><title>Putzer</title><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head><body>";
                            const htmlTable="<table style=\"color:"+color_in_table+";text-align:left; font-family:"+schriftart+";background-image: linear-gradient(67deg,transparent,"+color_gradient1+");\">";
                            const htmlReset="<p style=\"color:red;font-family:"+schriftart+";\"><i>!!! ohne Javascript Instanzen !!! kann enabled werden</i></p>"
                            const htmlHeaders = "style=\"color:"+colorHeadlines+";\""; 
                            const htmlHeadersDP = "style=\"color:"+colorHeadlinesDP+";\""; 
                            
                            //  var htmlOhneAnzahl="<p style=\"color:red;font-family:"+schriftart+";\"><i>!!! ohne DatenpunktZählung !!! kann enabled werden</i></p>"
                            const htmlError="<p style=\"color:red;font-family:"+schriftart+";\"><i>Script hat Fehler - bitte Log checken !!!</i></p>"
                            var allInstArr=[];
                            var  instanzArrHelp=[];
                            const dpPrefix = "javascript."+ instance +".";
                            var mylogs=false;
                            var htmlDP=[];
                            var htmlMSG=[];
                            var counterAll=0;
                            var directSearch=false;
                            
                            
                            var htmlHelper="";
                            var htmlHelperFile="";
                            
                            createState(dpPrefix + "ProofingDatapoints.HTMLTable", { name: 'HTMLTable',  type: 'string', read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.ScriptVersion", versionNr,{ name: 'ScriptVersion',  type: 'string', read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.RunScript", { name: 'RunScript',  type: 'boolean', role:"switch", read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.JavaInstanzCheck", true,{ name: 'JavaInstanzCheck',  type: 'boolean', role:"switch", read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.ObjectAnzahlCheck", true,{ name: 'ObjectAnzahlCheck',  type: 'boolean', role:"switch", read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.MonsterSearch", false,{ name: 'MonsterSearch',  type: 'boolean', role:"switch", read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige", false,{ name: 'ohneInstanzAnzeige',  type: 'boolean', role:"switch", read:  true,  write: true,});
                            createState(dpPrefix + "ProofingDatapoints.OrdnerCheck", { name: 'OrdnerCheck',  type: 'string', read:  true,  write: true,});
                            
                            
                            //------------------------------------------CHECK INSTANZEN--------------------------------------------------------
                            
                            function instanzCount(){
                              var ohneInstanz = getState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige").val;
                              
                               var counter=0; var counter2=0;var counter3=0; 
                            $('system.adapter.*.alive').each(function(id, i) {
                            
                            
                                var ida = id.split('.');
                                 allInstArr.push(ida[2]+"."+ida[3]);
                            
                              if (!ohneInstanz && !directSearch) {
                               
                               if(!id.includes("vis")){
                               
                            
                               counter++;
                            
                               if (getState(id).val==null) {;counter2++; mylog(ida[2]+ida[3]+"--------------------der hier wurde nie gestartet"); 
                                  htmlDP.push(ida[2]+"."+ida[3]);
                                  htmlMSG.push("Instanzen ohne Werte");} //else{instanzArr.push(ida[2]+"."+ida[3])}
                               if (getState(id).val==false) {counter3++;mylog(ida[2]+ida[3]+"-----------------------der hier ist ausgeschalten"); 
                                  htmlDP.push(ida[2]+"."+ida[3]);
                                  htmlMSG.push("nicht aktiviert");} /*else{instanzArr.push(ida[2]+"."+ida[3])}*/
                               }}
                            });
                             if (!ohneInstanz) {
                            mylog("______________________________________________Anzahl Instanzen: " + counter.toString());
                            htmlDP.push("");
                            htmlMSG.push("");
                            htmlDP.push("Anzahl Instanzen");
                            htmlMSG.push(counter.toString());
                            
                            mylog("______________________________________________Anzahl gestoppter Instanzen ohne Werte: " + counter2.toString())
                            htmlDP.push("Instanzen ohne Werte");
                            htmlMSG.push(counter2.toString());
                            htmlDP.push("Instanzen nicht aktiviert");
                            htmlMSG.push(counter3.toString());
                            
                             }
                            
                            }
                            
                            
                            //------------------------------------------CHECK ZUORDNUNG--------------------------------------------------------
                            
                            function checkTypes(select) {
                                mylog("bin in check types");
                               var counter=0; 
                               htmlMSG.push("");
                               htmlDP.push("");
                               var sub= select.substring(select.length-1, select.length); log("---------: "+sub);log("----------select: "+select);
                               mylog(select)
                               $(select).each(function (id, i) {
                                   counter++
                            
                                   
                                      
                               if (!id.includes('scriptEnabled') && !id.includes('scriptProblem')  && getState(id).val !== null /*&& !id.includes('Log-Script')  && !id.includes('Ereignisliste') && !id.includes('GETPROCESS')*/ ){
                            
                                   if (!JSON.stringify(getObject(id)).includes("type")) {
                                  
                                        var valType = typeof getState(id).val;
                                         htmlDP.push(id+": "+valType);
                                         htmlMSG.push("<b>missing TYPE !!</b>" );}
                                   
                                    else{ var dpType = getObject(id).common.type;
                                          var valType = typeof getState(id).val;
                                          if(dpType != "mixed" ) {
                                          if(dpType !== valType && !(dpType == 'array' && valType == 'object') /*&& !(dpType =='text' && valType=='string') && !(dpType =='string' && valType=='text')*/ ) {
                                             mylog(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                                             htmlDP.push(id+": "+valType);
                                             htmlMSG.push(dpType );
                            
                                             /* später testing)
                                             console.log("======1=============no type: "+id +"object: "+JSON.stringify(getObject(id)));
                                             if(!getObject(id).common.hasOwnProperty("type")) console.log("--------------kein TYPE: "+id) ;
                                             console.log("======2=============no type: "+id +"object: "+JSON.stringify(getObject(id).common));
                                           */
                                             
                                             }
                                           
                                   }}
                                 /*
                                   if(dpType != valType && !(dpType == 'array' && valType == 'object')) {
                                       log(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                                       htmlDP.push(dpType);
                                       htmlMSG.push(valType);
                                   }*/
                               }
                               });
                               htmlDP.push("<i>ID + IST-WERT</i>");
                               htmlMSG.push("<i>SOLL-WERT</i>");
                               htmlDP.push("-col-<b>geprüfte Instanz</b>");
                               htmlMSG.push("-col-<i><b>"+select+"</b></i>");
                               mylog("fertg" + counter.toString())
                              
                            }
                            
                            //------------------------------------------CHECK  WERTE--------------------------------------------------------
                            
                            function checkWerte(select) {
                               mylog("bin in check Werte");
                               var counter=0; 
                            
                               mylog(select);
                               $(select).each(function (id, i) {
                                   counter++
                                   
                               if (!id.includes('scriptEnabled') && !id.includes('scriptProblem') /* )  && !id.includes('Ereignisliste') && !id.includes('GETPROCESS')*/ ){
                                  //var dpType = getObject(id).common.type;
                                   try {
                                   var valType =  getState(id).val;
                                   } catch (e) {console.log("------------ERROR: "+e)}
                            
                            
                                  // if(dpType != "mixed" ) {}
                            
                                       if(valType === null) {mylog(id + ': Datenpunkttyp: ' /*+ dpType */+ ", Wert: "+valType);
                                           htmlDP.push(id);
                                           var ddd = new Date().getTime()-getObject(id).ts;
                                           htmlMSG.push("missing seit " + Math.floor((ddd)/1000/60/60/24)+"d "+Math.floor((ddd)/1000/60/60 %24)+"h "+Math.floor((ddd)/1000/60 %60)+"m ");
                                       } 
                                   
                                
                               }
                               });
                             
                                mylog("bin raus aus check Werte");
                              
                            }
                            //---------------------------------------------------------------------------------------------------------------------
                            
                            
                            function mylog(message) {
                              if(mylogs)
                                  console.log(message);
                            }
                            
                            //------------------------------------------Zähle Objecte der  INSTANZEN--------------------------------------------------------
                            function countDP(idb){
                               mylog("bin richtig in count");
                               var counter4=0;
                            
                               $(idb+".*").each(function(id, i) {
                               counter4++; })
                            
                            mylog(idb+counter4);
                            htmlDP.unshift(idb);
                            htmlMSG.unshift(counter4.toString());
                            counterAll=counterAll+counter4;
                            mylog("bin raus aus count");
                            }
                            
                            //----------------------------------------------Direct Suchen
                            
                            on({id:dpPrefix + "ProofingDatapoints.OrdnerCheck", change: "any"}, function (obj) {
                               
                                directSearch=true;
                                 instanzArrHelp=[];
                                setState(dpPrefix + "ProofingDatapoints.RunScript",true);
                            
                            
                                });
                            
                            //-----------------------------------------------SCHALTER MAIN------------------------------------------------
                            on({id:dpPrefix + "ProofingDatapoints.RunScript",  val: true}, function (obj) { 
                               let java= getState(dpPrefix + "ProofingDatapoints.JavaInstanzCheck").val;
                               let instanzAnzahl= getState(dpPrefix + "ProofingDatapoints.ObjectAnzahlCheck").val;
                               let monster= getState(dpPrefix + "ProofingDatapoints.MonsterSearch").val;
                               var ohneInstanz = getState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige").val;
                               var endehtmlConst=   "<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\">Letztes File Update: "+formatDate(getDateObject((parseFloat((new Date().getTime())))), "SS:mm:ss")+"</p>";
                               var endehtmlDPConst=   "<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\">Letztes Table Update: "+formatDate(getDateObject((parseFloat((new Date().getTime())))), "SS:mm:ss")+"</p>";
                               setState(dpPrefix + "ProofingDatapoints.ScriptVersion",versionNr);
                               htmlHelper="";
                               htmlHelperFile="";
                               setState(dpPrefix + "ProofingDatapoints.HTMLTable",htmlReset+endehtml+htmlError);
                               writeFile(null, "/ProofingDatapoints/htmlputz.html" ,htmlReset+endehtml+htmlError+"</body>", function (error) {mylog('file written'); });
                              
                               counterAll=0;
                               instanzArrHelp=[];
                               allInstArr=[];
                            
                            
                            setStateDelayed(dpPrefix + "ProofingDatapoints.RunScript",false,2500);
                            
                            htmlDP=[];
                            htmlMSG=[];
                            
                            instanzCount();  //überprüft instanzen und stellt allInstArr her
                            
                            htmlDP.push("-col-<b>INSTANZ INFO</b>"); htmlMSG.push(""); htmlDP.push(""); htmlMSG.push("");
                            mylog(instanzArr.length+"==================="+instanzArr.toString());
                            
                            
                            if (monster) {instanzArrHelp=allInstArr;} else {instanzArrHelp=instanzArr}  //ACHTUNG MONSTERSEARCH
                            if (directSearch) {instanzArrHelp=[]; instanzArrHelp.push(getState(dpPrefix + "ProofingDatapoints.OrdnerCheck").val);}
                            
                            for(let name in instanzArrHelp){
                               checkWerte(instanzArrHelp[name]+".*")                   //checkt alle werte in intanzArr
                                mylog("!!!!!!!!!!!!!!!!!!!!:  "+instanzArrHelp[name]);}
                            
                                if (instanzAnzahl){
                                      htmlDP.unshift(""); htmlMSG.unshift("");htmlDP.unshift("<b>OBJECTE IN INSTANZ</b>"); htmlMSG.unshift("Anzahl"); 
                                       
                                      for(let name in instanzArrHelp){
                                        countDP(instanzArrHelp[name]);mylog("bin in zhlen");}
                                        if (java && !monster) countDP("javascript")
                                      htmlDP.unshift("-col-<b>GESAMT GEPRÜFTE OBJECTE IN INSTANZEN</b>"); htmlMSG.unshift("-col-<b>"+counterAll.toString()+"</b>"); 
                                      
                                      }
                                      mylog("=============: "+counterAll);
                            
                            if (java && !monster && !ohneInstanz && !directSearch) checkWerte('javascript.*');                //checkt alle javainstanzen
                            
                            
                             htmlDP.push("-col-<b>ID's OHNE WERT:</b>");
                             htmlMSG.push("");
                            
                            for(let name in instanzArrHelp){
                               checkTypes(instanzArrHelp[name]+".*")
                               mylog("!!!!!!!!!!!!!!!!!!!!:  "+instanzArrHelp[name])};
                                 htmlDP.push("");
                                 htmlMSG.push("");
                                 htmlDP.push("-col-<b>IDs MIT FALSCHEN TYPE:</b>");
                                 htmlMSG.push("");
                            
                            
                             if (java && !monster && !ohneInstanz && !directSearch ) checkTypes('javascript.*');
                            
                            for(var i= htmlDP.length-1; i>-1; i--) {
                                let htmlDPVis; let htmlDPFile;let htmlMSGVis;let htmlMSGFile;
                                  if(htmlDP[i].includes("-col-")) {htmlDPVis=htmlDP[i].replace("-col-", (htmlHeadersDP+">"));  htmlDPVis=" "+htmlDPVis } else {htmlDPVis=">"+htmlDP[i]}
                                  if(htmlMSG[i].includes("-col-")) {htmlMSGVis=htmlMSG[i].replace("-col-", (htmlHeadersDP+">"));htmlMSGVis=" "+htmlMSGVis } else {htmlMSGVis=">"+htmlMSG[i]}
                                  htmlHelper= htmlHelper+"<tr><td"+htmlDPVis+"&ensp;&ensp;</td><td"+htmlMSGVis+"&ensp;&ensp;</td></tr>"
                            
                                //  if(htmlDP[i].includes("-col-")) {htmlDP[i]=htmlDP[i].replace("-col-", (htmlHeaders+">")); htmlDPFile=htmlDP[i]; htmlDPFile= " "+htmlDPFile ; } else {htmlDPFile=">"+htmlDP[i]}
                                        if(htmlDP[i].includes("-col-")) {htmlDPFile=htmlDP[i].replace("-col-", (htmlHeaders+">"));  htmlDPFile= " "+htmlDPFile ; } else {htmlDPFile=">"+htmlDP[i]}
                            
                                  if(htmlMSG[i].includes("-col-")) {htmlMSGFile=htmlMSG[i].replace("-col-", (htmlHeaders+">")); htmlMSGFile=" "+htmlMSGFile; } else {htmlMSGFile=">"+htmlMSG[i]}    
                                  htmlHelperFile= htmlHelperFile+"<tr><td"+htmlDPFile+"&ensp;&ensp;</td><td"+htmlMSGFile+"&ensp;&ensp;</td></tr>"
                            }
                               var   endehtml=endehtmlConst;
                               var   endehtmlDP=endehtmlDPConst;                       
                                
                            
                               if (monster){endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Monster Suche wird automatisch  deaktiviert !!!</i></p>"+endehtml;
                                         endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! ACHTUNG: SYSTEM WIRD BELASTET !!! </br></br>!!! Monster Suche wird automatisch  deaktiviert !!! </br></br> BERICHT/AUSWERTUNG NUR ÜBER WEBSEITE</i></p>"+endehtmlDP;}
                            
                            
                               if (!instanzAnzahl){endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne DatenpunktZählung !!! kann enabled werden</i></p>"+endehtml;
                                         endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne DatenpunktZählung !!! kann enabled werden</i></p>"+endehtmlDP;}
                            
                               if (!java){ endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne Javascript Instanzen !!! kann enabled werden</i></p>"+endehtml;
                                         endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne Javascript Instanzen !!! kann enabled werden</i></p>"+endehtmlDP;}
                               
                               if(!monster) { setStateDelayed(dpPrefix + "ProofingDatapoints.HTMLTable",endehtmlDP+"<table>"+htmlHelper,900);} else{setStateDelayed(dpPrefix + "ProofingDatapoints.HTMLTable",endehtmlDP,900);}
                              
                               console.log("================================schreibe file")  ; 
                               if(true)  writeFile(null, "/ProofingDatapoints/htmlputz.html" ,format+endehtml+htmlTable+htmlHelperFile+"</table></body>", function (error) { mylog('file written'); });
                            
                              // endehtml=endehtmlConst;
                              // endehtmlDP=endehtmlDPConst;
                            
                               setState(dpPrefix + "ProofingDatapoints.MonsterSearch",false);  //setzt monstersearch zurück
                              directSearch=false;
                            
                            
                            });
                            
                            

                            sigi234 1 Reply Last reply Reply Quote 0
                            • sigi234
                              sigi234 Forum Testing Most Active @liv-in-sky last edited by sigi234

                              @liv-in-sky

                              Html wurde nicht erstellt. Vis schon.

                              Das Skript musst 2 Mal gestartet werden, beim 1. Mal kommt das:

                              Screenshot (329).png

                              liv-in-sky 3 Replies Last reply Reply Quote 0
                              • liv-in-sky
                                liv-in-sky @sigi234 last edited by

                                @sigi234 hättest du auch das große log ? ich bekomm den fehler mit zeile 291 nicht zusammen - der fehler kommt beim aktivieren/starten oder beim ausführen des script durch runScript=true?

                                mach doch auch mal bitte einen test mit dem directSearch - siehe erster post

                                1 Reply Last reply Reply Quote 0
                                • liv-in-sky
                                  liv-in-sky @sigi234 last edited by

                                  @sigi234 ich kann den fehler nachvollziehen - arbeite daran

                                  1 Reply Last reply Reply Quote 0
                                  • liv-in-sky
                                    liv-in-sky @sigi234 last edited by liv-in-sky

                                    @sigi234

                                    bitte nochmal testen - sorry dafür - aber manchmal ist der wurm drin

                                    // @Liv-in-sky Okt.  2019
                                    
                                    
                                    
                                    
                                                                              // WICHTIG
                                                                              // hier muss die instanz der eigenen datenpunkte angegeben werden oder zusätzlich, die man prüfen möchte    , "alexa2.0"
                                                                              //oder auch nur einzelne ornder in der datenstruktur z.b. "javascript.2.WLANUnifi"
                                    const instanzArr=[ "EigeneDatenpunkte.0"];    
                                                                              // beispiel const instanzArr=[ "eigeneDatenpunkte.0", "ping.0",];
                                    
                                    var color_in_table="black"         // Farbe text in webseite
                                    let schriftart="Helvetica";        // möglich: Helvetica,Serif
                                    var color_gradient1="#819FF7";     // Hintergrund webseite 
                                    var colorHeadlines="darkblue";     // Farbe Überschriften in der VIS Anzeige
                                    var colorHeadlinesDP="#36d5ec ";   // Farbe Überschriften in der WebSeite Anzeige     
                                    var warnFarbe = "#36d5ec";         //Farbe für Warnungen in vis und Webseite
                                    
                                    
                                    //------------------------------------------AB HIER NICHTS ÄNDERN--------------------------------------------------------
                                    
                                    
                                    
                                    const versionNr = "15102019-1.1"
                                    const warnColor = warnFarbe ;
                                    
                                    const format = "<!DOCTYPE html><html lang=\"de\"><head><title>Putzer</title><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head><body>";
                                    const htmlTable="<table style=\"color:"+color_in_table+";text-align:left; font-family:"+schriftart+";background-image: linear-gradient(67deg,transparent,"+color_gradient1+");\">";
                                    const htmlReset="<p style=\"color:red;font-family:"+schriftart+";\"><i>!!! ohne Javascript Instanzen !!! kann enabled werden</i></p>"
                                    const htmlHeaders = "style=\"color:"+colorHeadlines+";\""; 
                                    const htmlHeadersDP = "style=\"color:"+colorHeadlinesDP+";\""; 
                                    
                                    //  var htmlOhneAnzahl="<p style=\"color:red;font-family:"+schriftart+";\"><i>!!! ohne DatenpunktZählung !!! kann enabled werden</i></p>"
                                    const htmlError="<p style=\"color:red;font-family:"+schriftart+";\"><i>Script hat Fehler - bitte Log checken !!!</i></p>"
                                    var allInstArr=[];
                                    var  instanzArrHelp=[];
                                    const dpPrefix = "javascript."+ instance +".";
                                    var mylogs=false;
                                    var htmlDP=[];
                                    var htmlMSG=[];
                                    var counterAll=0;
                                    var directSearch=false;
                                    var switchOn=false;
                                    
                                    
                                    var htmlHelper="";
                                    var htmlHelperFile="";
                                    
                                    createState(dpPrefix + "ProofingDatapoints.HTMLTable", { name: 'HTMLTable',  type: 'string', read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.ScriptVersion", versionNr,{ name: 'ScriptVersion',  type: 'string', read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.RunScript",false, { name: 'RunScript',  type: 'boolean', role:"switch", read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.JavaInstanzCheck", true,{ name: 'JavaInstanzCheck',  type: 'boolean', role:"switch", read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.ObjectAnzahlCheck", true,{ name: 'ObjectAnzahlCheck',  type: 'boolean', role:"switch", read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.MonsterSearch", false,{ name: 'MonsterSearch',  type: 'boolean', role:"switch", read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige", false,{ name: 'ohneInstanzAnzeige',  type: 'boolean', role:"switch", read:  true,  write: true,});
                                    createState(dpPrefix + "ProofingDatapoints.OrdnerCheck", "", { name: 'OrdnerCheck',  type: 'string', read:  true,  write: true,});
                                    
                                    
                                    //------------------------------------------CHECK INSTANZEN--------------------------------------------------------
                                    
                                    function instanzCount(){
                                      var ohneInstanz = getState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige").val;
                                      
                                       var counter=0; var counter2=0;var counter3=0; 
                                    $('system.adapter.*.alive').each(function(id, i) {
                                    
                                    
                                        var ida = id.split('.');
                                         allInstArr.push(ida[2]+"."+ida[3]);
                                    
                                      if (!ohneInstanz && !directSearch) {
                                       
                                       if(!id.includes("vis")){
                                       
                                    
                                       counter++;
                                    
                                       if (getState(id).val==null) {;counter2++; mylog(ida[2]+ida[3]+"--------------------der hier wurde nie gestartet"); 
                                          htmlDP.push(ida[2]+"."+ida[3]);
                                          htmlMSG.push("Instanzen ohne Werte");} //else{instanzArr.push(ida[2]+"."+ida[3])}
                                       if (getState(id).val==false) {counter3++;mylog(ida[2]+ida[3]+"-----------------------der hier ist ausgeschalten"); 
                                          htmlDP.push(ida[2]+"."+ida[3]);
                                          htmlMSG.push("nicht aktiviert");} /*else{instanzArr.push(ida[2]+"."+ida[3])}*/
                                       }}
                                    });
                                     if (!ohneInstanz) {
                                    mylog("______________________________________________Anzahl Instanzen: " + counter.toString());
                                    htmlDP.push("");
                                    htmlMSG.push("");
                                    htmlDP.push("Anzahl Instanzen");
                                    htmlMSG.push(counter.toString());
                                    
                                    mylog("______________________________________________Anzahl gestoppter Instanzen ohne Werte: " + counter2.toString())
                                    htmlDP.push("Instanzen ohne Werte");
                                    htmlMSG.push(counter2.toString());
                                    htmlDP.push("Instanzen nicht aktiviert");
                                    htmlMSG.push(counter3.toString());
                                    
                                     }
                                    
                                    }
                                    
                                    
                                    //------------------------------------------CHECK ZUORDNUNG--------------------------------------------------------
                                    
                                    function checkTypes(select) {
                                        mylog("bin in check types");
                                       var counter=0; 
                                       htmlMSG.push("");
                                       htmlDP.push("");
                                       var sub= select.substring(select.length-1, select.length); log("---------: "+sub);log("----------select: "+select);
                                       mylog(select)
                                       $(select).each(function (id, i) {
                                           counter++
                                    
                                           
                                              
                                       if (!id.includes('scriptEnabled') && !id.includes('scriptProblem')  && getState(id).val !== null /*&& !id.includes('Log-Script')  && !id.includes('Ereignisliste') && !id.includes('GETPROCESS')*/ ){
                                    
                                           if (!JSON.stringify(getObject(id)).includes("type")) {
                                          
                                                var valType = typeof getState(id).val;
                                                 htmlDP.push(id+": "+valType);
                                                 htmlMSG.push("<b>missing TYPE !!</b>" );}
                                           
                                            else{ var dpType = getObject(id).common.type;
                                                  var valType = typeof getState(id).val;
                                                  if(dpType != "mixed" ) {
                                                  if(dpType !== valType && !(dpType == 'array' && valType == 'object') /*&& !(dpType =='text' && valType=='string') && !(dpType =='string' && valType=='text')*/ ) {
                                                     mylog(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                                                     htmlDP.push(id+": "+valType);
                                                     htmlMSG.push(dpType );
                                    
                                                     /* später testing)
                                                     console.log("======1=============no type: "+id +"object: "+JSON.stringify(getObject(id)));
                                                     if(!getObject(id).common.hasOwnProperty("type")) console.log("--------------kein TYPE: "+id) ;
                                                     console.log("======2=============no type: "+id +"object: "+JSON.stringify(getObject(id).common));
                                                   */
                                                     
                                                     }
                                                   
                                           }}
                                         /*
                                           if(dpType != valType && !(dpType == 'array' && valType == 'object')) {
                                               log(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                                               htmlDP.push(dpType);
                                               htmlMSG.push(valType);
                                           }*/
                                       }
                                       });
                                       htmlDP.push("<i>ID + IST-WERT</i>");
                                       htmlMSG.push("<i>SOLL-WERT</i>");
                                       htmlDP.push("-col-<b>geprüfte Instanz</b>");
                                       htmlMSG.push("-col-<i><b>"+select+"</b></i>");
                                       mylog("fertg" + counter.toString())
                                      
                                    }
                                    
                                    //------------------------------------------CHECK  WERTE--------------------------------------------------------
                                    
                                    function checkWerte(select) {
                                       mylog("bin in check Werte");
                                       var counter=0; 
                                    
                                       mylog(select);
                                       $(select).each(function (id, i) {
                                           counter++
                                           
                                       if (!id.includes('scriptEnabled') && !id.includes('scriptProblem') /* )  && !id.includes('Ereignisliste') && !id.includes('GETPROCESS')*/ ){
                                          //var dpType = getObject(id).common.type;
                                           
                                           var valType =  getState(id).val;
                                          
                                    
                                    
                                          // if(dpType != "mixed" ) {}
                                    
                                               if(valType === null) {mylog(id + ': Datenpunkttyp: ' /*+ dpType */+ ", Wert: "+valType);
                                                   htmlDP.push(id);
                                                   var ddd = new Date().getTime()-getObject(id).ts;
                                                   htmlMSG.push("missing seit " + Math.floor((ddd)/1000/60/60/24)+"d "+Math.floor((ddd)/1000/60/60 %24)+"h "+Math.floor((ddd)/1000/60 %60)+"m ");
                                               } 
                                           
                                        
                                       }
                                       });
                                     
                                        mylog("bin raus aus check Werte");
                                      
                                    }
                                    //---------------------------------------------------------------------------------------------------------------------
                                    
                                    
                                    function mylog(message) {
                                      if(mylogs)
                                          console.log(message);
                                    }
                                    
                                    //------------------------------------------Zähle Objecte der  INSTANZEN--------------------------------------------------------
                                    function countDP(idb){
                                       mylog("bin richtig in count");
                                       var counter4=0;
                                    
                                       $(idb+".*").each(function(id, i) {
                                       counter4++; })
                                    
                                    mylog(idb+counter4);
                                    htmlDP.unshift(idb);
                                    htmlMSG.unshift(counter4.toString());
                                    counterAll=counterAll+counter4;
                                    mylog("bin raus aus count");
                                    }
                                    
                                    //----------------------------------------------Direct Suchen
                                    
                                    on({id:dpPrefix + "ProofingDatapoints.OrdnerCheck", ack: false, change: "any"}, function (obj) {
                                     
                                        directSearch=true;
                                         instanzArrHelp=[];
                                        setState(dpPrefix + "ProofingDatapoints.RunScript",true);
                                    
                                       
                                        });
                                    
                                    //-----------------------------------------------SCHALTER MAIN------------------------------------------------
                                    on({id:dpPrefix + "ProofingDatapoints.RunScript", ack: false, val: true}, function (obj) { 
                                      
                                       let java= getState(dpPrefix + "ProofingDatapoints.JavaInstanzCheck").val;
                                       let instanzAnzahl= getState(dpPrefix + "ProofingDatapoints.ObjectAnzahlCheck").val;
                                       let monster= getState(dpPrefix + "ProofingDatapoints.MonsterSearch").val;
                                       var ohneInstanz = getState(dpPrefix + "ProofingDatapoints.ohneInstanzAnzeige").val;
                                       var endehtmlConst=   "<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\">Letztes File Update: "+formatDate(getDateObject((parseFloat((new Date().getTime())))), "SS:mm:ss")+"</p>";
                                       var endehtmlDPConst=   "<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\">Letztes Table Update: "+formatDate(getDateObject((parseFloat((new Date().getTime())))), "SS:mm:ss")+"</p>";
                                       setState(dpPrefix + "ProofingDatapoints.ScriptVersion",versionNr);
                                       htmlHelper="";
                                       htmlHelperFile="";
                                       setState(dpPrefix + "ProofingDatapoints.HTMLTable",htmlReset+endehtml+htmlError);
                                       writeFile(null, "/ProofingDatapoints/htmlputz.html" ,htmlReset+endehtml+htmlError+"</body>", function (error) {mylog('file written'); });
                                      
                                       counterAll=0;
                                       instanzArrHelp=[];
                                       allInstArr=[];
                                    
                                    
                                    setStateDelayed(dpPrefix + "ProofingDatapoints.RunScript",false,2500);
                                    
                                    htmlDP=[];
                                    htmlMSG=[];
                                    
                                    instanzCount();  //überprüft instanzen und stellt allInstArr her
                                    
                                    htmlDP.push("-col-<b>INSTANZ INFO</b>"); htmlMSG.push(""); htmlDP.push(""); htmlMSG.push("");
                                    mylog(instanzArr.length+"==================="+instanzArr.toString());
                                    
                                    
                                    if (monster) {instanzArrHelp=allInstArr;} else {instanzArrHelp=instanzArr}  //ACHTUNG MONSTERSEARCH
                                    if (directSearch) {instanzArrHelp=[]; instanzArrHelp.push(getState(dpPrefix + "ProofingDatapoints.OrdnerCheck").val);}
                                    
                                    for(let name in instanzArrHelp){
                                       checkWerte(instanzArrHelp[name]+".*")                   //checkt alle werte in intanzArr
                                        mylog("!!!!!!!!!!!!!!!!!!!!:  "+instanzArrHelp[name]);}
                                    
                                        if (instanzAnzahl){
                                              htmlDP.unshift(""); htmlMSG.unshift("");htmlDP.unshift("<b>OBJECTE IN INSTANZ</b>"); htmlMSG.unshift("Anzahl"); 
                                               
                                              for(let name in instanzArrHelp){
                                                countDP(instanzArrHelp[name]);mylog("bin in zhlen");}
                                                if (java && !monster) countDP("javascript")
                                              htmlDP.unshift("-col-<b>GESAMT GEPRÜFTE OBJECTE IN INSTANZEN</b>"); htmlMSG.unshift("-col-<b>"+counterAll.toString()+"</b>"); 
                                              
                                              }
                                              mylog("=============: "+counterAll);
                                    
                                    if (java && !monster && !ohneInstanz && !directSearch) checkWerte('javascript.*');                //checkt alle javainstanzen
                                    
                                    
                                     htmlDP.push("-col-<b>ID's OHNE WERT:</b>");
                                     htmlMSG.push("");
                                    
                                    for(let name in instanzArrHelp){
                                       checkTypes(instanzArrHelp[name]+".*")
                                       mylog("!!!!!!!!!!!!!!!!!!!!:  "+instanzArrHelp[name])};
                                         htmlDP.push("");
                                         htmlMSG.push("");
                                         htmlDP.push("-col-<b>IDs MIT FALSCHEN TYPE:</b>");
                                         htmlMSG.push("");
                                    
                                    
                                     if (java && !monster && !ohneInstanz && !directSearch ) checkTypes('javascript.*');
                                    
                                    for(var i= htmlDP.length-1; i>-1; i--) {
                                        let htmlDPVis; let htmlDPFile;let htmlMSGVis;let htmlMSGFile;
                                          if(htmlDP[i].includes("-col-")) {htmlDPVis=htmlDP[i].replace("-col-", (htmlHeadersDP+">"));  htmlDPVis=" "+htmlDPVis } else {htmlDPVis=">"+htmlDP[i]}
                                          if(htmlMSG[i].includes("-col-")) {htmlMSGVis=htmlMSG[i].replace("-col-", (htmlHeadersDP+">"));htmlMSGVis=" "+htmlMSGVis } else {htmlMSGVis=">"+htmlMSG[i]}
                                          htmlHelper= htmlHelper+"<tr><td"+htmlDPVis+"&ensp;&ensp;</td><td"+htmlMSGVis+"&ensp;&ensp;</td></tr>"
                                    
                                        //  if(htmlDP[i].includes("-col-")) {htmlDP[i]=htmlDP[i].replace("-col-", (htmlHeaders+">")); htmlDPFile=htmlDP[i]; htmlDPFile= " "+htmlDPFile ; } else {htmlDPFile=">"+htmlDP[i]}
                                                if(htmlDP[i].includes("-col-")) {htmlDPFile=htmlDP[i].replace("-col-", (htmlHeaders+">"));  htmlDPFile= " "+htmlDPFile ; } else {htmlDPFile=">"+htmlDP[i]}
                                    
                                          if(htmlMSG[i].includes("-col-")) {htmlMSGFile=htmlMSG[i].replace("-col-", (htmlHeaders+">")); htmlMSGFile=" "+htmlMSGFile; } else {htmlMSGFile=">"+htmlMSG[i]}    
                                          htmlHelperFile= htmlHelperFile+"<tr><td"+htmlDPFile+"&ensp;&ensp;</td><td"+htmlMSGFile+"&ensp;&ensp;</td></tr>"
                                    }
                                       var   endehtml=endehtmlConst;
                                       var   endehtmlDP=endehtmlDPConst;                       
                                        
                                    
                                       if (monster){endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Monster Suche wird automatisch  deaktiviert !!!</i></p>"+endehtml;
                                                 endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! ACHTUNG: SYSTEM WIRD BELASTET !!! </br></br>!!! Monster Suche wird automatisch  deaktiviert !!! </br></br> BERICHT/AUSWERTUNG NUR ÜBER WEBSEITE</i></p>"+endehtmlDP;}
                                    
                                    
                                       if (!instanzAnzahl){endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne DatenpunktZählung !!! kann enabled werden</i></p>"+endehtml;
                                                 endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne DatenpunktZählung !!! kann enabled werden</i></p>"+endehtmlDP;}
                                    
                                       if (!java){ endehtml="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne Javascript Instanzen !!! kann enabled werden</i></p>"+endehtml;
                                                 endehtmlDP="<p style=\"color:"+warnColor+"; font-family:"+schriftart+";\"><i>!!! Auswertung ohne Javascript Instanzen !!! kann enabled werden</i></p>"+endehtmlDP;}
                                       
                                       if(!monster) { setStateDelayed(dpPrefix + "ProofingDatapoints.HTMLTable",endehtmlDP+"<table>"+htmlHelper,900);} else{setStateDelayed(dpPrefix + "ProofingDatapoints.HTMLTable",endehtmlDP,900);}
                                      
                                       mylog("================================schreibe file")  ; 
                                       writeFile(null, "/ProofingDatapoints/htmlputz.html" ,format+endehtml+htmlTable+htmlHelperFile+"</table></body>", function (error) { mylog('file written'); });
                                    
                                      // endehtml=endehtmlConst;
                                      // endehtmlDP=endehtmlDPConst;
                                    
                                       setState(dpPrefix + "ProofingDatapoints.MonsterSearch",false);  //setzt monstersearch zurück
                                       directSearch=false;
                                     
                                    });
                                    
                                    

                                    sigi234 1 Reply Last reply Reply Quote 0
                                    • sigi234
                                      sigi234 Forum Testing Most Active @liv-in-sky last edited by

                                      @liv-in-sky sagte in Script - Info über Datenpunkte sammeln:

                                                                                                                                                                                                                                                        // WICHTIG                                                                                                                                                                                                                      // hier muss die instanz der eigenen datenpunkte angegeben werden oder zusätzlich, die man prüfen möchte    , "alexa2.0"                                                                                                                                                                                                                      //oder auch nur einzelne ornder in der datenstruktur z.b. "javascript.2.WLANUnifi"                                                                                                                                                                            const instanzArr=[ "EigeneDatenpunkte.0"];                                                                                                                                                                                                                          // beispiel const instanzArr=[ "eigeneDatenpunkte.0", "ping.0",];                                                                                                                                                                                                                                                                                                                                                         // @Liv-in-sky Okt.  2019
                                      

                                      2 Mal drinnen!

                                      
                                                                                // WICHTIG
                                                                                // hier muss die instanz der eigenen datenpunkte angegeben werden oder zusätzlich, die man prüfen möchte    , "alexa2.0"
                                                                                //oder auch nur einzelne ornder in der datenstruktur z.b. "javascript.2.WLANUnifi"
                                      const instanzArr=[ "EigeneDatenpunkte.0"];    
                                                                                // beispiel const instanzArr=[ "eigeneDatenpunkte.0", "ping.0",];
                                       
                                      // @Liv-in-sky Okt.  2019
                                      
                                      liv-in-sky 1 Reply Last reply Reply Quote 0
                                      • liv-in-sky
                                        liv-in-sky @sigi234 last edited by

                                        @sigi234 bitte rauslöschen - ich mache für heute pause 😞 und habs geändert

                                        aber immerhin hab ich schon mal einen fehler im alexa2 adapter gefunden (wird gefixt) - ist doch schon mal was 🙂

                                        sigi234 1 Reply Last reply Reply Quote 0
                                        • sigi234
                                          sigi234 Forum Testing Most Active @liv-in-sky last edited by sigi234

                                          @liv-in-sky sagte in Script - Info über Datenpunkte sammeln:

                                          bitte rauslöschen

                                          ja,schaut besser aus, kein Fehler im Log.

                                          HTML - leider nein, wird nicht erstellt.

                                          Skript hängt sich auf.....

                                          1 Reply Last reply Reply Quote 0
                                          • liv-in-sky
                                            liv-in-sky last edited by liv-in-sky

                                            @paul53

                                            sorry aber ich muss dich nochmal was fragen - ich versuche multistate datenpunkte zu filtern, die keine number im attribut haben sondern string

                                            ist diese abfrage richtig - sie macht das mit meinen testpunkten aber ich würde gerne deine meinung haben

                                                     if(getObject(id).common.hasOwnProperty("states")){
                                            
                                                     var helpStates= Object.keys(getObject(id).common.states);
                                            
                                                     if (true) { //platz für weitere bedingung
                                                                var alarmString=false;
                                                                for (var i=0;  i  < helpStates.length ;i++){
                                                                     mylog(typeof helpStates[i]); //damit geht es nicht !
                                                                     myog(isNaN(helpStates[i]).toString())  ;
                                                                     if (isNaN(helpStates[i])) alarmString=true; 
                                                                     }  
                                                                if (alarmString){  htmlDP.push(id);
                                                                                   htmlMSG.push("ACHTUNG Multstate must be number")}
                                                                }
                                                     
                                                     }
                                            

                                            Image 4.png

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            801
                                            Online

                                            31.8k
                                            Users

                                            80.0k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript template
                                            11
                                            291
                                            27925
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo