Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Skript für Lichtsteuerung auf Zeit

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Skript für Lichtsteuerung auf Zeit

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

      Hallo ich bin ein Neuling versuche mich gerade im Javascript/js

      Ich Möchte Eine Lampe einschalte für 5 Minuten wenn ich den Taster kurz drücke, wenn die Lampe Leuchtet und die Taste noch mal kurz drücke wieder ausgehen

      auch wenn die 5 Minuten nicht um Sind

      ich habe schon geschaut ich finde Leider nichts, ist das Überhaut möglich

      Hatte eine CL-Box bei der hat das Funktioniert Möchte alles Umstellen auf ioBroker

      Bitte Bitte um Hilfe

      MfG Christian

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

        Vielleicht so:

        // Datenpunkt-IDs
        const idTaste = '...';
        const idLampe = '...';
        
        var timer = null;
        
        on({id: idTaste, val: true}, function() {
           if(timer) {
              clearTimeout(timer);  // laufenden Timer stoppen
              timer = null;
              setState(idLampe, false);
           } else {
              setState(idLampe, true);
              timer = setTimeout(function() {
                 setState(idLampe, false);
                 timer = null;
              }, 5 * 60000);  // 5 Minuten
           }
        });
        
        1 Reply Last reply Reply Quote 0
        • C
          coswald last edited by

          Hallo Paul53

          erst mal danke habe es eingegeben es funktioniert leider nicht

          Skript sieht so aus

          var timer=null;

          on({id: 'hm-rpc.0.OEQ0279752.2.PRESS_SHORT',val:true},function() {

          if(timer){

          clearTimeout(timer);

          stoppen

          timer=null;

          setState("hm-rpc.0.IEQ0007850.1.STATE",false);

          }else{

          SetState("hm-rpc.0.IEQ0007850.1.STATE",true);

          timer = setTimeout(function() {

          setState("hm-rpc.0.IEQ0007850.1.STATE",false);

          timer=nul;

          },5*60000);

          }

          });

          beim Start des Skript Steht unten

          22:24:21.706 [info] javascript.0 Start javascript script.js.Skript3

          22:24:21.706 [info] javascript.0 script.js.Skript3: registered 1 subscription and 0 schedules

          Beim Drücken der Taste kommt das

          22:24:44.719 [error] javascript.0 at Object. (script.js.Skript3:9:5)

          Hat sich da ein Fehler eingeschlichen? und wo ist er

          MfG Christian

          1 Reply Last reply Reply Quote 0
          • S
            SchuetzeSchulz last edited by

            5. Zeile das "stoppen" muss raus/entfernt werden und 4. Zeile von unten das muss

            timer=null;

            heissen

            1 Reply Last reply Reply Quote 0
            • C
              coswald last edited by

              Hallo noch mal

              geht immer noch nicht

              var timer=null;

              on({id: 'hm-rpc.0.OEQ0279752.2.PRESS_SHORT',val:true},function() {

              if(timer){

              clearTimeout(timer);

              timer=null;

              setState("hm-rpc.0.IEQ0007850.1.STATE",false);

              }else{

              SetState("hm-rpc.0.IEQ0007850.1.STATE",true);

              timer=setTimeout(function(){

              setState("hm-rpc.0.IEQ0007850.1.STATE",false);

              timer=null;

              },5*60000);

              }

              });

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

                @SchuetzeSchulz:

                5. Zeile das "stoppen" muss raus/entfernt werden und 4. Zeile von unten das muss

                timer=null; `
                … und
                @coswald:

                SetState("hm-rpc.0.IEQ0007850.1.STATE",true); `
                –>

                setState("hm-rpc.0.IEQ0007850.1.STATE",true);
                

                Weshalb hast Du das Skript nicht einfach kopiert (copy & paste) und dann die Zeilen 2 und 3 angepasst ?

                1 Reply Last reply Reply Quote 0
                • C
                  coswald last edited by

                  Möchte es Raus bekommen wo Klammern usw hinkommen drum habe ich es eingegeben

                  Möchte mich recht herzlich bedanken

                  MfG Christian

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  738
                  Online

                  31.7k
                  Users

                  79.8k
                  Topics

                  1.3m
                  Posts

                  4
                  7
                  800
                  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