Shelly 2PM for cover control

It is very useful that the shellies do their work without WiFi and any server by just placing them behind existing switches or buttons or replacing switches and buttons with a shelly component and a shelly switch. So You can easily integrate them step by step into Your WLAN an then into home-assistant.
Especially for the covers I did it that way, but there came more ideas, so e.g. for 1 cover switch I had the following idea:
Button 0: single press: open or stop (local)
Button 0: double press: toggle relay for light (home assistant)
Button 0: triple press: all covers open (home assistant)
Button 1: single press: close or stop (local)
Button 1: double press: toggle relay for fan (home assistant)
Button 1: triple press: all covers close (home assistant)
The local function is important for me because I want the essential functions to work even without WLAN and without HA. But I had do detach the inputs from the output because a double or triple press started and stopped the cover! Actions provided no sulution because I only could open or close the cover but could not stop(!) opening or closing.
I searched for a script to include in the local Shelly configuration but didn’t find one. So i developed one and want to post it here. The script is named cover_open_close_stop and runs on startup.

Shelly.addEventHandler(function(e) {
  print("Event handler called");
  s=Shelly.getComponentStatus("cover:0").state;
  if (e.component === "input:0") { // Button 0 open
    if (e.info.event === "single_push") {
      print("Button 0 was pushed");
      if (s === "opening") {
        print("Cover is now opening");
        Shelly.call("Cover.stop", {'id': 0});
        print("Stop Cover");
      }
      else if (s === "closing") {
        print("Cover is now closing");
        Shelly.call("Cover.open", {'id': 0});
        print("open Cover");
      }
      else {
        Shelly.call("Cover.open", {'id': 0});
        print("Open Cover");
      }
    }
  }
  else if (e.component === "input:1") { // Button 1 close
    if (e.info.event === "single_push") {
      print("Button 1 was pushed");
      if (s === "opening") {
        print("Cover is now opening");
        Shelly.call("Cover.close", {'id': 0});
        print("close Cover");
      }
      else if (s === "closing") {
        print("Cover is now closing");
        Shelly.call("Cover.stop", {'id': 0});
        print("Stop Cover");
      }
      else {
        Shelly.call("Cover.close", {'id': 0});
        print("close Cover");
      }
    }
  }
});

In HA I created automations e.g. for the triple pushes to open all covers. Shelly button 0 is button1 in HA, Shelly button 1 is button2 in HA.

alias: all covers open
description: "Opens all covers on triple push of any cover control"
mode: single
triggers:
  - device_id: 8487b2ad0bc0c6a822538b8abe15cbbc
    domain: shelly
    type: triple_push
    subtype: button1
    trigger: device
# more device ids here...
conditions: []
actions:
  - metadata: {}
    data: {}
    target:
      entity_id:
        - cover.name_of_cover_1
# more cover names here...
    action: cover.open_cover

Hope this helps someone.