Refresh snapshots after light actions

This commit is contained in:
2026-08-03 01:28:56 +02:00
parent 127d07dc6b
commit 4ea737024b
14 changed files with 177 additions and 6 deletions
+13 -1
View File
@@ -4,10 +4,12 @@ from frigate_camera_control_bridge.app import CameraControlBridge
class DummyAction:
def __init__(self, action_id, camera=None, kind="hikvision_colorvu"):
def __init__(self, action_id, camera=None, kind="hikvision_colorvu", name_key=None):
self.id = action_id
self.kind = kind
self.cfg = {}
if name_key:
self.cfg["name_key"] = name_key
if camera:
self.cfg["snapshot"] = {
"frigate_url": "http://frigate.example.test:5000",
@@ -52,6 +54,16 @@ class RefreshSummaryTest(unittest.TestCase):
self.assertEqual(message, "No camera changes found.")
def test_light_actions_refresh_snapshot_after_on_off(self):
white = DummyAction("white", "one", name_key="action.manual_white")
red_blue = DummyAction("red_blue", "one", name_key="action.red_blue")
siren = DummyAction("siren", "one", name_key="action.siren")
self.assertTrue(CameraControlBridge.should_refresh_snapshot_after_command(white, "on"))
self.assertTrue(CameraControlBridge.should_refresh_snapshot_after_command(red_blue, "off"))
self.assertFalse(CameraControlBridge.should_refresh_snapshot_after_command(siren, "on"))
self.assertFalse(CameraControlBridge.should_refresh_snapshot_after_command(white, "press"))
if __name__ == "__main__":
unittest.main()
+20 -1
View File
@@ -1,6 +1,6 @@
import unittest
from frigate_camera_control_bridge.ui import render_page
from frigate_camera_control_bridge.ui import camera_stream_url, render_page
class DummyAction:
@@ -11,6 +11,7 @@ class DummyAction:
self.state = state
self.auto_off_seconds = 180
self.auto_off_at = 1234567890
self.snapshot_version = 42
self.cfg = {
"name_key": name_key,
"camera_name": "Example camera",
@@ -35,6 +36,7 @@ class UiRenderTest(unittest.TestCase):
self.assertIn('data-auto-off-at="1234567890"', html)
self.assertIn('data-requires-ack="true"', html)
self.assertIn("Example camera", html)
self.assertIn("v=42", html)
def test_controls_from_same_camera_share_one_card(self):
actions = [
@@ -73,6 +75,23 @@ class UiRenderTest(unittest.TestCase):
self.assertIn('data-working-label="Refreshing cameras..."', html)
self.assertIn("<svg", html)
def test_camera_stream_link_uses_default_frigate_url(self):
action = DummyAction()
self.assertEqual(
camera_stream_url(action),
"http://frigate.example.test:5000/#example",
)
def test_camera_stream_link_uses_public_proxy_url_from_env_config(self):
action = DummyAction()
action.cfg["snapshot"]["public_url"] = "https://frigate.example.test"
self.assertEqual(
camera_stream_url(action),
"https://frigate.example.test/#example",
)
if __name__ == "__main__":
unittest.main()