adaptive-lighting
adaptive-lighting copied to clipboard
Ability to adjust horizon for max brightness and min color temp
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`
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
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.
Check out this new webapp to visualize the parameters https://basnijholt.github.io/adaptive-lighting/
https://github.com/basnijholt/adaptive-lighting/assets/6897215/68908f7d-fbf1-4991-98ce-3f2af6df996f
New brightness control is great! Thanks!
I am glad you like it 😄