mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-08 05:31:56 +00:00
PRP-172 Fix Hue Connect parse errors on newer versions of Groovy
This commit is contained in:
@@ -689,7 +689,7 @@ def parse(childDevice, description) {
|
|||||||
log.warn "Parsing Body failed - trying again..."
|
log.warn "Parsing Body failed - trying again..."
|
||||||
poll()
|
poll()
|
||||||
}
|
}
|
||||||
if (body instanceof java.util.HashMap) {
|
if (body instanceof java.util.Map) {
|
||||||
//poll response
|
//poll response
|
||||||
def bulbs = getChildDevices()
|
def bulbs = getChildDevices()
|
||||||
for (bulb in body) {
|
for (bulb in body) {
|
||||||
@@ -830,22 +830,22 @@ def setColorTemperature(childDevice, huesettings) {
|
|||||||
|
|
||||||
def setColor(childDevice, huesettings) {
|
def setColor(childDevice, huesettings) {
|
||||||
log.debug "Executing 'setColor($huesettings)'"
|
log.debug "Executing 'setColor($huesettings)'"
|
||||||
|
|
||||||
def value = [:]
|
def value = [:]
|
||||||
def hue = null
|
def hue = null
|
||||||
def sat = null
|
def sat = null
|
||||||
def xy = null
|
def xy = null
|
||||||
|
|
||||||
if (huesettings.hex != null) {
|
if (huesettings.hex != null) {
|
||||||
value.xy = getHextoXY(huesettings.hex)
|
value.xy = getHextoXY(huesettings.hex)
|
||||||
} else {
|
} else {
|
||||||
if (huesettings.hue != null)
|
if (huesettings.hue != null)
|
||||||
value.hue = Math.min(Math.round(huesettings.hue * 65535 / 100), 65535)
|
value.hue = Math.min(Math.round(huesettings.hue * 65535 / 100), 65535)
|
||||||
if (huesettings.saturation != null)
|
if (huesettings.saturation != null)
|
||||||
value.sat = Math.min(Math.round(huesettings.saturation * 255 / 100), 255)
|
value.sat = Math.min(Math.round(huesettings.saturation * 255 / 100), 255)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default behavior is to turn light on
|
// Default behavior is to turn light on
|
||||||
value.on = true
|
value.on = true
|
||||||
|
|
||||||
if (huesettings.level != null) {
|
if (huesettings.level != null) {
|
||||||
@@ -853,7 +853,7 @@ def setColor(childDevice, huesettings) {
|
|||||||
value.on = false
|
value.on = false
|
||||||
else if (huesettings.level == 1)
|
else if (huesettings.level == 1)
|
||||||
value.bri = 1
|
value.bri = 1
|
||||||
else
|
else
|
||||||
value.bri = Math.min(Math.round(huesettings.level * 255 / 100), 255)
|
value.bri = Math.min(Math.round(huesettings.level * 255 / 100), 255)
|
||||||
}
|
}
|
||||||
value.alert = huesettings.alert ? huesettings.alert : "none"
|
value.alert = huesettings.alert ? huesettings.alert : "none"
|
||||||
|
|||||||
Reference in New Issue
Block a user