Created
September 5, 2013 14:54
-
-
Save rappleg/6451240 to your computer and use it in GitHub Desktop.
Doors Parent
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
/** | |
* Doors | |
* | |
* Author: ryan | |
* Date: 2013-08-26 | |
*/ | |
preferences { | |
page(name: "root", title: "Doors", nextPage: "createDoor", install: true) { | |
section(" ") { | |
app "door", "Solutions", "New Door", title: "Add a door", page: "createDoor", childTitle: "Your doors", childPage: "doorDetail", install: true, multiple: true | |
} | |
} | |
} | |
def installed() { | |
log.debug "Installed with settings: ${settings}" | |
subscribeToChildren() | |
} | |
def updated() { | |
log.debug "Updated with settings: ${settings}" | |
unsubscribe() | |
subscribeToChildren() | |
} | |
def subscribeToChildren() { | |
childApps.each { childApp -> | |
log.debug "Subscribing to child ${childApp.label}" | |
subscribe(childApp) | |
childApp.childApps.each { grandChildApp -> | |
log.debug "Subscribing to grand child ${grandChildApp.label}" | |
subscribe(grandChildApp) | |
log.debug "Subscribing to physical devices for ${grandChildApp.label}" | |
grandChildApp.childDevices.each { device -> | |
log.debug "PHYSICAL DEVICE: " + device.typeName | |
subscribeToDeviceByType(device) | |
} | |
log.debug "Subscribing to virtual devices for ${grandChildApp.label}" | |
grandChildApp.virtualDevices.each { device -> | |
log.debug "VIRTUAL DEVICE: " + device.typeName | |
subscribeToDeviceByType(device) | |
} | |
} | |
} | |
} | |
def subscribeToDeviceByType(device) { | |
if (device.typeName == "Contact Sensor Capability") { | |
subscribe(device, "contact", "contactHandler") | |
} else if (device.typeName == "Lock Capability") { | |
subscribe(device, "lock", "lockHandler") | |
} else if (device.typeName == "Presence Sensor Capability") { | |
subscribe(device, "presence", "presenceHandler") | |
} | |
} | |
def contactHandler(evt) { | |
log.debug "$evt.value: $evt, $settings" | |
//sendEvent() | |
} | |
def lockHandler(evt) { | |
log.debug "$evt.value: $evt, $settings" | |
//sendEvent() | |
} | |
def presenceHandler(evt) { | |
log.debug "$evt.value: $evt, $settings" | |
//sendEvent() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment