Skip to content

Commit

Permalink
Merge pull request SmartThingsCommunity#542 from larsfinander/lifxExc…
Browse files Browse the repository at this point in the history
…eptionFix

DVCSMP-1505 LIFX setColor() throws exception
  • Loading branch information
larsfinander committed Feb 24, 2016
2 parents 3130e6a + 42b790e commit f616dcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def setHue(percentage) {
log.error("Bad setHue result: [${resp.status}] ${resp.data}")
}
}
return []
}

def setSaturation(percentage) {
Expand All @@ -97,6 +98,7 @@ def setSaturation(percentage) {
log.error("Bad setSaturation result: [${resp.status}] ${resp.data}")
}
}
return []
}

def setColor(Map color) {
Expand All @@ -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) {
Expand All @@ -150,6 +154,7 @@ def setLevel(percentage) {
log.error("Bad setLevel result: [${resp.status}] ${resp.data}")
}
}
return []
}

def setColorTemperature(kelvin) {
Expand All @@ -165,6 +170,7 @@ def setColorTemperature(kelvin) {
}

}
return []
}

def on() {
Expand All @@ -174,6 +180,7 @@ def on() {
sendEvent(name: "switch", value: "on")
}
}
return []
}

def off() {
Expand All @@ -183,6 +190,7 @@ def off() {
sendEvent(name: "switch", value: "off")
}
}
return []
}

def poll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def setLevel(percentage) {
log.error("Bad setLevel result: [${resp.status}] ${resp.data}")
}
}
return []
}

def setColorTemperature(kelvin) {
Expand All @@ -99,6 +100,7 @@ def setColorTemperature(kelvin) {
log.error("Bad setColorTemperature result: [${resp.status}] ${resp.data}")
}
}
return []
}

def on() {
Expand All @@ -108,6 +110,7 @@ def on() {
sendEvent(name: "switch", value: "on")
}
}
return []
}

def off() {
Expand All @@ -117,6 +120,7 @@ def off() {
sendEvent(name: "switch", value: "off")
}
}
return []
}

def poll() {
Expand Down

0 comments on commit f616dcb

Please sign in to comment.