Control Hue, Sat, Kelvin, and Brightness Individually

I have a little bit problem regarding controlling hue, sat, kelvin, and brightness Individually .

I have a question how can I set increase the brightness value without changing the existing hue and sat?

Because issue that I found, if I does not add any value for hue and sat (which mean 0) during sending message to increase the brightness, the light will changed the color to red and then it will adjust the brightness. I don’t want it to change color, I just want it to increase the brightness.

Help me. Thank you in advance.

Hi Adam,

To maintain the hue, I do a GetColor request to retrieve the current Hue, Brightness, Kelvin and Saturation values. I then structure my packets to maintain some of the existing values and adjust the parameters depending on my use-case. You can do this with a setColor send packet request. So it’s a GetColor, then SetColor sequence of requests.

1 Like

Hi firedance,

Thank you for your respond, I do appreciated it.

Currently I’m developing application that may control lifx light through other physical device and it’s not quite really convenient to keep asking the status because it will delay the process. So I’m wondering, do they have function where I can increase the brightness without effecting the colour and without my device to store the previous value of hue, sat, and kelvin? If they do have this functionality, may I have the link to the documentation.

Thank you.

Hi Adam, thanks.

I understand what you mean. Unfortunately, they do not have a way to do this over UDP. The packet has to be constructed with the existing parameters for Hue/Sat/Kelvin/Brightness/Duration.

I perform the same operations in a low-level implementation of Rust with UDP and it seems to work really fast for me. Is your code in Java? Does your code await a response from the LiFX device(s) after you send the setColor packet? If so, would you be able to get rid of awaiting the response from the devices and performing a “fire and forget?”

Alternatively, you could try the setLightPower state. The duration is adjustable, which will make the light appear as if the brightness is fluctuating.

1 Like

Yes, they do. Use the SetWaveformOptional packet which allows you to specify one or more of the HSBK values to change instead of requiring all of them. The bulb will then calculate and perform the transform between the current and target state.

3 Likes

Hi @Djelibeybi

I have use SetWaveformOptional - Packet 119 it is not working
I tried using the SetWaveform - Packet 103 also but did not working

I hope you can shed some light here

These are the data I sent for SetWaveform - Packet 103 to try using waveform:

transient= 0; (so it may not restore the previous colour, maintain the current colour set)

duration=1 second

cycle (I think this is how many cycles you want to be in that new colour) = 20 cycles
But this is quite weird because the expected value is float of 4 bytes

skew ratio=0; (this is actually 0.5 ratio, hence duty cycle = 1-0.5=0.5)

waveform=4 (pulse)

hue/saturation/brightness = 65535 (just for sake of testing set max)

kelvin= 65535 (just for sake of testing set max)

Like for SetColor - Packet 102 I have no problem

Thanks

You’re missing some of the required values. The payload of a SetWaveformOptional packet should look like this:

    "brightness": 0.9,
    "cycles": 1.0,
    "hue": 120.0,
    "kelvin": 0,
    "period": 10.0,
    "reserved6": "00",
    "saturation": 0.8,
    "set_brightness": 1,
    "set_hue": 1,
    "set_kelvin": 0,
    "set_saturation": 1,
    "skew_ratio": 0.0,
    "transient": 0,
    "waveform": 0

In particular, you need to set set_hue, set_brightness, set_saturation and set_kelvin to 1 if you want your values to be used or 0 if you want the existing value on the device to be used.

The period: 10 means this transition will happen over 10 seconds.

Also, if the device is not in the right power state, i.e. you need to turn it on or off, you should send a SetLightPower (117) with duration set to the same value as period in the SetWaveformOptional packet.

Setting waveform: 2 (half-sine) makes the transition smoother between the current and target color though it’s not really noticeable (in my opinion) unless the change is significant and the duration of the transform is longer than 2-3 seconds.

Hi @Djelibeybi

Understood I need to plug in those is_set_hue/kelvin/saturation/brightness.
I am aware of that.

Regardless I plugged in those value, I don’t really got the transition working

Say I want to change from blue to red colour without affecting other attributes, even using the basic SetWaveform packet 103 is not working for me as well. I think if I might get packet 103 working I might get the SetWaveformOptional packet 119 working

Btw, what do you mean by this?

" Also, if the device is not in the right power state, i.e. you need to turn it on or off, you should send a SetLightPower (117) with duration set to the same value as period in the SetWaveformOptional packet."

Do I need to make sure the SetLightPower (117) duration equal when using SetWaveFormOptional (119)?

Thanks

Yes, if you’re changing the power state. If you’re not, don’t send the packet at all.

I strongly suggest getting SetColor (102) working first by sending a LightState and then just replacing the values you want to change. Once you have that working, you can then get 119 working.