Weather and illumination based brightness compensation#1452
Open
jaynis wants to merge 2 commits intobasnijholt:mainfrom
Open
Weather and illumination based brightness compensation#1452jaynis wants to merge 2 commits intobasnijholt:mainfrom
jaynis wants to merge 2 commits intobasnijholt:mainfrom
Conversation
Signed-off-by: jaynis <kranz.jannis@googlemail.com>
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements advanced brightness compensation features that adjust light brightness based on ambient illumination (lux) and/or bare weather conditions. These features work on top of the existing brightness modes and are activated by either configuring a illuminace sensor reporting a lux value, a weather entity providing a weather condition or both, where the values are internally combined into one output. If none of both is set everything falls back to the default mechanism with no adjustments applied.
Closes #1138
Closes #1177
Closes #904
This PR is inspired by PR #1413, which is an alternative approach to integrate an illumination sensor.
Functioning
The compensation mechanism adjusts the brightness value coming from the configured brightness mode (
default,linearortanh) by applying reduction factors based on environmental conditions. The system compares actual ambient light (lux) or weather conditions against expected clear-sky values for the current sun position, then reduces brightness proportionally when conditions are darker than expected. This mechanism prevents unwanted reductions during dusk/dawn when light naturally dims and gradually fades compensation to zero as the sun sets, aligning brightness back to original sun-position values at night when weather/lux adjustments arent desired.Configuration
The following configurational options have been added:
lux_sensor: Entity ID of the illuminance sensor (optional, enables lux-based adjustment). Default: Nonelux_min: Minimum lux value - no brightness reduction applied. Default: 0lux_max: Maximum lux value - full brightness reduction applied. Default: 10000lux_smoothing_samples: Number of samples for moving average smoothing. Default: 5lux_smoothing_window: Time window in seconds for smoothing lux readings. Default: 300lux_brightness_reduction_factor: Maximum brightness reduction factor (0-1) when lux is at minimum. Default: 0.5weather_entity: Entity ID of the weather entity (optional, enables weather-based adjustment). Default: Nonebad_weather: List of weather states considered as bad weather. Default:['cloudy', 'pouring', 'hail', 'fog', 'rainy', 'snowy', 'snowy-rainy']weather_brightness_reduction_factor: Brightness reduction factor (0-1) applied during bad weather. Default: 0.3