From b552bcc6f0a90bed85d4421df24d1ce8563412c9 Mon Sep 17 00:00:00 2001 From: Tom Manley Date: Tue, 2 May 2017 22:24:25 -0500 Subject: [PATCH] Fix recent regression with setting color temperature This fixes a recently introduced bug that caused an exception while attempting to set the color temperature on any of these three DTHs. https://smartthings.atlassian.net/browse/DVCSMP-2606 --- .../zigbee-white-color-temperature-bulb.groovy | 7 ++++++- .../zll-white-color-temperature-bulb-5000k.groovy | 7 ++++++- .../zll-white-color-temperature-bulb.groovy | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy b/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy index 0769667..6f913a4 100644 --- a/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy +++ b/devicetypes/smartthings/zigbee-white-color-temperature-bulb.src/zigbee-white-color-temperature-bulb.groovy @@ -71,6 +71,11 @@ metadata { } } +// Globals +private getMOVE_TO_COLOR_TEMPERATURE_COMMAND() { 0x0A } +private getCOLOR_CONTROL_CLUSTER() { 0x0300 } +private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 } + // Parse incoming device messages to generate events def parse(String description) { log.debug "description is $description" @@ -146,7 +151,7 @@ def setColorTemperature(value) { def tempInMired = (1000000 / value) as Integer def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4)) - zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") + + zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$finalHex 0000") + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) } diff --git a/devicetypes/smartthings/zll-white-color-temperature-bulb-5000k.src/zll-white-color-temperature-bulb-5000k.groovy b/devicetypes/smartthings/zll-white-color-temperature-bulb-5000k.src/zll-white-color-temperature-bulb-5000k.groovy index 1b83210..c4b09e7 100644 --- a/devicetypes/smartthings/zll-white-color-temperature-bulb-5000k.src/zll-white-color-temperature-bulb-5000k.groovy +++ b/devicetypes/smartthings/zll-white-color-temperature-bulb-5000k.src/zll-white-color-temperature-bulb-5000k.groovy @@ -66,6 +66,11 @@ metadata { } } +// Globals +private getMOVE_TO_COLOR_TEMPERATURE_COMMAND() { 0x0A } +private getCOLOR_CONTROL_CLUSTER() { 0x0300 } +private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 } + // Parse incoming device messages to generate events def parse(String description) { log.debug "description is $description" @@ -152,7 +157,7 @@ def setColorTemperature(value) { def tempInMired = (1000000 / value) as Integer def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4)) - zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") + + zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$finalHex 0000") + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) } diff --git a/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy b/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy index 8eee5fa..6264eb1 100644 --- a/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy +++ b/devicetypes/smartthings/zll-white-color-temperature-bulb.src/zll-white-color-temperature-bulb.groovy @@ -68,6 +68,11 @@ metadata { } } +// Globals +private getMOVE_TO_COLOR_TEMPERATURE_COMMAND() { 0x0A } +private getCOLOR_CONTROL_CLUSTER() { 0x0300 } +private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 } + // Parse incoming device messages to generate events def parse(String description) { log.debug "description is $description" @@ -147,7 +152,7 @@ def setColorTemperature(value) { def tempInMired = (1000000 / value) as Integer def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4)) - zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") + + zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$finalHex 0000") + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) }