Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Script Hilfe

    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

    Script Hilfe

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

      @fischi87
      Anstelle der for-Schleife verwende ein Intervall für Alexa. sendTo() muss außerhalb der Schleife (des Intervalls) aufgerufen werden.

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

        @paul53
        sorry aber soweit bin ich der script Materie noch nicht drin 🙂

        Ansätze?

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

          @fischi87
          Anmerkung: Mit Alexa kenne ich mich überhaupt nicht aus.

          var timer = 0;
          
          function klingel() {
              let i = 0;
              timer = setInterval(function() {
                  setState(ALEXA[i][1], 40);
                  setState(ALEXA[i][0], "Jemand steht vor der Tür");
                  i++;
                  if(i >= ALEXA.length) clearInterval(timer);
              }, 200);
              sendTo('telegram.0', {
                  text:   'Jemand steht vor der Tür'
              });
              setTimeout(function(){
                   setState(idtaster,false);
              }, 600);
          }
          
          fischi87 1 Reply Last reply Reply Quote 0
          • fischi87
            fischi87 @paul53 last edited by

            @paul53 ist der Interval dafür da wie schnell Alexa spricht? dauert nämlich immer noch etwas bis Alexa was sagt.

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

              @fischi87 sagte:

              dauert nämlich immer noch etwas bis Alexa was sagt.

              Was ist etwas ? Die erste Verzögerung ist 200 ms.

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

                @paul53
                ich habe es jetzt nicht gestoppt aber ich schätze mindestens 2-6 sek. mal 2 mal 4 mal 6 sek.

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

                  @fischi87 sagte:

                  mal 2 mal 4 mal 6 sek.

                  Bei Alexa muss ich passen.

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

                    @paul53
                    okay danke dir trotzdem erstmal, es funktioniert ja!

                    fischi87 1 Reply Last reply Reply Quote 0
                    • fischi87
                      fischi87 @fischi87 last edited by

                      @fischi87

                      hallo paul, ich habe das jetzt so integriert. der Timer in Zeile 13 und 17 wird rot unterlegt, ist dies relevant?

                      const idtaster = 'hm-rpc.0.MEQ0485030.1.STATE'
                      
                      const ALEXA = [];
                      
                      ALEXA[0] = /*AZ*/ ['alexa2.0.Echo-Devices.G0911M07940632RE.Commands.speak', 'alexa2.0.Echo-Devices.G0911M07940632RE.Commands.speak-volume'];
                      ALEXA[1] = /*SZ*/ ['alexa2.0.Echo-Devices.G0911M0894370XXL.Commands.speak', 'alexa2.0.Echo-Devices.G0911M0894370XXL.Commands.speak-volume'];
                      ALEXA[2] = /*WZ*/ ['alexa2.0.Echo-Devices.G090LF0964340WK2.Commands.speak', 'alexa2.0.Echo-Devices.G090LF0964340WK2.Commands.speak-volume'];
                      
                      var timer = 0;
                       
                      function klingel() {
                          let i = 0;
                          timer = setInterval(function() {
                              setState(ALEXA[i][1], 40);
                              setState(ALEXA[i][0], "Jemand steht vor der Tür");
                              i++;
                              if(i >= ALEXA.length) clearInterval(timer);
                          }, 200);
                          sendTo('telegram.0', {
                              text:   'Jemand steht vor der Tür'
                          });
                          setTimeout(function(){
                               setState(idtaster,false);
                          }, 600);
                      }
                      
                      on(idtaster, function(dp) {
                          if(dp.state.val) {
                              klingel();
                          }
                      });
                      
                      paul53 1 Reply Last reply Reply Quote 0
                      • paul53
                        paul53 @fischi87 last edited by

                        @fischi87 sagte:

                        Timer in Zeile 13 und 17 wird rot unterlegt, ist dies relevant?

                        Du hast die Variable timer mit der Zahl 0 initialisiert, weshalb der Editor meckert. Besser:

                        var timer = null;
                        
                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        945
                        Online

                        31.8k
                        Users

                        80.0k
                        Topics

                        1.3m
                        Posts

                        2
                        11
                        306
                        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