Skip to content

feat(brightness): gradual sun-based dimming with cosine curve - #60

Open
ojacques wants to merge 1 commit into
mainfrom
feat/gradual-sun-dimming
Open

ojacques wants to merge 1 commit into
mainfrom
feat/gradual-sun-dimming

Conversation

@ojacques

Copy link
Copy Markdown
Contributor

Summary

Replaces the instant brightness switch at sunrise/sunset with a smooth cosine transition.

Before

Brightness jumped from night→day (or day→night) in a single step at the exact minute of sunrise/sunset. Very noticeable.

After

Brightness ramps gradually over 30 minutes (configurable), centered on sunrise/sunset. Uses a cosine curve so the change is barely noticeable at the start/end and fastest in the middle — matching how f.lux and Home Assistant Adaptive Lighting work.

Example with sunrise at 06:30, night=20%, day=80%:

06:15  20%  (start of transition)
06:20  24%  (slow start — cosine)
06:25  35%
06:30  50%  (midpoint — fastest change)
06:35  65%
06:40  75%
06:45  80%  (end of transition)

Configuration

New option in [brightness_schedule] section of zeclock.ini:

sun_transition_minutes = 30
  • Default: 30 minutes (15 before + 15 after sunrise/sunset)
  • Set to 0 for the previous instant-switch behavior
  • Max: 120 minutes

Files changed

  • zeclock/brightness_scheduler.py — cosine ramp in _compute_sun_brightness()
  • zeclock/backend_config.py — new config field + INI parsing
  • zeclock/clock.py — pass new param to scheduler
  • zeclock/remote/rest_remote.py — pass new param on config reload

Replace the instant brightness switch at sunrise/sunset with a smooth
cosine transition over a configurable duration (default: 30 minutes,
centered on the event — 15 min before and 15 min after).

The cosine curve makes the change barely perceptible at the start and
end of the transition, with the fastest change in the middle — matching
how f.lux, Home Assistant Adaptive Lighting, and other apps handle it.

New config option in [brightness_schedule]:
  sun_transition_minutes = 30  (0 = instant switch, max 120)

Setting to 0 restores the previous instant-switch behavior.
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.

1 participant