Jump to content

Recommended Posts

Posted

Hallo,

ich habe meine Rollläden mit Shelly 2PM angesteuert und funktioniert auch wie erwartet.
Nur reagieren sie sehr langsam auf Taster-Ereignisse.
Wenn er läuft dauert es etwa 300-500 mS bis er stoppt.

Über WebZugriff reagieren sie nahezu sofort.

Liegt es an meinem Script, kann man da was optimieren?
 

*******************************************************************************
Kurzer Click automatisch auf/ab bis zum Ende
Langer Druck fährt bis zum Loslassen des Tasters
DoppelKlick steuert die ganze Gruppe automatisch auf/ab
******************************************************************************/
var LongPush = false;

Shelly.addEventHandler(
  function (event) {
    print("EventHandler: " + JSON.stringify(event));

    if (typeof event.info.event !== 'undefined') {

      // start the cover on button down
      if (event.info.event === 'btn_down') {
        let CoverState = Shelly.getComponentStatus("Cover:0");
        print("Cover.GetStatus: " + JSON.stringify(CoverState));
        if ((CoverState.state !== 'opening') && (CoverState.state !== 'closing')) {
          if ((CoverState.state !== 'open') && (event.info.id === 0)) { // Button:0 = Up
            Shelly.call("Cover.open", { 'id': 0 });
          } else if ((CoverState.state !== 'closed') && (event.info.id === 1)) { // Button:1 = Down
            Shelly.call("Cover.close", { 'id': 0 });
          }
        }
      }

      // stop the cover after single push
      if (event.info.event === 'single_push') {
        let CoverState = Shelly.getComponentStatus("Cover:0");
        print("Cover.GetStatus: " + JSON.stringify(CoverState));
        if (CoverState.state === 'opening' || CoverState.state === 'closing')
          if ((event.info.ts - CoverState.move_started_at) > 1) {
            print("Cover.stop <2>");
            Shelly.call("Cover.stop", { 'id': 0 });
          }
      }

      // stop the cover if button is released after long push
      if (LongPush && (event.info.event === 'btn_up')) {
        let CoverState = Shelly.getComponentStatus("Cover:0");
        print("Cover.GetStatus: " + JSON.stringify(CoverState));
        if (CoverState.state === 'opening' || CoverState.state === 'closing') {
          print("Cover.stop <1>");
          Shelly.call("Cover.stop", { 'id': 0 });
        }
      }

      // set the Push flags
      if (event.info.event === 'btn_down') {
        LongPush = false;
      }
      if (event.info.event === 'long_push')
        LongPush = true;

      // start the cover group on double push
      if (event.info.event === 'double_push') {

      }
    }
  }
)

Danke und schöne Grüße
Manfred

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...