Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [gelöst]Dimmen mit "Long Press"

    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]Dimmen mit "Long Press"

    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User last edited by

      Sorry wenn ich nochmal das Thema aufmache. Ich versuche das Script auf eine weitere Lampe zu erweitern. Hört sich simpel an aber anscheinend zu schwierig für mich 😉 Also die Aufgabe wäre ein Taster zwei Lampen die synchron laufen. Kann mir jemand einen Tipp geben?

      paul53 2 Replies Last reply Reply Quote 0
      • paul53
        paul53 @Guest last edited by

        @noah3112
        Erwartest Du eine Antwort, wenn das Thema mit [gelöst] markiert ist ?

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

          @noah3112 sagte:

          ein Taster zwei Lampen die synchron laufen.

          // IDs anpassen !
          const idLevel1 = "meinAdapter.0.CC78CB0000261884.bri"; 
          const idSwitch1 = "meinAdapter.0.CC78CB0000261884.on"; 
          const idLevel2 = "...bri";
          const idSwitch2 = "...on";
          const idLong = "mihome.0.devices.switch_158d0001f3a5b2.long";
           
          var level = getState(idLevel1).val;
          var state1 = getState(idSwitch1).val;
          var state2 = getState(idSwitch2).val;
          var down = false;
          if(level > 90) down = true;
          var timer = null;
           
          function rampe() {
             if(down) {
                level = level - 5;
                if(level < 0) down = false;
                else {
                   setState(idLevel1, level);
                   setState(idLevel2, level);
                }
             } else {
                level = level + 5;
                if(level > 100) down = true;
                else {
                   setState(idLevel1, level);
                   setState(idLevel2, level);
                }
             }
          }
           
          on({id: idSwitch1, ack: true}, function(dp) {
             state1 = dp.state.val;
          });
          
          on({id: idSwitch2, ack: true}, function(dp) {
             state2 = dp.state.val;
          });
           
          on(idLong, function(dp) {
             if(dp.state.val) {
                if(!state1) setState(idSwitch1, true);
                if(!state2) setState(idSwitch2, true);
                timer = setInterval(rampe, 200);
             } else clearInterval(timer);
          });
          
          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            Ja ich weiß, aber neues Thema wollte ich dafür nicht extra aufmachen. Und dein Beispiel funktionierte bei mir bisher wunderbar. Danke das du trotzdem geantwortet hast. Du hast es einfach drauf 🙂

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

            Support us

            ioBroker
            Community Adapters
            Donate

            407
            Online

            31.9k
            Users

            80.2k
            Topics

            1.3m
            Posts

            2
            4
            293
            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