Created
July 14, 2023 21:25
-
-
Save lgrangeia/8a163911a602740b1187ecca781075f5 to your computer and use it in GitHub Desktop.
Shelly 2PM Script to roll venetian blinds up on double tap to close
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let double_click = false; | |
let last_close_ts = 0; | |
let double_tap_time = 3; | |
let roll_blades = false; | |
Shelly.addEventHandler( | |
function (event, ud) { | |
print("event: ", JSON.stringify(event)); | |
if (event.info.event === "closing") { | |
let close_ts = event.info.ts; | |
let delta = close_ts - last_close_ts; | |
print("DELTA: ", delta); | |
last_close_ts = close_ts; | |
if (delta < double_tap_time) { | |
print("will roll blades once closed."); | |
roll_blades = true; | |
} | |
} | |
if (event.info.event === "closed") { | |
print("CLOSED!"); | |
if (roll_blades) { | |
roll_blades = false | |
Shelly.call("Cover.GoToPosition", {'id': 0, 'pos': 2}); | |
} | |
} | |
}, | |
null | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment