Skip to content

feat(nvr): prepare nvr for config reload#1250

Merged
roflcoopter merged 5 commits intodevfrom
feature/nvr-reload
Feb 13, 2026
Merged

feat(nvr): prepare nvr for config reload#1250
roflcoopter merged 5 commits intodevfrom
feature/nvr-reload

Conversation

@roflcoopter
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 13, 2026 20:16
@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for viseron canceled.

Name Link
🔨 Latest commit 809950c
🔍 Latest deploy log https://app.netlify.com/projects/viseron/deploys/698f9c67d7379f0008f7992a

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prepares the NVR (Network Video Recorder) component for configuration reload by implementing proper event listener tracking and cleanup mechanisms. The changes introduce an unload pattern that allows entities and NVR instances to properly clean up their resources (event listeners, signal handlers) when being removed or reloaded.

Changes:

  • Added __init__ method to base Entity class to initialize event listener tracking list
  • Implemented unload method in Entity base class to unsubscribe from tracked event listeners
  • Modified NVR entities (sensor and toggle) to track their event listeners for proper cleanup
  • Added unload methods to FrameIntervalCalculator and NVR classes to clean up resources
  • Updated entity registration to include domain and identifier for proper entity tracking

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
viseron/helpers/entity/init.py Added __init__ to initialize _event_listeners list and unload method to clean up tracked listeners
viseron/domains/camera/entity/init.py Added super().__init__(vis) call to ensure event listener tracking is initialized
viseron/components/nvr/toggle.py Modified to append event listeners to _event_listeners for tracking
viseron/components/nvr/sensor.py Modified to append event listeners to _event_listeners for tracking
viseron/components/nvr/nvr.py Added listener tracking, unload methods for FrameIntervalCalculator and NVR, updated entity registration with domain/identifier, removed unused DATA_STREAM_COMPONENT

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 13, 2026 21:49
@roflcoopter roflcoopter merged commit b092037 into dev Feb 13, 2026
9 checks passed
@roflcoopter roflcoopter deleted the feature/nvr-reload branch February 13, 2026 21:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +879 to +885
def unload(self) -> None:
"""Unload nvr."""
for unsubscribe in self._listeners:
unsubscribe()
for scanner in self._frame_scanners.values():
scanner.unload()
self._nvr_thread.stop() # indirectly calls self.stop thru stop_target
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new unload() method lacks test coverage. Consider adding tests that verify:

  1. Event listeners are properly unsubscribed
  2. Frame scanners are unloaded correctly
  3. The NVR thread is stopped

This is important for ensuring the config reload functionality works correctly and doesn't leave dangling resources.

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +83
def unload(self):
"""Unload entity."""
for unsubscribe in self._event_listeners:
unsubscribe()
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new unload() method in the Entity base class lacks test coverage. This is a critical piece of functionality for config reload. Consider adding tests to verify that entities properly clean up their event listeners when unloaded.

Copilot uses AI. Check for mistakes.
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

Comments