Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix birdseye / restream #412

Merged
merged 6 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions custom_components/frigate/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def async_setup_entry(
]
+ (
[BirdseyeCamera(entry, frigate_client)]
if frigate_config.get("restream", {}).get("birdseye", False)
if frigate_config.get("birdseye", {}).get("restream", False)
else []
)
)
Expand Down Expand Up @@ -147,7 +147,10 @@ def __init__(
f"{frigate_config['mqtt']['topic_prefix']}" f"/{self._cam_name}/motion/set"
)

if self._camera_config.get("restream", {}).get("enabled"):
if (
self._cam_name
in self._frigate_config.get("go2rtc", {}).get("streams", {}).keys()
):
self._restream_type = "rtsp"
streaming_template = config_entry.options.get(
CONF_RTSP_URL_TEMPLATE, ""
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
},
"record": {"enabled": False, "retain_days": 30},
"rtmp": {"enabled": True},
"restream": {"enabled": True},
"snapshots": {
"bounding_box": False,
"crop": False,
Expand Down Expand Up @@ -154,6 +153,7 @@
"user": None,
},
"snapshots": {"retain": {"default": 10, "objects": {}}},
"go2rtc": {"streams": {"front_door": "rtsp://rtsp:password@cam-front-door/live"}},
}
TEST_STATS = {
"detection_fps": 13.7,
Expand Down
15 changes: 7 additions & 8 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def test_frigate_camera_setup_birdseye_rtsp(hass: HomeAssistant) -> None:
"""Set up birdseye camera."""

config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["restream"] = {"birdseye": True}
config["birdseye"] = {"restream": True}
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
await setup_mock_frigate_config_entry(hass, client=client)
Expand All @@ -98,7 +98,7 @@ async def test_frigate_camera_setup_rtmp(
"""Set up a camera."""

config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["cameras"]["front_door"]["restream"]["enabled"] = False
config["go2rtc"] = {}
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
await setup_mock_frigate_config_entry(hass, client=client)
Expand Down Expand Up @@ -159,7 +159,7 @@ async def test_frigate_camera_birdseye_image_height(
"""Ensure async_camera_image respects height parameter."""

config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["restream"] = {"birdseye": True}
config["birdseye"] = {"restream": True}
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
await setup_mock_frigate_config_entry(hass, client=client)
Expand Down Expand Up @@ -188,7 +188,7 @@ async def test_frigate_camera_setup_no_stream(hass: HomeAssistant) -> None:
"""Set up a camera without streaming."""

config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["cameras"]["front_door"]["restream"]["enabled"] = False
config["go2rtc"] = {}
config["cameras"]["front_door"]["rtmp"]["enabled"] = False
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
Expand All @@ -210,7 +210,7 @@ async def test_frigate_camera_recording_camera_state(
"""Set up an mqtt camera."""

config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["cameras"]["front_door"]["restream"]["enabled"] = False
config["go2rtc"] = {}
config["cameras"]["front_door"]["rtmp"]["enabled"] = False
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
Expand Down Expand Up @@ -370,7 +370,6 @@ async def test_camera_option_rtsp_stream_url_template(
) -> None:
"""Verify camera with the RTSP URL template option."""
config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["cameras"]["front_door"]["restream"]["enabled"] = True
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
config_entry = create_mock_frigate_config_entry(
Expand All @@ -391,7 +390,7 @@ async def test_birdseye_option_rtsp_stream_url_template(
) -> None:
"""Verify birdseye cam with the RTSP URL template option."""
config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["restream"] = {"birdseye": True}
config["birdseye"] = {"restream": True}
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
config_entry = create_mock_frigate_config_entry(
Expand All @@ -412,7 +411,7 @@ async def test_camera_option_rtmp_stream_url_template(
) -> None:
"""Verify camera with the RTMP URL template option."""
config: dict[str, Any] = copy.deepcopy(TEST_CONFIG)
config["cameras"]["front_door"]["restream"]["enabled"] = False
config["go2rtc"] = {}
client = create_mock_frigate_client()
client.async_get_config = AsyncMock(return_value=config)
config_entry = create_mock_frigate_config_entry(
Expand Down