Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Entwicklung
    4. Timing issue createState --> setState trotz Callback

    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

    Timing issue createState --> setState trotz Callback

    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      HGlab @paul53 last edited by

      @paul53
      Guter Punkt, kann nur dann kein 'ack' und 'expire' mitgeben

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

        @HGlab sagte:

        kann nur dann kein 'ack' und 'expire' mitgeben

        Wozu dient "expire" ?
        Nach meiner Erfahrung macht es nur Probleme.

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

          @paul53
          das JSON-Objekt hat Bäume und Blätter die optional sind. Da ich generisch durch das Objekt traversiere schreibe ich alles rein was da ist. Wenn etwas nicht mehr da ist läuft es ins expire.

          Mit folgender Ergänzung rennt es nun ohne Warnings durch - eigentlich gibt es dafür keinen Grund, aber so klappt es - warum auch immer!

          if (existsObject(id) == false) {
              createState(id, '', creat_param, function (err,state) {
                  if (err) log(err + ' | ' + state, 'error'); 
                  setState(id, { 'val': value, 'ack': true, 'expire': 5.1 * 60 });
              });
          } else {
              setState(id, { 'val': value, 'ack': true, 'expire': 5.1 * 60 });
          }
          paul53 UncleSam 2 Replies Last reply Reply Quote 0
          • paul53
            paul53 @HGlab last edited by paul53

            @HGlab sagte:

            Mit folgender Ergänzung rennt es nun ohne Warnings durch - eigentlich gibt es dafür keinen Grund

            Der log-Befehl benötigt Zeit, sorgt also dafür dass setState() etwas später ausgeführt wird.

            H 1 Reply Last reply Reply Quote 0
            • UncleSam
              UncleSam Developer @HGlab last edited by

              @HGlab Was sagt denn das Log nun?

              UncleSam H 2 Replies Last reply Reply Quote 0
              • H
                HGlab @paul53 last edited by

                @paul53
                war auch ein Verdacht, es ist aber nur das "if", ist nie TRUE;
                Wenn ich nur

                log(err + ' | ' + state, 'error'); 
                

                ohne if nehme, dann kommen die Fehler wieder. Sehr strange!

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

                  @UncleSam sagte in Timing issue createState --> setState trotz Callback:

                  @HGlab Was sagt denn das Log nun?

                  ?

                  1 Reply Last reply Reply Quote 0
                  • H
                    HGlab @UncleSam last edited by

                    @UncleSam said in Timing issue createState --> setState trotz Callback:

                    @HGlab Was sagt denn das Log nun?

                    keine Fehler im Log; die CreateState funktionieren alle
                    siehe https://forum.iobroker.net/topic/40222/timing-issue-createstate-setstate-trotz-callback/4

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

                      @HGlab sagte:

                      ohne if nehme, dann kommen die Fehler wieder. Sehr strange!

                      Allerdings.
                      Möglicher Workaround wäre, die Funktion in einem Intervall (z.B. alle 200 ms) anstelle in einer Schleife aufzurufen, denn die JSON-Abfrage erfolgt anscheinend alle 5 Minuten.

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

                        @paul53
                        Ich traversiere rekursiv durch das JSON Objekt und rufe für jedes Blatt die setStateCus-Methode auf.
                        Wüsste nicht wie ich das sinnvoll entkoppeln kann.
                        Hab auch schon setState mit 1000ms verzögert ausgeführt, auch das hat nichts geholfen.
                        Ich denke es liegt am Übergang zu Reddis. Reddis funktioniert ja auch asynchron und vermutlich stecken die "creates" noch in der Queue und werden teilweise von den setStates überholt.

                        Vielleicht lege ich mal ein issue beim JS-Controller an...

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

                          @HGlab sagte in:

                          Vielleicht lege ich mal ein issue beim JS-Controller an...

                          Da gibt es bereits etwas.

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

                            @paul53 👍

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            689
                            Online

                            31.9k
                            Users

                            80.2k
                            Topics

                            1.3m
                            Posts

                            createstate setstate
                            3
                            16
                            728
                            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