adaptive-lighting/custom_components
Casey 5bf28bd729 Fix sun-event day-anchoring: curve collapsed to min in summer afternoons
sensor.sun_next_rising flips to tomorrow at sunrise; the old anchor only
pulled it back when >12h away. With short June nights tomorrow's sunrise
is within 12h by mid-afternoon, so from ~17:30 local until sunset the
pair described tomorrow and the curve returned minimum.

Replace the clock-distance heuristic with ordering-based anchoring in a
new pure helper anchor_sun_events() (color_and_brightness.py):
- daytime (sunrise > sunset): pull sunrise back one day, unconditionally
- stale "today's sunset" still on yesterday: push sunset forward one day
- post-sunset ramp tail (both flipped, still within half_width): pull
  both back so the down-ramp completes instead of snapping to min

8 regression tests incl. the June-afternoon repro and a winter check.
2026-06-07 20:26:42 +02:00
..
adaptive_lighting Fix sun-event day-anchoring: curve collapsed to min in summer afternoons 2026-06-07 20:26:42 +02:00