Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Entwicklung
    4. Adapterentwicklung / Object ID Baum

    NEWS

    • Monatsrückblick - April 2025

    • Minor js-controller 7.0.7 Update in latest repo

    • Save The Date: ioBroker@Smart Living Forum Solingen, 14.06.

    Adapterentwicklung / Object ID Baum

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

      Include this files:

      https://github.com/hometm/ioBroker.vcar … x.html#L24

      https://github.com/hometm/ioBroker.vcar ... x.html#L22

      https://github.com/hometm/ioBroker.vcar ... x.html#L18

      Include this function:

      https://github.com/hometm/ioBroker.vcar ... .html#L135

      and now you can open select ID dialog like here:

      https://github.com/hometm/ioBroker.vcar ... x.html#L81

      1 Reply Last reply Reply Quote 0
      • snador
        snador last edited by

        @BlauerFuchs: Vielen Dank! Ich probiere das aus!

        1 Reply Last reply Reply Quote 0
        • snador
          snador last edited by

          Hallo BlueFox, so ganz hat es noch nicht funktioniert. Es kommt folgender Error (siehe Anhang). Das einbinden der socket.io.js hat den Fehler leider nicht behoben…

          LG
          4236_socket.jpg

          1 Reply Last reply Reply Quote 0
          • Bluefox
            Bluefox last edited by

            @snador:

            Hallo BlueFox, so ganz hat es noch nicht funktioniert. Es kommt folgender Error (siehe Anhang). Das einbinden der socket.io.js hat den Fehler leider nicht behoben…

            LG `
            Ohne Code ist schwer zu sagen.

            1 Reply Last reply Reply Quote 0
            • snador
              snador last edited by

              Ich hab eigentlich nur die Dinge gemacht, die Du mir vorgeschlagen hast und dann testweise mal einen click auf ein Element gelegt. Der Fehler kommt nur beim Click. Code schicke ihn heute Abend hinterher…

              1 Reply Last reply Reply Quote 0
              • snador
                snador last edited by

                socket.emit schmeißt den Fehler…

                 function initSelectId (cb) { :? 
                        if (selectId) return cb(selectId);
                        socket.emit('getObjects', function (err, res) {
                            if (!err && res) {
                                selectId = $('#dialog-select-member').selectId('init',  {
                                    noMultiselect: true,
                                    objects: res,
                                    imgPath:       '../../lib/css/fancytree/',
                                    filter:        {type: 'state'},
                                    name:          'vcard-select-state',
                                    texts: {
                                        select:          _('Select'),
                                        cancel:          _('Cancel'),
                                        all:             _('All'),
                                        id:              _('ID'),
                                        name:            _('Name'),
                                        role:            _('Role'),
                                        room:            _('Room'),
                                        value:           _('Value'),
                                        selectid:        _('Select ID'),
                                        from:            _('From'),
                                        lc:              _('Last changed'),
                                        ts:              _('Time stamp'),
                                        wait:            _('Processing...'),
                                        ack:             _('Acknowledged'),
                                        selectAll:       _('Select all'),
                                        unselectAll:     _('Deselect all'),
                                        invertSelection: _('Invert selection')
                                    },
                                    columns: ['image', 'name', 'role', 'room']
                                });
                                cb && cb(selectId);
                            }
                        });
                    }
                
                1 Reply Last reply Reply Quote 0
                • snador
                  snador last edited by

                  Ansonsten hab ich nur folgendes drin. Ein Klick auf ein Elemente zum testen.

                     $('#select2').click(function () {
                              initSelectId(function (sid) {
                                  sid.selectId('show', $('#object2').val(), function (newId) {
                                      if (newId != $('#object2').val()) {
                                          $('#object2').val(newId);
                                          onChange();
                                      }
                                  });
                              });
                          });
                  
                  1 Reply Last reply Reply Quote 0
                  • snador
                    snador last edited by

                    Ach so. Vielleicht sollte ich noch dazu sagen, dass ich die Funktion nicht im Backend benötige wie der vCard Adapter sondern auf einer Edit Seite im Frontend, ähnlich wie der Vis Adapter. Spielt ggf. ne Rolle bzgl. der einzubindenden Ressourcen…

                    1 Reply Last reply Reply Quote 0
                    • snador
                      snador last edited by

                      Hier noch das aktuelle Testszenario:

                      /**
                       *  ioBroker.nightingale
                       *  https://github.com/ioBroker/ioBroker.nightingale
                       *
                       *  Copyright (c) 2018 Sandro Zimmermann https://github.com/xxx
                       *  License: MIT
                       *
                      */
                      
                      /* jshint browser:--undef */
                      /* jshint browser:true */
                      /* global document */
                      /* global console */
                      /* global session */
                      /* global window */
                      /* global location */
                      /* global setTimeout */
                      /* global clearTimeout */
                      /* global io */
                      /* global systemLang:true */
                      /* global systemLang */
                      /* global _ */
                      /* global can */
                      /* global storage */
                      /* global servConn */
                      /* global systemDictionary:true */
                      /* global systemDictionary */
                      /* global $ */
                      /* global translateAll */
                      /* global jQuery */
                      /* global $ */
                      /* global document */
                      /* jshint -W097 */// jshint strict:false
                      
                      'use strict';
                      
                      var selectId;
                      
                      // Dict ///////////////////////////////////////////////////
                      $.extend(systemDictionary, {
                          'Views': {
                          	'en': 'Views',
                          	'de': 'Views',
                          	'ru': 'Страницы'
                          }
                      });
                      
                      // NGL ///////////////////////////////////////////////////
                      var ngl = {
                      
                      	version: "0.0.1",
                          requiredServerVersion: '0.0.0',
                          enums:        {},
                          objects:      {},
                          states:       {},
                          root:         [],
                          refresh:      false,
                          isFirstTime:  true,
                          conn:         servConn,
                          editMode:     false,
                          queueStates:  [],
                          updateStates: [],
                          ids:          [],
                          user:         'admin',
                          defaultInvisibleRoles: ['inhibit', 'button', 'action', 'timer'],
                          defaultInvisibleNames: ['TIMER_ON', 'RELOCK_DELAY', 'OLD_VALUE', 'STATE_UNCERTAIN', 'DECISION_VALUE', 'ADJUSTING_DATA' , 'ADJUSTING_COMMAND', 'INSTALL_TEST'],
                          ignoreIndicators: ['indicator.updates', 'indicator.state'],
                          lastTimes:    [],
                          activePage:   null,
                          erasePage:    {},
                          isMobile:     null,
                      
                          // Init ///////////////////////////////////////////////////
                      
                          init: function(){
                      
                          	console.log('init');
                      
                          	ngl.initConn();
                      
                          	console.log(ngl.conn);
                          	console.log(ngl.conn._socket);
                      
                          	ngl.conn.getObjects(function (err, data) {
                                          vis.objects = data;
                              });
                      
                          	$('#testfield').click(function () {
                                  ngl.initSelectId(function (sid) {
                                      sid.selectId('show', $('#testfield').val(), function (newId) {
                                          if (newId != $('#testfield').val()) {
                                              $('#testfield').val(newId);
                                              onChange();
                                          }
                                      });
                                  });
                              });
                      
                          },
                      
                          // Connection ///////////////////////////////////////////////////
                      
                          initConn: function(){
                      
                          	ngl.conn.namespace   = 'nightingale.0';
                      	    ngl.conn._useStorage = false;
                      	    var states = [];
                      	    ngl.conn.init({
                      	        name:          		'',  			// optional - default 'vis.0'
                      	        connLink:      		'',  	// optional URL of the socket.io adapter
                      	        socketSession: 		''           				// optional - used by authentication
                      	    },{
                      	        onConnChange: function (isConnected) {
                      	            if (isConnected) {
                      	                console.log('connected');
                      	                ngl.conn.getStates(function (err, _states) {
                      	                    var count = 0;
                      	                    for (var id in _states) {
                      	                        count++;
                      	                    }
                      	                    console.log('Received ' + count + ' states.');
                      	                    states = _states;
                      	                });
                      	            } else {
                      	                console.log('disconnected');
                      	            }
                      	        },
                      	        onRefresh: function () {
                      	            window.location.reload();
                      	        },
                      	        onUpdate: function (id, state) {
                      	            setTimeout(function () {
                      	                console.log('NEW VALUE of ' + id + ': ' + JSON.stringify(state));
                      	                states[id] = state;
                      	            }, 0);
                      	        },
                      	        onError: function (err) {
                      	            window.alert(_('Cannot execute %s for %s, because of insufficient permissions', err.command, err.arg), _('Insufficient permissions'), 'alert', 600);
                      	        }
                      	    });
                      
                          },
                      
                          // Object Tree ///////////////////////////////////////////////////
                      
                          initSelectId: function(cb) {
                              if (selectId) return cb(selectId);
                              ngl.conn._socket.emit('getObjects', function (err, res) {
                                  if (!err && res) {
                                      selectId = $('#dialog-select-member').selectId('init',  {
                                          noMultiselect: true,
                                          objects: res,
                                          imgPath:       '../../lib/css/fancytree/',
                                          filter:        {type: 'state'},
                                          name:          'vcard-select-state',
                                          texts: {
                                              select:          _('Select'),
                                              cancel:          _('Cancel'),
                                              all:             _('All'),
                                              id:              _('ID'),
                                              name:            _('Name'),
                                              role:            _('Role'),
                                              room:            _('Room'),
                                              value:           _('Value'),
                                              selectid:        _('Select ID'),
                                              from:            _('From'),
                                              lc:              _('Last changed'),
                                              ts:              _('Time stamp'),
                                              wait:            _('Processing...'),
                                              ack:             _('Acknowledged'),
                                              selectAll:       _('Select all'),
                                              unselectAll:     _('Deselect all'),
                                              invertSelection: _('Invert selection')
                                          },
                                          columns: ['image', 'name', 'role', 'room']
                                      });
                                      cb && cb(selectId);
                                  }
                              });
                          }
                      
                          // Helpers ///////////////////////////////////////////////////
                      
                      };
                      
                      // Ready ///////////////////////////////////////////////////
                      (function ($) {
                          $(document).ready(function () {
                              ngl.init();
                          });
                      })(jQuery);
                      
                      
                          <title>Titel</title>
                      
                      ### Nightingale Adapter
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • snador
                        snador last edited by

                        So, ich hab mal den Code oben drüber aktualisiert. Sorry aber ich blicke insgesamt noch nicht wirklich durch, deshalb die ganze Anfängerfragen. Ich versuche gerade im Adapter "Frontend" (www) eine Seite zu erstellen (ähnlich Vis Edit) die eine Connection erstellt und SocketIO zum Laufen bringt. Danach möchte ich gerne den Object Baum holen. Nur mal so für den Anfang. Vielleicht versteh ich es irgendwann 🙂 Ich hab mir die grundsätzliche Vorgehensweise in diversen Adaptern abgeschaut.

                        Nun zu meinen Fragen.

                        1: Muss ich die Connection im www überhaupt noch initialisieren oder steht die schon wenn der Adapter läuft? Ist es so halbweg korrekt?

                        2: Die Connection scheint erfolgreich zu laufen aber es kommt die Meldung "socket.io not initialized" (Meldung kommt erst wenn ngl.conn.getObjects aufgerufen wird). Wie mache ich das und muss ich überhaupt?

                        3: In der Funktion initSelectId bringt der Aufruf socket.emit() den weiter oben erwähnten Fehler aber auch ngl.conn._socket.emit() liefert zurück das _socket logischerweise null ist 🙂 Führe ich auf Punkt [2] zurück…

                        4: Ist mein grober Ansatz überhaupt korrekt?

                        Vielleicht kann einer der Wissenden mal drüber schauen und dem Noob etwas auf die Sprünge helfen.

                        Vielen Dank!
                        4236_console.jpg

                        1 Reply Last reply Reply Quote 0
                        • snador
                          snador last edited by

                          Neuer Stand: Ich habe den socket.io Adapter installiert und läuft es erst einmal. Nun fragen ich mich allerdings warum andere Adapter auch laufen ohne das der Socket.io Adapter installiert war? Gibt es noch eine andere (eventuell günstigere) Variante ohne den socket.io Adapter zu installieren? Und ist es normal das in der Console minutenlang alle gefundenen Objekte durchlaufen?

                          Fragen über Fragen, sorry 🙂

                          1 Reply Last reply Reply Quote 0
                          • AlCalzone
                            AlCalzone Developer last edited by

                            @snador:

                            Gibt es noch eine andere (eventuell günstigere) Variante ohne den socket.io Adapter zu installieren? `
                            Möglicherweise mit dem Web-Adapter und seiner integrierten socket.io-Instanz.

                            1 Reply Last reply Reply Quote 0
                            • snador
                              snador last edited by

                              Ich habe jetzt noch was anderes ausprobiert 🙂 Ich habe mir aus einem anderen Adapter den Part "_socket/info.js" herauskopiert und eingebunden und den socket.io Adapter wieder deinstalliert. Und siehe da es geht 🙂 Kann mir Jemand erklären warum und ob die Vorgehensweise so einigermaßen korrekt ist.

                              
                                  <title>Titel</title>
                              
                              

                              Aber noch eine andere Frage: Muss das so sein, dass in der Console unablässig die Objekte laufen? Siehe Anhang:
                              4236_console.jpg

                              1 Reply Last reply Reply Quote 0
                              • simatec
                                simatec Developer Most Active last edited by

                                Ich krame hier mal den alten Thread wieder raus.
                                Aktuell habe ich ein vergleichbares Problem.

                                Ich bekomme die Object-ID Dialog auf biegen und brechen nicht aufgerufen.
                                Hier mal der aktuelle Stand vom Github mit meinen Versuchen.
                                https://github.com/simatec/ioBroker.shuttercontrol/blob/master/admin/index_m.html

                                Hab keine Idee, was ich noch probieren kann.

                                1 Reply Last reply Reply Quote 0
                                • simatec
                                  simatec Developer Most Active last edited by

                                  edit: Die Dialogbox mit Oject-Baum öffnet jetzt.
                                  Wie man allerdings die ausgewählte ID nun in die neu angelegte Tabellenzeile bekommt, erschließt sich mir garnicht.
                                  Gibt es irgendwo eine Doku zu den Aufbau der Tabellen?

                                  1 Reply Last reply Reply Quote 0
                                  • blauholsten
                                    blauholsten Developer last edited by

                                    Moin,

                                    Wenn du dich etwas gedulden kannst, schick ich dir nachher wie das geht.
                                    Ich habe mich vor einiger Zeit damit beschäftigt, wenn ich mich richtig erinnere haben blufox seine links nicht wirklich funktioniert.

                                    simatec 1 Reply Last reply Reply Quote 0
                                    • simatec
                                      simatec Developer Most Active @blauholsten last edited by

                                      @blauholsten
                                      Perfekt ... ☺

                                      1 Reply Last reply Reply Quote 0
                                      • blauholsten
                                        blauholsten Developer last edited by

                                        Hi,

                                        hatte vorhin nicht richtig gelesen, hast ein PR den kannst du mal testen...

                                        simatec 1 Reply Last reply Reply Quote 0
                                        • simatec
                                          simatec Developer Most Active @blauholsten last edited by

                                          @blauholsten
                                          Der PR bringt so leider nix.
                                          Bin aber auch schon etwas weiter gekommen.
                                          ID‘s werden nun geschrieben.
                                          Muss allerdings nochmal schauen, warum über den edit Button nur dann der Dialog Object Baum aufgerufen wird, solang ich keine nein Zeile in der Tabelle hinzufüge.
                                          Wenn ich eine neue Zeile hinzufüge, geht edit erst nach dem speichern.
                                          Ist allerdings noch nicht im Github gepusht

                                          1 Reply Last reply Reply Quote 0
                                          • blauholsten
                                            blauholsten Developer last edited by

                                            Hi,

                                            habe dein Adapter mal kurz installiert, bekomme folgende Meldung wenn ich die ID öffnen will....

                                            Uncaught TypeError: $(...).selectId is not a function
                                                at n.<anonymous> (index_m.html?0:206)
                                                at n.onack (universalModuleDefinition:3)
                                                at n.onpacket (universalModuleDefinition:3)
                                                at n.<anonymous> (universalModuleDefinition:3)
                                                at n.emit (universalModuleDefinition:2)
                                                at n.ondecoded (universalModuleDefinition:1)
                                                at s.<anonymous> (universalModuleDefinition:3)
                                                at s.r.emit (universalModuleDefinition:1)
                                                at s.add (universalModuleDefinition:1)
                                                at n.ondata (universalModuleDefinition:1)
                                            
                                            simatec 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            955
                                            Online

                                            31.6k
                                            Users

                                            79.4k
                                            Topics

                                            1.3m
                                            Posts

                                            7
                                            33
                                            3319
                                            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