Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. [gelöst] Trigger on System Restart

    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

    [gelöst] Trigger on System Restart

    This topic has been deleted. Only users with topic management privileges can see it.
    • Dutchman
      Dutchman Developer Most Active Administrators last edited by

      Da ich auch einige Sachen bei ioBroker start abarbeiten möchte habe ich dazu 1ne Variable erstellt und 1 Script welches dies bei start auf true setzt und 2sekunden später wieder falsch.

      Ich benutzte diese als Trigger für andere Scripte/Events welche ich bei einen Start ausführen möchte.

      Nachteil, man erkennt damit nicht den Unterschied zwischen ioBroker Neustart und/oder Neustart des JavaScript adapters.

      –-----------------------

      Send from mobile device

      1 Reply Last reply Reply Quote 0
      • M
        Marty56 last edited by

        Interessant.

        Das sehe ich nicht bei mir!

        Muss noch etwas anderes falsch sein.

        Außerdem bin ich gar nicht sicher, ob so ein Verhalten sinnvoll wäre.

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

          Ansonsten poste mal deinen Code und was passieren soll, dann sieht man vllt mehr

          1 Reply Last reply Reply Quote 0
          • M
            Marty56 last edited by

            Mir jetzt klar was gemeint war.

            Alle Statement eines Scripts werden bei Start aufgeführt.

            Will man eine Regel sowohl durch trigger als auch durch Systemstart ausführen will, dann packt man den Code in eine Funktion die von Triggern und auch vom Skipt am Anfang ausgeführt wird.

            Insofern ist das Statement, dass es die Funktion nicht benötigt wird, schon ok.

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

              Diese Aussage ist 100% korrekt 😉

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

                Wie kann man elegant die Funktionen beim Skript-Neustart einmal ausführen?

                setInterval(function() { 
                  log ('Programmstart 1')
                },5*60*1000);
                
                on({id: 'javascript.0.haus.Heizung.Bad.FensterOffen', change: 'ne'}, function (obj) {
                  log ('Programmstart 2')
                });
                `
                C paul53 2 Replies Last reply Reply Quote 0
                • C
                  Chrunchy @hanss last edited by

                  @hanss Indem du die einmal einfach im Programm aufrufst.
                  Alternativ einen function init erstellen, die du dann im Programm am ende aufrufst.

                  hanss 1 Reply Last reply Reply Quote 0
                  • hanss
                    hanss @Chrunchy last edited by

                    @Chrunchy
                    Ich verstehe das nicht,
                    könntest Du bitte mein Beispiel entsprechend ergänzen?
                    -Es sollte beim Script-Start Programmstart 1 und Programmstart 2 im Log stehen

                    C 1 Reply Last reply Reply Quote 0
                    • C
                      Chrunchy @hanss last edited by Chrunchy

                      @hanss OK

                      function init() {
                        log ('Programmstart 1');
                        log ('Programmstart 2');
                      }
                      
                      setInterval(function() { 
                        log ('Programmstart 1')
                      },5*60*1000);
                      
                      on({id: 'javascript.0.haus.Heizung.Bad.FensterOffen', change: 'ne'}, function (obj) {
                        log ('Programmstart 2')
                      });
                      
                      init();
                      
                      hanss 1 Reply Last reply Reply Quote 0
                      • hanss
                        hanss @Chrunchy last edited by

                        @Chrunchy
                        Du machst Spaß?
                        Die Zeilen log('Programmstart').. stehen natürlich stellvertretend für ca. 100 Zeilen Programmcode.

                        C 1 Reply Last reply Reply Quote 0
                        • C
                          Chrunchy @hanss last edited by

                          @hanss Das sollte dann aber keinen Unterschied mehr machen. 😉

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

                            @hanss sagte:

                            setInterval(function() { 
                               log ('Programmstart 1')
                            },5*60*1000);
                            

                            Die Log-Ausgabe erfolgt 5 Minuten nach Skript-Start und dann jede weitere 5 Minuten.

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

                              @paul53
                              Vielen Dank, das war mir klar.
                              Ich will aber die Log-Ausgabe sofort beim Skript-Start und habe das jetzt so gelöst:

                              ausgabe()
                              setInterval(ausgabe(),5*60*1000) 
                              function ausgabe(){
                                 log ('Programmstart 1')
                              }
                              
                              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

                              664
                              Online

                              31.9k
                              Users

                              80.2k
                              Topics

                              1.3m
                              Posts

                              6
                              16
                              2108
                              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