mclarkk / lifxlan

Python library for accessing LIFX devices locally using the official LIFX LAN protocol.
MIT License
503 stars 115 forks source link

Setting multizone light brightness correctly? #141

Open LinqLover opened 4 years ago

LinqLover commented 4 years ago

Using the LIFX app, I can change the brightness of my light strip so that each color zone is set to the target brightness. However, if I call set_brightness(32768) on a MultiZoneLight, this will reset all color zones to the same color.

Did someone already face or investigate the issue?

Does the LAN protocol provide a solution for this or does the client manually need to implement this? I am new to this project, but could you maybe use SetWaveformOptional, or is this only for animations?

Provided that the firmer is the case and we need to implement this manually, I would propose to override set_brightness (and maybe also set_{hue,saturation,colortemp}?) in MultiZoneLight to do this for all zones separately. Pseudo:

# brightness in range [0 - 65535]
def set_brightness(self, brightness, duration=0, rapid=False):
    """ brightness to set
        duration in ms"""
    current_colors = self.get_color_zones()
    next_colors = [(hue, sat, brightness, kelvin) for (hue, sat, _, kelvin) in current_colors]
    return self.set_zone_colors(next_colors, duration=duration, rapid=rapid)

If you are interested, I'd be happy to send you a PR!

mclarkk commented 3 years ago

Great find -- yes, I've love a PR!