Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Objekte aufräumen

    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

    Objekte aufräumen

    This topic has been deleted. Only users with topic management privileges can see it.
    • liv-in-sky
      liv-in-sky @Guest last edited by liv-in-sky

      @nis ok - geb mir bescheid, wenn du näheres weißt

      ihr kennt euch da besser aus - wenn man einen datenpunkt als auswahlliste anlegt, sieht das wieder anders aus:

      Image 1.png

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

        @liv-in-sky sagte:

        wenn man einen datenpunkt als auswahlliste anlegt, sieht das wieder anders aus:

        Das ist die ebenfalls zulässige String-Schreibweise für states. Wenn man states manuell eingibt, ist diese Schreibweise einfacher zu handhaben.
        Admin berücksichtigt automatisch die Schreibweise. In Javascript sollte man eine Wandlung in ein Objekt vornehmen.

        function statesStr2Obj(states) {
            if (typeof states == 'string') {
                var arr = states.split(';');
                states = {};
                for(var i = 0; i < arr.length; i++) {
                    var ele = arr[i].split(':');
                    states[ele[0]] = ele[1];
                }
            }
            return states;
        }
        
        1 Reply Last reply Reply Quote 0
        • paul53
          paul53 @liv-in-sky last edited by paul53

          @liv-in-sky sagte:

          darin sind object-werte geschrieben obwohl string,number oder boolean im dp deklariert ist

          console.log(typeof null); // ist object 
          

          Wenn leere Datenpunkte beim Typvergleich nicht auftauschen sollen, dann fasse die Prüfungen zusammen.

          function checkTypes(select) {
              $(select).each(function (id, i) {
                  var ida = id.split('.');
                  if(ida[2] != 'scriptEnabled' && ida[2] != 'scriptProblem') {
                      if(getState(id).val === null) console.log(id + ': Leer !');
                      else {
                          var dpType = getObject(id).common.type;
                          var valType = typeof getState(id).val;
                          if(dpType != valType && !(dpType == 'array' && valType == 'object')) {
                              console.log(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                          }
                      }
                  }
              });
          }
          
          checkTypes('javascript.*');
          

          oder filtere die leeren Datenpunkte aus

          function checkTypes(select) {
              $(select).each(function (id, i) {
                  var ida = id.split('.');
                  if(ida[2] != 'scriptEnabled' && ida[2] != 'scriptProblem' && getState(id).val !== null) {
                      var dpType = getObject(id).common.type;
                      var valType = typeof getState(id).val;
                      if(dpType != valType && !(dpType == 'array' && valType == 'object')) {
                          console.log(id + ': Datenpunkttyp: ' + dpType + ', Wert: ' + valType);
                      }
                  }
              });
          }
           
          checkTypes('javascript.*');
          
          liv-in-sky 1 Reply Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @paul53 last edited by

            @paul53 das mit dem ausfiltern gefällt mir

            übrigends muß ich auch fehlende type aussortieren - da schmiert das programm mit error ab

                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")) {
                          mylog("no"+id);
                          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 );}
                            
                    }}
            

            wahrscheinlich noch eine dämliche frage - - der adpter plex hat datenpunkte mit dem type "text" - wo kommt den sowas her ? habe erstmal die combi dpType=text und varType=string ausgeschlossen

            paul53 2 Replies Last reply Reply Quote 0
            • paul53
              paul53 @liv-in-sky last edited by

              @liv-in-sky sagte:

              type "text" - wo kommt den sowas her ?

              Ist unzulässig ! Bitte Issue beim Adapter auf Github erstellen.

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

                @paul53 gilt das auch für type "double" - den habe ich auch gefunden

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

                  @liv-in-sky sagte:

                  gilt das auch für type "double"

                  Ja, es gibt nur 6 gültige Datenpunkt-Typen:

                  • boolean
                  • number
                  • string
                  • object
                  • array
                  • mixed (bitte vermeiden)

                  Als Typ des Wertes existieren nur

                  • boolean
                  • number
                  • string
                  • object
                  • undefined
                  • function
                  liv-in-sky 1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @paul53 last edited by

                    @paul53 danke - mach ich - genau deshalb/dafür sollte ja das script genutzt werden 🙂

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

                      @liv-in-sky sagte:

                      brigends muß ich auch fehlende type aussortieren - da schmiert das programm mit error ab

                      Datenpunkte ohne common.type darf es nicht geben ! Auch dort Issue auf Github erstellen.
                      Um den Error zu vermeiden, erweitere die Abfrage

                              if(!id.includes('scriptEnabled') && !id.includes('scriptProblem') && getState(id).val !== null && getObject(id).common.type) {
                      
                      sigi234 1 Reply Last reply Reply Quote 0
                      • sigi234
                        sigi234 Forum Testing Most Active @paul53 last edited by

                        @paul53
                        @liv-in-sky

                        Da kommen ja Sachen auf. 😁

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

                        Support us

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

                        425
                        Online

                        31.9k
                        Users

                        80.1k
                        Topics

                        1.3m
                        Posts

                        aufräumen objekte admin
                        8
                        100
                        5279
                        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