Is setting dimmer to 0 the same as turning off the switch?

You have the option to set a dimmer level to turn on the bulb at a specific brightness. You also have the option of turning on the switch or turning off the switch.

Does dim:0 do the same as turning the switch off?

1 Like

Typically, yes, but it depends on the driver, protocol, and device. An "off" is the best option if that is your goal (as it should work on any device).

3 Likes

I have found most drivers send an off command for level 0. You can see it easiest in the code for virtual dimmers:

if (level == 0) {
    off()
    return
}

When it calls off() for 0 level, off sets the switch attribute to off and sends the switch off event, so if your switch attribute returns to off when level goes to zero, then that is basically the same as turning off the switch directly. The question is what level it returns to when you turn the switch back on, which will be handled by the driver. To maintain last level, you will probably want to just turn off the switch. If you turn the switch back on using level, it wouldn't really matter, as any level adjustment will turn the switch back on and update the switch attribute and set the level to what you set.

if (device.currentValue("switch") != "on") on()

So, on most drivers, you could probably use level for everything and never use a switch command to turn things on and off. and on an off events will still be sent.

2 Likes

So I’ll start by saying there is probably a better way to do this, but I am using a virtual switch with the build in virtual switch driver as the front end to a broadlink remote to control a dc ceiling fan.

This way my wife can say “bedroom fan 2” and it sets it to speed 2.

Well she broke my integration the first night by saying “bedroom fan off”. I didn’t option for that I can tell you for sure that with the built in virtual dimmer, setting it to zero does in fact switch the switch off as well, but turning it off does not set it to zero.

I never thought of replacing the driver to modify the behavior there.

Thats the same conclusion i came to with my situation. Now when i turn off a light i reset the dimmer.