Motion events from different cameras are merged into one #110

Closed
opened 2026-07-14 08:53:39 +00:00 by coding-agent-marvin8 · 1 comment
coding-agent-marvin8 commented 2026-07-14 08:53:39 +00:00 (Migrated from codeberg.org)

When two cameras both detect motion within 60 seconds of each other, the day view and calendar merge their snapshots into a single event attributed to whichever camera fired first (almost always the first camera in the config). The second camera's motion event is invisible: wrong camera name, wrong thumbnail, wrong view link, and undercounted events on the calendar.

Expected: each camera's motion is detected independently. Simultaneous motion on two cameras shows two events side by side, and the calendar counts them both.

When two cameras both detect motion within 60 seconds of each other, the day view and calendar merge their snapshots into a single event attributed to whichever camera fired first (almost always the first camera in the config). The second camera's motion event is invisible: wrong camera name, wrong thumbnail, wrong view link, and undercounted events on the calendar. Expected: each camera's motion is detected independently. Simultaneous motion on two cameras shows two events side by side, and the calendar counts them both.
coding-agent-marvin8 commented 2026-07-14 08:53:50 +00:00 (Migrated from codeberg.org)

Root cause: group_into_events() in web/routes/clips.py is fed motion snapshots from all cameras as one chronologically-sorted stream, so snapshots from different cameras within gap_seconds of each other land in the same event. The event is then labelled with first_snapshot["camera"].

Plan: add group_events_per_camera() to events.py — partition the snapshot list by camera, run group_into_events() per camera, merge and sort the resulting events by start time. Swap both call sites in clips.py (day_view and days_list). TDD with five new tests in tests/test_events.py. Design spec reviewed locally.

Root cause: group_into_events() in web/routes/clips.py is fed motion snapshots from all cameras as one chronologically-sorted stream, so snapshots from different cameras within gap_seconds of each other land in the same event. The event is then labelled with first_snapshot["camera"]. Plan: add group_events_per_camera() to events.py — partition the snapshot list by camera, run group_into_events() per camera, merge and sort the resulting events by start time. Swap both call sites in clips.py (day_view and days_list). TDD with five new tests in tests/test_events.py. Design spec reviewed locally.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marvin8/cang#110
No description provided.