SHARD-174: Hue (Connect) updated() calls can fail in certain situations

This commit is contained in:
Luke Bredeson
2016-04-28 11:06:16 -05:00
parent 88dd510e72
commit 1c4386a67b

View File

@@ -332,8 +332,7 @@ private addChildBulb(dni, hueType, name, hub, update=false, device = null) {
if (deviceType) {
return addChildDevice("smartthings", deviceType, dni, hub, ["label": name])
}
else {
} else {
log.warn "Device type $hueType not supported"
return null
}
@@ -349,8 +348,10 @@ def addBulbs() {
newHueBulb = bulbs.find { (app.id + "/" + it.value.id) == dni }
if (newHueBulb != null) {
d = addChildBulb(dni, newHueBulb?.value?.type, newHueBulb?.value?.name, newHueBulb?.value?.hub)
log.debug "created ${d.displayName} with id $dni"
d.refresh()
if (d) {
log.debug "created ${d.displayName} with id $dni"
d.refresh()
}
} else {
log.debug "$dni in not longer paired to the Hue Bridge or ID changed"
}
@@ -358,7 +359,7 @@ def addBulbs() {
//backwards compatable
newHueBulb = bulbs.find { (app.id + "/" + it.id) == dni }
d = addChildBulb(dni, "Extended Color Light", newHueBulb?.value?.name, newHueBulb?.value?.hub)
d.refresh()
d?.refresh()
}
} else {
log.debug "found ${d.displayName} with id $dni already exists, type: '$d.typeName'"