Skip to content

Weather and illumination based brightness compensation#1452

Open
jaynis wants to merge 2 commits intobasnijholt:mainfrom
jaynis:feature/weather-compensation
Open

Weather and illumination based brightness compensation#1452
jaynis wants to merge 2 commits intobasnijholt:mainfrom
jaynis:feature/weather-compensation

Conversation

@jaynis
Copy link

@jaynis jaynis commented Mar 21, 2026

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, linear or tanh) 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: None
  • lux_min: Minimum lux value - no brightness reduction applied. Default: 0
  • lux_max: Maximum lux value - full brightness reduction applied. Default: 10000
  • lux_smoothing_samples: Number of samples for moving average smoothing. Default: 5
  • lux_smoothing_window: Time window in seconds for smoothing lux readings. Default: 300
  • lux_brightness_reduction_factor: Maximum brightness reduction factor (0-1) when lux is at minimum. Default: 0.5
  • weather_entity: Entity ID of the weather entity (optional, enables weather-based adjustment). Default: None
  • bad_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

Signed-off-by: jaynis <kranz.jannis@googlemail.com>
@jaynis jaynis requested a review from basnijholt as a code owner March 21, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set Brightness based on Lux No support for bad weather? Integration with PWS solar sensor

1 participant