Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Error/Bug
    4. Objekte anlegen

    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

    SOLVED Objekte anlegen

    This topic has been deleted. Only users with topic management privileges can see it.
    • bahnuhr
      bahnuhr Forum Testing Most Active last edited by

      folgendes Script klappt soweit:

      const id = "mqtt.0.abcde";
      
      const obj = {
      "type":"state",
      "common": {
          "name": "abcde",
          "role": "",
          "type": "string",
          "read": true,
          "write": true,
          "desc": "per Javascript erzeugt",
          "def": ""}
      };
      
      setObject(id, obj, function() {
          setState(id, obj.common.def,true);
      });
      
      

      Trotzdem kommt noch im log ein Fehler:

      javascript.1	2019-08-02 12:18:47.405	warn	at Socket.<anonymous> (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\component-bind\index.js:21:15)
      javascript.1	2019-08-02 12:18:47.405	warn	at Manager.ondata (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\socket.io-client\lib\manager.js:322:16)
      javascript.1	2019-08-02 12:18:47.405	warn	at Decoder.add (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\socket.io-parser\index.js:246:12)
      javascript.1	2019-08-02 12:18:47.405	warn	at Decoder.Emitter.emit (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\component-emitter\index.js:134:20)
      javascript.1	2019-08-02 12:18:47.405	warn	at Decoder.<anonymous> (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\component-bind\index.js:21:15)
      javascript.1	2019-08-02 12:18:47.405	warn	at Manager.ondecoded (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\socket.io-client\lib\manager.js:332:8)
      javascript.1	2019-08-02 12:18:47.405	warn	at Manager.Emitter.emit (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\socket.io-client\node_modules\component-emitter\index.js:133:20)
      javascript.1	2019-08-02 12:18:47.405	warn	at Manager.<anonymous> (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\component-bind\index.js:21:15)
      javascript.1	2019-08-02 12:18:47.405	warn	at Socket.onpacket (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\socket.io-client\lib\socket.js:236:12)
      javascript.1	2019-08-02 12:18:47.405	warn	at Socket.onack (C:\ioBroker\node_modules\iobroker.js-controller\node_modules\socket.io-client\lib\socket.js:312:9)
      javascript.1	2019-08-02 12:18:47.405	warn	at Socket.<anonymous> (script.js.Scripte.test3:17:5)
      javascript.1	2019-08-02 12:18:47.405	warn	at setState (C:\ioBroker\node_modules\iobroker.javascript\lib\sandbox.js:1258:20)
      javascript.1	2019-08-02 12:18:47.404	warn	State "mqtt.0.abcde" not found 
      

      Trotz Fehler wird die Variable angelegt.

      Offensichtlich ist da immer noch was falsch

      Homoran Issi 2 Replies Last reply Reply Quote 0
      • paul53
        paul53 @bahnuhr last edited by

        @bahnuhr sagte:

        Warn-Meldung ist normal.

        So geht es auch ohne Warnung:

        const id = "mqtt.0.abcde";
         
        const obj = {
          "type":"state",
          "common": {
            "name": "abcde",
            "role": "",
            "type": "string",
            "read": true,
            "write": true,
            "desc": "per Javascript erzeugt",
            "def": ""
          }
        };
         
        setObject(id, obj);
        setTimeout(function() {setState(id, obj.common.def, true)}, 100);
        
        1 Reply Last reply Reply Quote 2
        • Homoran
          Homoran Global Moderator Administrators @bahnuhr last edited by Homoran

          @bahnuhr sagte in Objekte anlegen:

          Trotzdem kommt noch im log ein Fehler:

          Wo?

          ich sehe nur "warn"

          https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#setobject
          fettgedrucktes beachten

          1 Reply Last reply Reply Quote 0
          • Issi
            Issi Developer @bahnuhr last edited by

            @bahnuhr

            const id = "mqtt.0.abcde"
            
             
            
            const obj = {
            
            "type":"state",
            
            "common": {
            
                "name": "abcde",
            
                "role": "",
            
                "type": "string",
            
                "read": true,
            
                "write": true,
            
                "desc": "per Javascript erzeugt",
            
                "def": ""}
            
            };
            
             
            
            setObject(id, obj, function() {
            
                setState(id, obj.common.def,true);
            
            });
            
             
            

            das ; bei "mqtt.o.abcde" weg machen dan kommt auch kein warnungen mehr

            1 Reply Last reply Reply Quote 0
            • bahnuhr
              bahnuhr Forum Testing Most Active last edited by

              habe ; gelöscht.

              Hat sich aber nichts geändert.

              "warn" kommt immer noch.

              Issi 1 Reply Last reply Reply Quote 0
              • Issi
                Issi Developer @bahnuhr last edited by

                @bahnuhr hab mal dein script getestet bei mir kommen auch warn Meldungen wen ich dann die ; in Zeile 1 weg machen sowie oben von mir gepostet dann wird ein datenpunkt erstellt ohne das warn Meldungen kommen

                1 Reply Last reply Reply Quote 0
                • bahnuhr
                  bahnuhr Forum Testing Most Active last edited by bahnuhr

                  Also bei mir kommt die Warn Meldung wenn die Var. noch nicht besteht (wird aber trotzdem dann angelegt.).

                  Wenn sie schon besteht und ich dann das Script aktiviere; dann kommt keine Meldung mehr.

                  Hast du dies mal probiert.

                  Homoran Issi 2 Replies Last reply Reply Quote 0
                  • Homoran
                    Homoran Global Moderator Administrators @bahnuhr last edited by

                    @bahnuhr
                    Etwas anderes steht auch nicht in der Warn drin.

                    deswegen solltest du ja die Doku, die ich verlinkt habe lesen, insbesondere das fetgedruckte

                    1 Reply Last reply Reply Quote 0
                    • Issi
                      Issi Developer @bahnuhr last edited by Issi

                      @bahnuhr also ich habe kein mqtt adapter instalirt also wird der datenpunkt ganz neu angelegt
                      Anmerkung 2019-08-02 133151.png
                      Anmerkung 2019-08-02 133206.png

                      1 Reply Last reply Reply Quote 0
                      • Homoran
                        Homoran Global Moderator Administrators last edited by Homoran

                        Da das anklicken eines Links wohl zuviel verlangt ist:

                        zu setObject steht in der Doku

                        You should use it to modify an existing object you read beforehand, e.g.:

                        und die warn sagt beim ersten mal nur, dass es noch nicht existiert
                        anschließend ist es angelegt und keine warn erscheint

                        bahnuhr 1 Reply Last reply Reply Quote 0
                        • bahnuhr
                          bahnuhr Forum Testing Most Active @Homoran last edited by

                          @Homoran sagte in Objekte anlegen:

                          Da das anklicken eines Links wohl zuviel verlangt ist:

                          Und immer die Spitzen (kommt jedenfalls so rüber).

                          Ich habe sehrwohl den Link angeklickt und auch gelesen; aber nicht verstanden.

                          Aber wenn dir dies klar ist, dann schreib doch mal wie die Lösung ist.

                          mfg

                          thewhobox 1 Reply Last reply Reply Quote 0
                          • thewhobox
                            thewhobox @bahnuhr last edited by

                            @bahnuhr Es gibt keine Lösung. Das Verhalten ist so gewollt.
                            Die funktion ist nur ein Workaround um damit einen Datenpunkt zu erstellen.

                            Eigentlich bearbeitet die funktion einen vorhandenen Datenpunkt.
                            Deswegen heißt sie setObject und nicht createObject.
                            Wenn der Datenpunkt nicht vorhanden ist gibt es halt eine Warnung, erstellt ihn aber trotzdem.

                            1 Reply Last reply Reply Quote 0
                            • bahnuhr
                              bahnuhr Forum Testing Most Active last edited by

                              Danke.
                              Das ist ne klare Aussage.

                              Fazit:
                              Datenpunkt wird erstellt.
                              Warn-Meldung ist normal.

                              Homoran paul53 2 Replies Last reply Reply Quote 0
                              • Homoran
                                Homoran Global Moderator Administrators @bahnuhr last edited by

                                @bahnuhr sagte in Objekte anlegen:

                                Fazit:
                                Datenpunkt wird erstellt.
                                Warn-Meldung ist normal.

                                Sorry, wenn das bei mir nicht so rüberkam - das wollte ich mit meinen Worten auch bereits mehrfach gesagt haben

                                1 Reply Last reply Reply Quote 0
                                • paul53
                                  paul53 @bahnuhr last edited by

                                  @bahnuhr sagte:

                                  Warn-Meldung ist normal.

                                  So geht es auch ohne Warnung:

                                  const id = "mqtt.0.abcde";
                                   
                                  const obj = {
                                    "type":"state",
                                    "common": {
                                      "name": "abcde",
                                      "role": "",
                                      "type": "string",
                                      "read": true,
                                      "write": true,
                                      "desc": "per Javascript erzeugt",
                                      "def": ""
                                    }
                                  };
                                   
                                  setObject(id, obj);
                                  setTimeout(function() {setState(id, obj.common.def, true)}, 100);
                                  
                                  1 Reply Last reply Reply Quote 2
                                  • bahnuhr
                                    bahnuhr Forum Testing Most Active last edited by

                                    Danke Paul,

                                    das ist die Lösung.

                                    mfg
                                    Dieter

                                    paul53 1 Reply Last reply Reply Quote 0
                                    • paul53
                                      paul53 @bahnuhr last edited by

                                      @bahnuhr sagte:

                                      das ist die Lösung.

                                      Dann markiere die Lösung, damit das Fragezeichen verschwindet.

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

                                      Support us

                                      ioBroker
                                      Community Adapters
                                      Donate

                                      855
                                      Online

                                      31.9k
                                      Users

                                      80.1k
                                      Topics

                                      1.3m
                                      Posts

                                      objekte anlegen
                                      6
                                      26
                                      1804
                                      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