Skip to content

Instantly share code, notes, and snippets.

@tylerlange
Created April 23, 2015 16:41
Show Gist options
  • Save tylerlange/638d8d602d33c7929e42 to your computer and use it in GitHub Desktop.
Save tylerlange/638d8d602d33c7929e42 to your computer and use it in GitHub Desktop.
Unlock it when I arrive
/**
* Unlock It When I Arrive
*
* Author: SmartThings
* Date: 2013-02-11
*/
definition(
name: "Unlock It When I Arrive",
namespace: "smartthings",
author: "SmartThings",
description: "Unlocks the door when you arrive at your location.",
category: "Safety & Security",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png",
oauth: true
)
preferences {
section("When I arrive..."){
input "presence1", "capability.presenceSensor", title: "Who?", multiple: true
}
section("Unlock the lock..."){
input "lock1", "capability.lock", multiple: true
}
}
def installed()
{
subscribe(presence1, "presence.present", presence)
}
def updated()
{
unsubscribe()
subscribe(presence1, "presence.present", presence)
}
def presence(evt)
{
def anyLocked = lock1.count{it.currentLock == "unlocked"} != lock1.size()
if (anyLocked) {
sendPush "Unlocked door due to arrival of $evt.displayName"
lock1.unlock()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment