Kasa binding - change transition period programmatically?

I have a bunch of kasa smart lights set up outside, and I was brainstorming ways of using them in holiday decoration setups. While thinking about ways to make them cycle through colors, I realized that I could simplify things a lot if I set up those lights to have very long transition periods, and then just set a large color change every minute or so. (Otherwise, I’d have to to set the rule up to run a series of much smaller color change every second or so, in order to get smooth-but-slow transitions.)

This could also be handy in setting up sunrise emulation for wake-up alarms, slowly dimming the lights at night, setting up a “Party” mode that plays through color cycles, etc…

The problem with setting a very long transition period is that there are times when I want the lights to react more quickly. And as far as I can tell, the only way to adjust the transition period is to change the Thing configuration on the UI.

Is there a way to change the transition period using a rule? Maybe some sort of hidden channel that can receive commands in milliseconds? Or, a way to programmatically adjust and save the Thing code?

If not, no worries! Just figured I’d ask!

Not easily. The only way I know of to do that is to use the REST API from the rule to do the same thing that the Thing settings page does.

You might file a feature request issue on the binding to convert the configuration parameter to become a Channel which will let you link it to an Item and send commands, though there might be technical reasons why they didn’t do that in the first place.

Thanks, Rich. I’ll put in that feature request, and in the meantime, I’ll look into using the REST API to change the configuration on a once-in-a-while basis, just for when I set up a holiday decor scene. I use node-red for my rules, and I’m pretty sure I can send REST commands relatively easily from there.

Another thing I thought of was that it would be very cool if the transition period could be specified in the same command as the light value. Instead of HSB, it could be HSBT. So the value would be something like (115, 90, 90, 2000), where the last number is transition time in milliseconds, and works only apply to that specific command.

But I imagine that would require creating a whole new type of item at the system-wide level… A big ask, and something that probably wouldn’t happen unless I can learn enough about coding to create a suggested implementation myself…

Transition period is not a channel because the transition period is not available in the device data. Channels are basically are representation of the physical data of the device. Also the transition period needs to be send with the other data, which means it would require combining data from one channel with a new command, making it difficult to synchronize.
Having a new data type (that combines color and transition period) is not possible as openHAB has a strict set of command/states, that are not extendable (as of why is a whole other discussion).

A solution could be actions are added to the binding. That way from a rule a command with transaction period could be given.

A current workaround might be to create a second thing to the same device with a different transaction period configured. But I’m not sure if that works as I haven’t tested it.

Thanks for that info, Hilbrand, and for all of your work on this binding. If you decide to add actions to the binding some day, I’d be happy to help test it out!
Meanwhile, your suggestion to create a duplicate Thing with a different transition period appears to be working perfectly. Thanks!

1 Like