LIFX Developer Zone

Interruption of transitions with long duration

I’d like to know whether transitions are linear, or do they follow a curve. This thread suggests they are linear, I’d like to confirm how this behaves. This thread alsosuggests that changing the power state should not interrupt transitions.

I’m using node red with node-red-contrib-node-lifx (uses node-lifx library). I set a transition to red for 1 hour in the evenings. My kitchen lights are motion-activated, and what I’ve found is that setting lights to on/off interrupts the transition and causes it to halt where it is. I’m setting only {“on”: true/false} so this should not affect anything else. Interruption of the transition could be a behaviour of the particular node red control system I’m using.

To get around this, for the motion-activated lights I’ve put in place a “reminder” of the transition that they are supposed to be following as follows:
Send command to change to hue 0 (red), saturation 100 over 1 hour
After 5 minutes, send command hue 0, sat 100 over 55 minutes
and so on, reducing duration by 5 minutes each time for the whole hour

I figured this would get the lights to arrive at full red after 1 hour regardless if they were interrupted i.e. to speed the transition up a bit each time if necessary.

Actually, what I’ve found is that these lights arrive at the full red within about 20 minutes with this method. I thought that maybe the transition is following a curve rather than being linear, such that the initial rate of transition is quicker and that sending this command multiple times caused the lights to get to the endpoint sooner. But the thread linked above suggests it should be linear (and also that simply sending on/off commands shouldn’t interrupt it, but again that could be a behaviour of the node red module).

Hope this makes sense! I’d like confirmation of how transitions behave so that I can try to troubleshoot/solve my approach.

Thanks! Great lights by the way, and the LAN protocol is very helpful for what I need.

Hello,

I assume this is using the HTTP API?

Whenever you use the /v1/lights/:selector/state endpoint we stop any firmware effects and waveforms on the device; and we have not made this optional.

When we set a color, the cloud will send a SetWaveformOptional with a SAW waveform to the device, which means it is linear.

To be honest, I’m not entirely sure why what you’re doing would make that transition only take 20 minutes. I made a script that does that change over 60 seconds and it seems to work correctly for me (maybe it’s different over the full hour)

You can get the script here.

python3 -m venv .photons_core
source .photons_core/bin/activate
pip install lifx-photons-core
python set_red.py d073d5001337

Every 5 seconds it’ll send a new SetWaveformOptional with a period of the remaining seconds and then it’ll get the current state after this and print the saturation to the terminal.

How have you setup the motion detection? Is it on the same network and able to use the LAN API instead of the HTTP API. In that scenario, sending a SetLightPower will not interrupt the waveform.

Hi there, thanks for the response. I’m using the LAN API. The scripts for that are not my own, they are addon modules of the Node-RED system. I don’t know Python to use your code, or javascript to modify the module I’m using.
I believe that when I send a command on/off, the code uses setPower (0/65535 are the values from what I can read of the code) and it also sets duration. Would the duration interrupt the transition? In this case I’m talking about a transition over an hour from one colour to another. I guess maybe setting a duration has started a new transition instead.

You’ve answered my question that it could be linear, but that you have different transition shapes that are referred to as waveforms.

If you can let me know whether setting duration on the on/off command would interrupt the waveform transition, that would be helpful. For the rest, I’m going to have to dig into the code I’m using or ask the developers of that code.

Thanks again!

I did a test just now and setting Power does not affect a running waveform.

Just to confirm, that’s using a duration of e.g. 1 second on the on/off command?

If you set any duration with power, it creates a new transition. So avoid that completely if you want the running transition to persist.

I do this in with motion sensors and HomeKit while transitions that are triggered by https://github.com/djelibeybi/docker-lifx-daydusk are still running and it works perfectly.

Changing power with or without duration does not affect waveforms.

Really? Is that new? I’ve had transitions get interrupted by a power-with-duration command before.

If it’s via the HTTP API then that’s because we turn off firmware effects and waveforms on the state endpoint.

You can try this out yourself with the LAN api using photons

lifx lan:transform match:label=den -- '{"color": "yellow", "power": "on", "brightness": 1}'
lifx lan:transform match:label=den -- '{"color": "blue", "duration": 30}'
lifx lan:transform match:label=den -- '{"power": "off", "duration": 30}'

Thank you I have enough info in hand now. A module developer over at node Red is looking over the code and there are some implementation oversights on this point, so we think we the issue is with that module and are professing towards a fix.

Thanks to all here for the help. It’s even more interesting to me now than when I first bought a LIFX bulb! I’ll no doubt be back at some point, having learnt a more modern programming language to reflect the environments I’m actually using.

Cheers,

Andobi

1 Like