Hue update to match the new UI (Bridge)

This commit is contained in:
Juan Pablo Risso
2015-09-08 13:53:45 -04:00
parent e1a9f2f761
commit 8dd3b2396f

View File

@@ -15,19 +15,27 @@ metadata {
// TODO: define status and reply messages here // TODO: define status and reply messages here
} }
tiles { tiles(scale: 2) {
multiAttributeTile(name:"rich-control"){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "default", label: "Hue Bridge", action: "", icon: "st.Lighting.light99-hue", backgroundColor: "#F3C200"
}
tileAttribute ("serialNumber", key: "SECONDARY_CONTROL") {
attributeState "default", label:'SN: ${currentValue}'
}
}
standardTile("icon", "icon", width: 1, height: 1, canChangeIcon: false, inactiveLabel: true, canChangeBackground: false) { standardTile("icon", "icon", width: 1, height: 1, canChangeIcon: false, inactiveLabel: true, canChangeBackground: false) {
state "default", label: "Hue Bridge", action: "", icon: "st.Lighting.light99-hue", backgroundColor: "#FFFFFF" state "default", label: "Hue Bridge", action: "", icon: "st.Lighting.light99-hue", backgroundColor: "#FFFFFF"
} }
valueTile("serialNumber", "device.serialNumber", decoration: "flat", height: 1, width: 2, inactiveLabel: false) { valueTile("serialNumber", "device.serialNumber", decoration: "flat", height: 1, width: 2, inactiveLabel: false) {
state "default", label:'SN: ${currentValue}' state "default", label:'SN: ${currentValue}'
} }
valueTile("networkAddress", "device.networkAddress", decoration: "flat", height: 1, width: 2, inactiveLabel: false) { valueTile("networkAddress", "device.networkAddress", decoration: "flat", height: 2, width: 4, inactiveLabel: false) {
state "default", label:'${currentValue}', height: 1, width: 2, inactiveLabel: false state "default", label:'${currentValue}', height: 1, width: 2, inactiveLabel: false
} }
main (["icon"]) main (["icon"])
details(["networkAddress","serialNumber"]) details(["rich-control", "networkAddress"])
} }
} }
@@ -36,7 +44,6 @@ def parse(description) {
log.debug "Parsing '${description}'" log.debug "Parsing '${description}'"
def results = [] def results = []
def result = parent.parse(this, description) def result = parent.parse(this, description)
if (result instanceof physicalgraph.device.HubAction){ if (result instanceof physicalgraph.device.HubAction){
log.trace "HUE BRIDGE HubAction received -- DOES THIS EVER HAPPEN?" log.trace "HUE BRIDGE HubAction received -- DOES THIS EVER HAPPEN?"
results << result results << result
@@ -44,32 +51,30 @@ def parse(description) {
//do nothing //do nothing
log.trace "HUE BRIDGE was updated" log.trace "HUE BRIDGE was updated"
} else { } else {
log.trace "HUE BRIDGE, OTHER"
def map = description def map = description
if (description instanceof String) { if (description instanceof String) {
map = stringToMap(description) map = stringToMap(description)
} }
if (map?.name && map?.value) { if (map?.name && map?.value) {
log.trace "HUE BRIDGE, GENERATING EVENT: $map.name: $map.value" log.trace "HUE BRIDGE, GENERATING EVENT: $map.name: $map.value"
results << createEvent(name: "${map?.name}", value: "${map?.value}") results << createEvent(name: "${map.name}", value: "${map.value}")
} } else {
else { log.trace "Parsing description"
log.trace "HUE BRIDGE, OTHER"
def msg = parseLanMessage(description) def msg = parseLanMessage(description)
if (msg.body) { if (msg.body) {
def contentType = msg.headers["Content-Type"] def contentType = msg.headers["Content-Type"]
if (contentType?.contains("json")) { if (contentType?.contains("json")) {
def bulbs = new groovy.json.JsonSlurper().parseText(msg.body) def bulbs = new groovy.json.JsonSlurper().parseText(msg.body)
if (bulbs.state) { if (bulbs.state) {
log.warn "NOT PROCESSED: $msg.body" log.info "Bridge response: $msg.body"
} } else {
else { // Sending Bulbs List to parent"
log.debug "HUE BRIDGE, GENERATING BULB LIST EVENT: $bulbs" if (parent.state.inBulbDiscovery)
sendEvent(name: "bulbList", value: device.hub.id, isStateChange: true, data: bulbs, displayed: false) log.info parent.bulbListHandler(device.hub.id, msg.body)
} }
} }
else if (contentType?.contains("xml")) { else if (contentType?.contains("xml")) {
log.debug "HUE BRIDGE, SWALLOWING BRIDGE DESCRIPTION RESPONSE -- BRIDGE ALREADY PRESENT" log.debug "HUE BRIDGE ALREADY PRESENT"
} }
} }
} }