Skip to content

Commit 5ba9026

Browse files
authored
fix(camera): update is_package detection logic for G6 Entry (#721)
1 parent d3dc30d commit 5ba9026

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/uiprotect/data/devices.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ def rtsps_no_srtp_url(self) -> str | None:
325325

326326
@property
327327
def is_package(self) -> bool:
328-
return self.fps is not None and self.fps <= 2
328+
# NOTE: The previous logic (checking fps <= 2) stopped working with G6 Entry
329+
# due to higher FPS values. This is now aligned with the logic used in
330+
# package_camera_channel. Not optimal, but will be fixed with the switch
331+
# to the public API.
332+
return self.fps is not None and self.id == 3
329333

330334

331335
class ISPSettings(ProtectBaseObject):

tests/data/test_camera.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,48 @@
2323
SmartDetectAudioType,
2424
VideoMode,
2525
)
26-
from uiprotect.data.devices import CameraZone, Hotplug, HotplugExtender, WifiStats
26+
from uiprotect.data.devices import (
27+
CameraChannel,
28+
CameraZone,
29+
Hotplug,
30+
HotplugExtender,
31+
WifiStats,
32+
)
2733
from uiprotect.data.types import DEFAULT, PermissionNode, SmartDetectObjectType
2834
from uiprotect.data.websocket import WSAction, WSSubscriptionMessage
2935
from uiprotect.exceptions import BadRequest, NotAuthorized
3036
from uiprotect.utils import to_js_time
3137

3238

39+
@pytest.mark.parametrize(
40+
("channel_id", "fps", "expected"),
41+
[
42+
(3, 2, True), # Package channel with low fps (legacy behavior)
43+
(3, 15, True), # Package channel with higher fps (G6 Entry)
44+
(3, None, False), # Package channel with no fps
45+
(0, 2, False), # Non-package channel with low fps
46+
(1, 15, False), # Non-package channel
47+
(2, None, False), # Non-package channel with no fps
48+
],
49+
)
50+
def test_camera_channel_is_package(channel_id: int, fps: int | None, expected: bool):
51+
"""Test CameraChannel.is_package uses channel id == 3 for detection."""
52+
channel = CameraChannel.from_unifi_dict(
53+
id=channel_id,
54+
videoId="test",
55+
name="test",
56+
enabled=True,
57+
isRtspEnabled=False,
58+
width=1920,
59+
height=1080,
60+
fps=fps,
61+
bitrate=1000,
62+
fpsValues=[],
63+
idrInterval=1,
64+
)
65+
assert channel.is_package is expected
66+
67+
3368
@pytest.mark.parametrize(
3469
("link_speed", "expected_type"),
3570
[

0 commit comments

Comments
 (0)