Skip to content

Instantly share code, notes, and snippets.

@bflorian
Last active December 17, 2015 03:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bflorian/5542132 to your computer and use it in GitHub Desktop.
Save bflorian/5542132 to your computer and use it in GitHub Desktop.
Welcome Home Rest Call, SmartApp that makes a web service call when a contact sensor opens.
/**
* Welcome Home
*
* Make a web service call when your front door opens,
*
* Author: SmartThings
*/
preferences {
section("When the door opens/closes...") {
input "contact1", "capability.contactSensor", title: "Where?"
}
}
def installed() {
subscribe(contact1, "contact", contactOpenHandler)
}
def updated() {
unsubscribe()
subscribe(contact1, "contact", contactOpenHandler)
}
def contactOpenHandler(evt) {
httpPost(uri: "http://localhost:8088/webdemos/smarttest/event", body: [id: evt.deviceId, name: evt.name, value: evt.value]) {response ->
log.debug response.data
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment