Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- definition(
- name: "Automatic Door Unlock",
- namespace: "io.goodintentions.autounlock",
- author: "Good Intentions",
- description: "Unlocks a door a specified time after locking.",
- category: "Safety & Security",
- iconUrl: "http://i.imgur.com/Wo5HCef.jpg",
- iconX2Url: "http://i.imgur.com/Wo5HCef.jpg",
- iconX3Url: "http://i.imgur.com/Wo5HCef.jpg")
- preferences {
- section("Lock Confguration:") {
- input "lock","capability.lock", title: "Lock", required: true
- input "delay", "number", title: "Unlock after locked(minutes):", defaultValue: 7, required: true
- }
- }
- def installed()
- {
- subscribe(lock, "lock", lockHandler)
- }
- def updated()
- {
- unsubscribe()
- subscribe(lock, "lock", lockHandler)
- }
- def lockHandler(evt) {
- if (evt.value == "locked") {
- runIn(getDelaySeconds(delay), unlockDoor)
- log.debug("${evt.displayName} locked.")
- }
- }
- void unlockDoor() {
- unschedule(unlockDoor)
- log.debug("Unlocking${lock.displayName} now.")
- lock.unlock()
- }
- def getDelaySeconds(delay) {
- return (delay * 60)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement