Merge pull request #542 from larsfinander/lifxExceptionFix

DVCSMP-1505 LIFX setColor() throws exception
This commit is contained in:
Lars Finander
2016-02-24 15:27:26 -08:00
2 changed files with 13 additions and 1 deletions

View File

@@ -84,6 +84,7 @@ def setHue(percentage) {
log.error("Bad setHue result: [${resp.status}] ${resp.data}")
}
}
return []
}
def setSaturation(percentage) {
@@ -97,6 +98,7 @@ def setSaturation(percentage) {
log.error("Bad setSaturation result: [${resp.status}] ${resp.data}")
}
}
return []
}
def setColor(Map color) {
@@ -122,13 +124,15 @@ def setColor(Map color) {
parent.logErrors(logObject:log) {
def resp = parent.apiPUT("/lights/${selector()}/state", [color: attrs.join(" "), power: "on"])
if (resp.status < 300) {
sendEvent(name: "color", value: color.hex)
if (color.hex)
sendEvent(name: "color", value: color.hex)
sendEvent(name: "switch", value: "on")
events.each { sendEvent(it) }
} else {
log.error("Bad setColor result: [${resp.status}] ${resp.data}")
}
}
return []
}
def setLevel(percentage) {
@@ -150,6 +154,7 @@ def setLevel(percentage) {
log.error("Bad setLevel result: [${resp.status}] ${resp.data}")
}
}
return []
}
def setColorTemperature(kelvin) {
@@ -165,6 +170,7 @@ def setColorTemperature(kelvin) {
}
}
return []
}
def on() {
@@ -174,6 +180,7 @@ def on() {
sendEvent(name: "switch", value: "on")
}
}
return []
}
def off() {
@@ -183,6 +190,7 @@ def off() {
sendEvent(name: "switch", value: "off")
}
}
return []
}
def poll() {

View File

@@ -84,6 +84,7 @@ def setLevel(percentage) {
log.error("Bad setLevel result: [${resp.status}] ${resp.data}")
}
}
return []
}
def setColorTemperature(kelvin) {
@@ -99,6 +100,7 @@ def setColorTemperature(kelvin) {
log.error("Bad setColorTemperature result: [${resp.status}] ${resp.data}")
}
}
return []
}
def on() {
@@ -108,6 +110,7 @@ def on() {
sendEvent(name: "switch", value: "on")
}
}
return []
}
def off() {
@@ -117,6 +120,7 @@ def off() {
sendEvent(name: "switch", value: "off")
}
}
return []
}
def poll() {