@@ -77,6 +77,7 @@ Boolean hasCapabilityBattery() { return device.hasCapability('Battery') == true
7777Boolean hasCapabilityColorControl () { return device. hasCapability(' ColorControl' ) == true }
7878Boolean hasCapabilityColorMode () { return device. hasCapability(' ColorMode' ) == true }
7979Boolean hasCapabilityColorTemperature () { return device. hasCapability(' ColorTemperature' ) == true }
80+ Boolean hasCapabilityWhiteLevel () { return device. hasAttribute(' whiteLevel' ) == true }
8081Boolean hasCapabilityLight () { return device. hasCapability(' Light' ) == true }
8182Boolean hasCapabilitySwitch () { return device. hasCapability(' Switch' ) == true }
8283Boolean hasCapabilityPresence () { return device. hasCapability(' PresenceSensor' ) == true }
@@ -1125,6 +1126,12 @@ void setWhiteLevelAttribute(Integer whiteLevel, ChildDeviceWrapper child = null)
11251126 else {sendDeviceEvent([name : ' whiteLevel' , value : whiteLevel, unit : ' %' ])}
11261127}
11271128
1129+ @CompileStatic
1130+ void setColorTemperatureAttribute (Integer colorTemperature , ChildDeviceWrapper child = null ) {
1131+ if (child != null ) {sendChildDeviceEvent([name : ' colorTemperature' , value : colorTemperature, unit : ' °K' ], child)}
1132+ else {sendDeviceEvent([name : ' colorTemperature' , value : colorTemperature, unit : ' °K' ])}
1133+ }
1134+
11281135void setColorModeAttribute (String colorMode ) {
11291136 if (colorMode in [' CT' , ' RGB' , ' EFFECTS' ]) {
11301137 sendDeviceEvent([name : ' colorMode' , value : colorMode])
@@ -3780,10 +3787,14 @@ void processGen1LightStatus(Map json, Integer index = 0) {
37803787 Boolean isOn = json?. ison as Boolean
37813788 if (isOn != null ) {setSwitchState(isOn)}
37823789 Integer whiteLevel = json?. white as Integer
3783- if (whiteLevel != null ) {
3790+ if (whiteLevel != null && hasCapabilityWhiteLevel() == true ) {
37843791 whiteLevel = (Integer )(whiteLevel/ 255 )
37853792 setWhiteLevelAttribute(whiteLevel)
37863793 }
3794+ Integer colorTemp = json?. temp as Integer
3795+ if (colorTemp != null && hasCapabilityColorTemperature() == true ) {
3796+ setColorTemperatureAttribute(colorTemp)
3797+ }
37873798}
37883799
37893800@CompileStatic
0 commit comments