Skip to content

Conversation

@an0nfunc
Copy link

@an0nfunc an0nfunc commented Jan 23, 2026

Summary

Adds support for controlling brightness based on an outdoor lux sensor instead of sun position. This allows adaptive lighting to respond to actual ambient light conditions (e.g., overcast days) rather than calculated sun position.

  • New lux option for brightness_mode
  • Follows circadian behavior: dark (low lux) = dim lights, bright (high lux) = bright lights
  • Smoothing buffer prevents rapid fluctuations from passing clouds
  • Falls back to sun-based calculation when sensor unavailable

Configuration

Option Default Description
lux_sensor None Entity ID of outdoor illuminance sensor
lux_min 0 Lux value for minimum brightness
lux_max 10000 Lux value for maximum brightness
lux_smoothing_samples 5 Number of samples to average
lux_smoothing_window 300 Time window (seconds) for samples

Test plan

  • Unit tests for lux brightness calculation
  • Tested on live Home Assistant instance
  • Verified fallback when sensor unavailable
  • Verified smoothing prevents rapid changes

Closes #1177

@an0nfunc an0nfunc requested a review from basnijholt as a code owner January 23, 2026 19:33
@an0nfunc an0nfunc force-pushed the feature/lux-sensor-brightness-mode branch from bcb3ca7 to d188cc0 Compare January 23, 2026 19:42
@an0nfunc an0nfunc force-pushed the feature/lux-sensor-brightness-mode branch 3 times, most recently from 60770ee to ad847c0 Compare January 23, 2026 22:07
@basnijholt
Copy link
Owner

Thanks @an0nfunc!

Will check later. Just curious, did you use Opus 4.5 or another model?

@an0nfunc
Copy link
Author

an0nfunc commented Jan 23, 2026

Thanks @an0nfunc!

Will check later. Just curious, did you use Opus 4.5 or another model?

Cool :) This is done by Opus 4.5 and manually reviewed 😇

Edit: I see there are still some tests failing, will have a look 👀.
Edit2: Sorry was missing some tests locally. Should all pass now.
Edit3: Turns out EntitySelector doesn't like empty values, which broke the optional lux_sensor field. Switched to a SelectSelector dropdown that lists all available illuminance sensors. Works nicely and the UX is actually better this way.

@an0nfunc an0nfunc force-pushed the feature/lux-sensor-brightness-mode branch 3 times, most recently from 9402281 to b8c14c1 Compare January 24, 2026 10:43
Add support for controlling brightness based on an outdoor lux sensor
instead of sun position. Users can select "lux" as the brightness_mode
and configure a lux sensor entity.

New configuration options:
- lux_sensor: Entity ID of outdoor illuminance sensor
- lux_min: Lux value for minimum brightness (default: 0)
- lux_max: Lux value for maximum brightness (default: 10000)
- lux_smoothing_samples: Number of samples to average (default: 5)
- lux_smoothing_window: Time window in seconds (default: 300)

Features:
- Linear brightness mapping matching circadian behavior (dark = dim)
- Smoothing buffer to prevent rapid fluctuations
- Automatic fallback to sun-based calculation when sensor unavailable
- Switch attributes show current_lux and lux_samples_count
@an0nfunc an0nfunc force-pushed the feature/lux-sensor-brightness-mode branch from e82bfa7 to de2193e Compare January 24, 2026 10:48
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

2 participants