Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Scriptbeispiel] Alle Rollladen zeitverzögert per Taste/vis

    NEWS

    • js-controller 3.2 jetzt im STABLE!

    • Alexa2 Adapter: ACHTUNG UPDATE auf 3.7.x nötig!!

    • ioBroker Fertigimages für Einplatinencomputer eingestellt

    [Scriptbeispiel] Alle Rollladen zeitverzögert per Taste/vis

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

      Es wurden schon verschiedene Varianten des Rollladenscripts gezeigt.

      Ich möchte nun auch noch meine Adaption davon vorstellen, da diese gerade im Aufbau der Anlage von Vorteil ist.

      Dieses 'fire and forget' Script fährt immer alle Storen, auch wenn ihr welche abgebaut und / oder angebaut habt. Die einzelnen Läden müssen nicht neu konfiguriert oder eingetragen werden.

      Dafür fahren sie halt 'nur' ganz auf oder ganz zu.

      // Erzeuge zwei Objekte um mit .vis oder anderen Scripten einzugreifen
      createState("javascript.0.vis.Storen.runter", false);
      createState("javascript.0.vis.Storen.hoch", false);
      
      var input1 = "hm-rpc.0.LEQ0656999.1.PRESS_SHORT"/*HM-PB-2-WM55-2 LEQ0656999:1.PRESS_SHORT*/;    // Hier den Auslöse-Datenpunkt für 'AB' einfügen
      var input2 = "javascript.0.vis.Storen.runter"/*javascript.0.vis.Storen.runter*/;
      var input3 = "hm-rpc.0.LEQ0656999.2.PRESS_SHORT"/*HM-PB-2-WM55-2 LEQ0656999:2.PRESS_SHORT*/;    // Hier den Auslöse-Datenpunkt für 'AUF' einfügen
      var input4 = "javascript.0.vis.Storen.hoch"/*javascript.0.vis.Storen.hoch*/;
      var timer1 = 3000;  // Millisekunden Verzögerung zwischen den Storen                            // Das können virtuelle oder richtige Taste sein
      
      // DO NOT CHANGE BELOW THIS LINE, untill you know what you do!
      // It is better to cache all the blinds at start, because in big installations it can take some time to search for blinds
      var cacheSelector = $('channel{TYPE=BLIND}[state.id=*.LEVEL]');     // Get all blinds of Homematic
      var oldTimers = [];
      
      // set timed function
      function timedState(i, id, level) {
        oldTimers.push(setTimeout(function(){
          setState(id, level);
          log("fahre Storen " + id + " auf " + level + "%"); 
        }, timer1 * i));
      }
      
      function setPercent(value) {
          // Terminate old timers. So it is possible to start the next step without waiting 'till the old one finished
          for (var t = 0; t < oldTimers.length; t++) {
               clearTimeout(oldTimers[t]);
          }
          oldTimers = [];
          cacheSelector.each(function (id, i) {
              timedState(i, id, value);       // 0 for 0% or 100 for 100%
          }); 
      }
      
      // blinds down
      on({id: input1}, function () {
          log("Script: Storen schliessen startet");           // Log the action. Default level is always  "info"  
          setPercent(0);
      });
      on({id: input2}, function () {
          log("Script: Storen schliessen startet");
          setPercent(0);
      });
      
      // blinds up
      on({id: input3}, function () {
          log("Script: Storen öffnen startet");
           setPercent(100);
      });
      on({id: input4}, function () {
          log("Script: Storen öffnen startet");
           setPercent(100);
      });
      
      // astro functions
      schedule({astro: "sunriseEnd"}, function () {
          log("Script: Astro-SunriseEnd - Storen öffnen startet");
          setPercent(100);
      });
      schedule({astro: "sunset"}, function () {
          log("Script: Astro-Sunset - Storen schliessen startet");
          setPercent(0);
      });
      
      

      Version 0.2.0 15.06.15 Integration von virtuellen Datenpunkten, um zB mit .vis zu schalten

      Version 0.1.2 12.06.15 Auslösung durch Astro-Funktion angefügt

      Version 0.1.1 05.06.15 Anpassungen von Bluefox nachgetragen

      Version 0.1.0 04.06.15 First release

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

        Ich wurde das so ändern:

        var input1 = "hm-rpc.0.LEQ0696992.1.PRESS_SHORT"/*HM-PB-2-WM55-2 LEQ0696992:1.PRESS_SHORT*/;    // Hier den Datenpunkt für 'AB' einfügen
        var input2 = "hm-rpc.0.LEQ0696992.2.PRESS_SHORT"/*HM-PB-2-WM55-2 LEQ0696992:2.PRESS_SHORT*/;    // Hier den Datenpunkt für 'AUF' einfügen
        var timer1 = 4000;  // Millisekunden Verzögerung zwischen den Storen                            // Das kann eine Virtuell oder richtige Taste sein
        
        // DO NOT CHANGE BELOW THIS LINE
        // It is better to cache all the blinds at start, because in the big installations it can take the time to search for blinds
        var cacheSelector = $('channel{TYPE=BLIND}[state.id=*.LEVEL]');     // Get all blinds of Homematic
        var oldTimers = [];
        
        // set timed function
        function timedState(i, id, level) {
          oldTimers.push(setTimeout(function(){
            setState(id, level);
            log("fahre Storen " + id + " auf " + level + "%"); 
          }, timer1 * i));
        }
        
        function setPercent(value) {
            // Terminate old timers. So it is possible to start the next step without waiting till the old one finished
            for (var t = 0; t < oldTimers.length; t++) {
                 clearTimeout(oldTimers[t]);
            }
            oldTimers = [];
            cacheSelector.each(function (id, i) {
                timedState(i, id, value);       // 0 for 0% or 100 for 100%
            }); 
        }
        
        // blinds down
        on({id: input1}, function () {
            log("Script: Storen schliessen startet");          // Log the action. Default level is always  "info"  
            setPercent(0);
        });
        
        // blinds up
        on({id: input2}, function () {
            log("Script: Storen öffnen startet");       // Log the action. Default level is always  "info" 
             setPercent(100);
        });
        
        
        1 Reply Last reply Reply Quote 0
        • Y
          ykuendig last edited by

          Cool; ( Immerhin hatte meins auch funktioniert… )

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

          Support us

          ioBroker
          Community Adapters
          Donate

          316
          Online

          38.6k
          Users

          43.9k
          Topics

          614.6k
          Posts

          2
          3
          2080
          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-2021
          logo