adaptive-lighting icon indicating copy to clipboard operation
adaptive-lighting copied to clipboard

Ability to adjust horizon for max brightness and min color temp

Open jacob3089 opened this issue 3 years ago • 1 comments

I was wondering if you could consider allowing adjustment of the horizon for max brightness and min color temp. Right now it is at sunrise and sunset without the ability to configure it. I would like to both have a cooler color temp at sunset, getting warmer into the evening and also not have peak light brightness right at sunrise. I have a proposal for enabling this functionality below. Two configurable settings would need to be added.

brightness_horizon_offset: percent above horizon where max brightness will be reached; default 0.

color_temp_horizon_offset: percent below horizon where min color temp will be reached; default 0.

I have one option of a working implementation with the code below.

 def calc_brightness_pct(self, percent: float, is_sleep: bool) -> float:
    """Calculate the brightness in %."""
    if is_sleep:
        return self.sleep_brightness
    if percent > (0 + brightness_horizon_offset):
        return self.max_brightness
    delta_brightness = self.max_brightness - self.min_brightness
    return (delta_brightness * (1 + percent) / (1 + brightness_horizon_offset)) + self.min_brightness

def calc_color_temp_kelvin(self, percent: float, is_sleep: bool) -> float:
    """Calculate the color temperature in Kelvin."""
    if is_sleep:
        return self.sleep_color_temp
    if percent > (0 - color_temp_horizon_offset):
        delta = self.max_color_temp - self.min_color_temp
        return (delta * (percent + color_temp_horizon_offset) / (1 + color_temp_horizon_offset)) + self.min_color_temp
    return self.min_color_temp`

jacob3089 avatar Jun 01 '21 02:06 jacob3089

The current behaviour of sunrise -> 100% brightness can be quite harsh to wake up to

I'm using automations to turn off sleep mode at sunrise, in combination with sunrise_offset to try to implement some gradual brightness adjustments in the morning, but this still isn't quite what I'd like

I think the proposed solution is neat, because it's a more direct way of influencing gradual brightness relative to the sun's position

jokeyrhyme avatar Oct 18 '21 01:10 jokeyrhyme

Check out the new brightness_mode feature introduced in 1.19.0: https://github.com/basnijholt/adaptive-lighting/blob/104664d3588442730f7ea9e811dd1986aca0c2e8/README.md#custom-brightness-ramps-using-brightness_mode-with-linear-and-tanh

This should give you enough control to separate brightness and color.

Some more examples: Notice the values of brightness_mode_time_light and brightness_mode_time_dark in the text box. image image image image

basnijholt avatar Aug 06 '23 20:08 basnijholt

Check out this new webapp to visualize the parameters https://basnijholt.github.io/adaptive-lighting/

adaptive-lighting

https://github.com/basnijholt/adaptive-lighting/assets/6897215/68908f7d-fbf1-4991-98ce-3f2af6df996f

basnijholt avatar Aug 09 '23 01:08 basnijholt

New brightness control is great! Thanks!

jacob3089 avatar Aug 10 '23 23:08 jacob3089

I am glad you like it 😄

basnijholt avatar Aug 11 '23 00:08 basnijholt