Created
February 14, 2014 21:49
-
-
Save rappleg/9010044 to your computer and use it in GitHub Desktop.
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
/** | |
* ParentChildParent | |
* | |
* Author: scott | |
* Date: 2014-02-14 | |
*/ | |
preferences { | |
section("Title") { | |
// TODO: put inputs here | |
} | |
} | |
mappings { | |
path("/show") { | |
action: [ | |
GET: "show" | |
] | |
} | |
path("/add") { | |
action: [ | |
GET: "add" | |
] | |
} | |
} | |
def installed() { | |
log.debug "Installed with settings: ${settings}" | |
def one = addChildDevice("rappleg", "ParentChildChild", uuid(), null, ["label":"one"]) | |
def two = addChildDevice("rappleg", "ParentChildChild", uuid(), null, ["label":"two"]) | |
initialize() | |
log.debug "0: ${getServerUrl()}/api/smartapps/installations/${app.id}/show?access_token=${state.accessToken}" | |
log.debug "1: ${getServerUrl()}/api/devices/${one.device.id}/show?access_token=${one.data.accessToken}" | |
log.debug "2: ${getServerUrl()}/api/devices/${two.device.id}/show?access_token=${two.data.accessToken}" | |
} | |
def uuid() | |
{ | |
return UUID.randomUUID().toString() | |
} | |
def updated() { | |
log.debug "Updated with settings: ${settings}" | |
unsubscribe() | |
initialize() | |
} | |
def initialize() { | |
if(!state.accessToken) | |
{ | |
log.debug "about to create access token" | |
createAccessToken() | |
} | |
} | |
def show() { | |
def count = atomicState.data?.count | |
return [count: count] | |
} | |
def add() { | |
increment() | |
return show() | |
} | |
def increment() | |
{ | |
def old = atomicState.data?.count ?: 0 | |
log.debug "old: $old" | |
atomicState.data = [count: old + 1] | |
} | |
def getServerUrl() { return "http://localhost:8080/" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment