Dim to Level 0 vs. Off

Hi there -

Done some searching on this but haven’t found the information I’m looking for. I have taken a custom device type for my Lightify bulb and made a few changes so that the bulb “dims” on/off. Essentially I’ve just replaced the ON command with setLevel 99 and the OFF command with setLevel 0.

def on() {
log.debug "on()"
sendEvent(name: "level", value: 100)
sendEvent(name: "switch", value: "on")
"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {fe 1500}"
}

def off() {
	log.debug "off()"
	sendEvent(name: "level", value: 0)
    sendEvent(name: "switch", value: "off")
	"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {00 1500}"
}

Question then, is if there is any harm in having the bulb “off” by setLevel 0? Will the bulb itself think it is still on or draw additional power?

I tried following up my dim to 0 command with an actual off command, but they are sent so quickly that it nulls my dimming off function. I tried to add a sleep command, but couldn’t get it to work.

def off() {
	log.debug "off()"
	sendEvent(name: "level", value: 0)
    sendEvent(name: "switch", value: "off")
	"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {00 1500}"
    sleep(2000)
    "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 0 {}"
}

Fairly new to the SmartThings (and groovy) world - any information is appreciated!

Thanks

No harm. The level and on/off are linked in zigbee. The bulb will automatically update its internal on/off attribute to off when it is set to its minimum “level”. Same thing happens when you set the level to 99, the bulb automatically updates to “on”.

The one thing you lose in this method is that your “on” command will always go to full brightness. A normal “on” command returns the bulb to the last brightness before turning off. But I guess setting it to level 0 instead of “off” nullifies that function anyway.

Note: Zigbee allows for dim transitions during on/off commands via an attribute. That feature is built into the DTH you linked to (see the first command in the updated() method). You may need to update the firmware on your bulb to enable it though because Lightify bulbs had a couple quirks initially. You can do that via the Lightify Gateway.

3 Likes

Fyi there is zigbee.setLevel command that is a higher level abstraction for setting the level than using st cmd. If you use that to set the level to 0 it will turn the bulb off instead of actually setting the level to 0. That way the next time you turn it on with the on command it will come back to the previous level.

http://docs.smartthings.com/en/latest/ref-docs/zigbee-ref.html#zigbee-setlevel

2 Likes

Thanks Scott and Tom! I’ll give the transition attribute a shot as well. We are connecting this directly to ST and don’t have the Lighting gateway, so not sure if the firmware is up to date or not.

Also chiming in to echo Scott. No harm.