Hi, I am developing a Zigbee light controlled the dim and color temperature for smartthings.
I have been self-publishing the product on the developer site with reference to other developed products, but I have a problem with the color temp UI.
I set the range from 2700 to 6000 but the range of 0-100K is displayed in the executed UI.
The code I posted is below. Somebody help me ~
And I can’t set the runLocally: false attribute to true, is this correct?
- My Device Handlers Code -
Blockquote
metadata {
definition (name: “First Light”, namespace: “smartthings”, author: “SmartThings”, runLocally: false, minHubCoreVersion: ‘000.019.00012’, executeCommandsLocally: true) {
capability "Actuator"
capability "Color Temperature"
capability "Configuration"
capability "Health Check"
capability "Refresh"
capability "Switch"
capability "Switch Level"
capability "Light"
attribute "colorName", "string"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0006,0008,0300", manufacturer: "MyHome", model: "MYLIGHT", deviceJoinName: "TESTLIGHT"
}
// UI tile definitions
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
}
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel"
}
}
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", width: 4, height: 2, inactiveLabel: false, range:"(2700..6000)") {
state "colorTemperature", action:"color temperature.setColorTemperature"
}
valueTile("colorName", "device.colorName", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "colorName", label: '${currentValue}'
}
main(["switch"])
details(["switch", "colorTempSliderControl", "colorName", "refresh"])
}
}
// 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”
def event = zigbee.getEvent(description)
if (event) {
if (event.name == “level” && event.value == 0) {}
else {
if (event.name == “colorTemperature”) {
setGenericName(event.value)
}
sendEvent(event)
}
}
else {
def cluster = zigbee.parse(description)
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
if (cluster.data[0] == 0x00) {
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
}
}
else {
log.warn "DID NOT PARSE MESSAGE for description : $description"
log.debug "${cluster}"
}
}
}
def off() {
zigbee.off()
}
def on() {
zigbee.on()
}
def setLevel(value) {
zigbee.setLevel(value,5) +
zigbee.readAttribute(0006, 0000)
}
/**
- PING is used by Device-Watch in attempt to reach the Device
- */
def ping() {
return zigbee.onOffRefresh()
}
def refresh() {
zigbee.onOffRefresh() +
zigbee.levelRefresh() +
zigbee.colorTemperatureRefresh() +
zigbee.onOffConfig(0, 300) +
zigbee.levelConfig()
}
def configure() {
log.debug “Configuring Reporting and Bindings.”
// Device-Watch allows 2 check-in misses from device + ping (plus 1 min lag time)
// enrolls with default periodic reporting until newer 5 min interval is confirmed
sendEvent(name: “checkInterval”, value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: “zigbee”, hubHardwareId: device.hub.hardwareID])
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
refresh()
}
def setColorTemperature(value) {
value = value as Integer
def tempInMired = Math.round(1000000 / value)
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
List cmds = []
if (device.getDataValue("manufacturer") == "MYHOME" && device.getDataValue("model") == "MYLIGHT") {
// Sengled Element Plus will ignore the command if the transition time is 0x0000
cmds << zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$finalHex 1000")
} else {
cmds << zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$finalHex 1000")
}
cmds << zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE)
cmds
}
//Naming based on the wiki article here: Color temperature - Wikipedia
def setGenericName(value){
if (value != null) {
def genericName = “White”
if (value < 3300) {
genericName = “Soft White”
} else if (value < 4150) {
genericName = “Moonlight”
} else if (value <= 5000) {
genericName = “Cool White”
} else if (value >= 5000) {
genericName = “Daylight”
}
sendEvent(name: “colorName”, value: genericName)
}
}
def installed() {
sendEvent(name: “level”, value: 100)
}
Blockquote