Add adaptive brightness value source with time-of-day and scene modes

New "adaptive" value source type that automatically adjusts brightness
based on external conditions. Two sub-modes: time-of-day (schedule-based
interpolation with midnight wrap) and scene brightness (frame luminance
analysis via numpy BT.601 subsampling with EMA smoothing).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 15:14:30 +03:00
parent 48651f0a4e
commit d339dd3f90
11 changed files with 643 additions and 19 deletions

View File

@@ -43,6 +43,10 @@ def _to_response(source: ValueSource) -> ValueSourceResponse:
mode=d.get("mode"),
sensitivity=d.get("sensitivity"),
smoothing=d.get("smoothing"),
adaptive_mode=d.get("adaptive_mode"),
schedule=d.get("schedule"),
picture_source_id=d.get("picture_source_id"),
scene_behavior=d.get("scene_behavior"),
description=d.get("description"),
created_at=source.created_at,
updated_at=source.updated_at,
@@ -86,6 +90,10 @@ async def create_value_source(
sensitivity=data.sensitivity,
smoothing=data.smoothing,
description=data.description,
adaptive_mode=data.adaptive_mode,
schedule=data.schedule,
picture_source_id=data.picture_source_id,
scene_behavior=data.scene_behavior,
)
return _to_response(source)
except ValueError as e:
@@ -129,6 +137,10 @@ async def update_value_source(
sensitivity=data.sensitivity,
smoothing=data.smoothing,
description=data.description,
adaptive_mode=data.adaptive_mode,
schedule=data.schedule,
picture_source_id=data.picture_source_id,
scene_behavior=data.scene_behavior,
)
# Hot-reload running value streams
pm.update_value_source(source_id)