TPLink plugin turns on dimmer when sending brightness

Back with openHAB 2, TPLink dimmer brightness could be controlled without turning the light on. This was useful for setting default dimmer levels appropriate for a time of day, or in response to other lights being on. However, since upgrading to openHAB 3, my rules relying on this behavior have all been broken as sending a brightness command turns the light on.

Has anybody else noticed a change in behavior here? Was this intentional?

I don’t recall that in OH2, but it’s been a long time since I used it. I seem to think that this is standard behaviour for dimmers in OH.

I go the other way and set brightness when a light is turned on, based on existing conditions. OH is always fast enough to adjust the brightness before I notice.

1 Like

Sounds like normal behavior to me. The TP-Link binding for HS220 dimmers doesn’t even have a separate on-off channel, only brightness (dimmer).

It definitely was the behavior back in OpenHab2, and it changed.

There’s only one channel, sure, but the channel supports the following commands:

OnOff, IncreaseDecrease, Percent, Refresh

The channel supports those commands, but sending a percentage command will generally turn on a dimmer to that percentage. That’s how my zwave dimmer works as well.

There’s a certain sensibility to a dimmer turning on when the brightness is changed, but I can appreciate that you’ve been used to a different behaviour. I feel like I may have started out that way as well in OH2, and then adapted to the convention when I upgraded. I think I started with 3.1.

Yes that behavior was there in the past and was changed in 2020 (pr7028) and has been available since 2.5.8.
The reason it changed was that the dimmer channel turned the dimmer off when the slider would be set to 0. This was unexpected behavior in the ui. Because sliding the dimmer to 0 and than to any other state would leave the dimmer off. In openHAB dimmer 0 is equivalent to off and any other value to on. Therefore the binding should react in this expected way.

If you want to only set the brightness there is a workaround possible. The binding nowadays contains an action that makes it possible to send any command (i.e. the json string) to a device. In your rules you can use this to set only the brightness. There is a test case that contains the command you need to send: dimmer_set_brightness.json

3 Likes

Thanks for the reply!

It wasn’t really clear from the documentation (in OpenHab, or anywhere), how to send a command to a ThingActions. After a bit of hacking and reading some OpenHab source code, I managed to come up with this (which worked!):

master_bath.rules:

rule "Master bath desired level changes"
when
    Item MasterBath_DesiredDimmerLevel changed
then
    val cmd = '{"smartlife.iot.dimmer":{"set_brightness":{"brightness":' + MasterBath_DesiredDimmerLevel.state + '}}}'
    val actions = getActions("tplinksmarthome", "tplinksmarthome:hs220:123ABC")
    actions.send(cmd)
end

Is this how you would have done it? Or is there a better way? (and, is this documented anywhere? I promise, I really did try and find my own answers here)

Documentation PR: [tplinksmarthome] Document sending raw commands to devices by timcharper · Pull Request #14062 · openhab/openhab-addons · GitHub

1 Like