mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-23 05:10:50 +00:00
Merge pull request #1151 from larsfinander/PROB-1352_Hue_colors_rendering_incorrectly_production
PROB-1352 Hue colors rendering incorrectly
This commit is contained in:
@@ -1017,12 +1017,12 @@ def setColor(childDevice, huesettings) {
|
|||||||
log.debug "Executing 'setColor($huesettings)'"
|
log.debug "Executing 'setColor($huesettings)'"
|
||||||
|
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
|
|
||||||
def value = [:]
|
def value = [:]
|
||||||
def hue = null
|
def hue = null
|
||||||
def sat = null
|
def sat = null
|
||||||
def xy = null
|
def xy = null
|
||||||
|
|
||||||
// For now ignore model to get a consistent color if same color is set across multiple devices
|
// For now ignore model to get a consistent color if same color is set across multiple devices
|
||||||
// def model = state.bulbs[getId(childDevice)]?.modelid
|
// def model = state.bulbs[getId(childDevice)]?.modelid
|
||||||
if (huesettings.hex != null) {
|
if (huesettings.hex != null) {
|
||||||
@@ -1038,11 +1038,12 @@ def setColor(childDevice, huesettings) {
|
|||||||
else
|
else
|
||||||
value.hue = Math.min(Math.round(childDevice.device?.currentValue("hue") * 65535 / 100), 65535)
|
value.hue = Math.min(Math.round(childDevice.device?.currentValue("hue") * 65535 / 100), 65535)
|
||||||
|
|
||||||
if (huesettings.saturation != null)
|
if (huesettings.saturation != null)
|
||||||
value.sat = Math.min(Math.round(huesettings.saturation * 254 / 100), 254)
|
value.sat = Math.min(Math.round(huesettings.saturation * 254 / 100), 254)
|
||||||
else
|
else
|
||||||
value.sat = Math.min(Math.round(childDevice.device?.currentValue("saturation") * 254 / 100), 254)
|
value.sat = Math.min(Math.round(childDevice.device?.currentValue("saturation") * 254 / 100), 254)
|
||||||
|
|
||||||
|
/* Disabled for now due to bad behavior via Lightning Wizard
|
||||||
if (!value.xy) {
|
if (!value.xy) {
|
||||||
// Below will translate values to hex->XY to take into account the color support of the different hue types
|
// Below will translate values to hex->XY to take into account the color support of the different hue types
|
||||||
def hex = colorUtil.hslToHex((int) huesettings.hue, (int) huesettings.saturation)
|
def hex = colorUtil.hslToHex((int) huesettings.hue, (int) huesettings.saturation)
|
||||||
@@ -1050,6 +1051,7 @@ def setColor(childDevice, huesettings) {
|
|||||||
// Once groups, or scenes are introduced it might be a good idea to use unique models again
|
// Once groups, or scenes are introduced it might be a good idea to use unique models again
|
||||||
value.xy = calculateXY(hex)
|
value.xy = calculateXY(hex)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Default behavior is to turn light on
|
// Default behavior is to turn light on
|
||||||
value.on = true
|
value.on = true
|
||||||
@@ -1059,7 +1061,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 * 254 / 100), 254)
|
value.bri = Math.min(Math.round(huesettings.level * 254 / 100), 254)
|
||||||
}
|
}
|
||||||
value.alert = huesettings.alert ? huesettings.alert : "none"
|
value.alert = huesettings.alert ? huesettings.alert : "none"
|
||||||
|
|||||||
Reference in New Issue
Block a user