Last active
December 17, 2015 03:19
-
-
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.
This file contains hidden or 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
/** | |
* 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