Automation to change light temp/brightness while it is on - how?

Honestly I was hoping someone more knowledgeable would stop by to answer… but yes I would expect that you could edit the file and then restart HA and you would be golden.

I have never done that, so don’t know if it would be permanent through an update or not.

Finally had time to look at this…

I edited lifx.py in two places, replaced the current color temperature calculation with the following:

place 1

def color_temp(self):
    """Return the color temperature."""
    #temperature = int(TEMP_MIN_HASS + (TEMP_MAX_HASS - TEMP_MIN_HASS) *
    #                  (self._kel - TEMP_MIN) / (TEMP_MAX - TEMP_MIN))
    temperature = int(1000000 / self._kel)

place 2

    if ATTR_COLOR_TEMP in kwargs:
        # pylint: disable=fixme
        # TODO: Use color_temperature_mired_to_kelvin from util.color
        #kelvin = int(((TEMP_MAX - TEMP_MIN) *
        #              (kwargs[ATTR_COLOR_TEMP] - TEMP_MIN_HASS) /
        #              (TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
        kelvin = int(1000000/kwargs[ATTR_COLOR_TEMP])

After that (and hass restart) I see the expected colors from the bulbs, and they match what flux tells them to be.

2 Likes

Thanks @aymercury, this did the trick! :slight_smile:

@aymercury can you tell me where to find the lifx.py file?

Also, do either of you know how to tell flux not to adjust brightness? I tried setting it to brightness: -1
but got this error

Invalid config for [switch.flux]: value must be at least 0 for dictionary value @ data[‘brightness’]. Got -1.

I replied in some other thread with the file location.

For brightness I used 0-255 values, 100 for dim movie mode, for example.

I’m sure you already found the answer to your question, but just in case anyone else is looking, you can disable brightness adjustment with the following:

> disable_brightness_adjust: True