mirror of
https://github.com/home-assistant/core.git
synced 2025-07-04 20:07:10 +00:00
Reolink autotrack streams for TrackMix and high/low resolution snapshots (#90591)
* Add auto track stream for Trackmix connected to NVR * Enable autotracking stream by default * Add snapshot high/low resolution * Improve naming * fix snapshots camera's not beeing added * keep unique ID the same * fix styling
This commit is contained in:
parent
9eac0458dd
commit
b91c6911d9
@ -28,13 +28,18 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
cameras = []
|
cameras = []
|
||||||
for channel in host.api.stream_channels:
|
for channel in host.api.stream_channels:
|
||||||
streams = ["sub", "main", "snapshots"]
|
streams = ["sub", "main", "snapshots_sub", "snapshots_main"]
|
||||||
if host.api.protocol in ["rtmp", "flv"]:
|
if host.api.protocol in ["rtmp", "flv"]:
|
||||||
streams.append("ext")
|
streams.append("ext")
|
||||||
|
|
||||||
|
if host.api.supported(channel, "autotrack_stream"):
|
||||||
|
streams.extend(
|
||||||
|
["autotrack_sub", "autotrack_snapshots_sub", "autotrack_snapshots_main"]
|
||||||
|
)
|
||||||
|
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
stream_url = await host.api.get_stream_source(channel, stream)
|
stream_url = await host.api.get_stream_source(channel, stream)
|
||||||
if stream_url is None and stream != "snapshots":
|
if stream_url is None and "snapshots" not in stream:
|
||||||
continue
|
continue
|
||||||
cameras.append(ReolinkCamera(reolink_data, channel, stream))
|
cameras.append(ReolinkCamera(reolink_data, channel, stream))
|
||||||
|
|
||||||
@ -58,12 +63,16 @@ class ReolinkCamera(ReolinkChannelCoordinatorEntity, Camera):
|
|||||||
|
|
||||||
self._stream = stream
|
self._stream = stream
|
||||||
|
|
||||||
|
stream_name = self._stream.replace("_", " ")
|
||||||
if self._host.api.model in DUAL_LENS_MODELS:
|
if self._host.api.model in DUAL_LENS_MODELS:
|
||||||
self._attr_name = f"{self._stream} lens {self._channel}"
|
self._attr_name = f"{stream_name} lens {self._channel}"
|
||||||
else:
|
else:
|
||||||
self._attr_name = self._stream
|
self._attr_name = stream_name
|
||||||
self._attr_unique_id = f"{self._host.unique_id}_{self._channel}_{self._stream}"
|
stream_id = self._stream
|
||||||
self._attr_entity_registry_enabled_default = stream == "sub"
|
if stream_id == "snapshots_main":
|
||||||
|
stream_id = "snapshots"
|
||||||
|
self._attr_unique_id = f"{self._host.unique_id}_{self._channel}_{stream_id}"
|
||||||
|
self._attr_entity_registry_enabled_default = stream in ["sub", "autotrack_sub"]
|
||||||
|
|
||||||
async def stream_source(self) -> str | None:
|
async def stream_source(self) -> str | None:
|
||||||
"""Return the source of the stream."""
|
"""Return the source of the stream."""
|
||||||
@ -73,4 +82,4 @@ class ReolinkCamera(ReolinkChannelCoordinatorEntity, Camera):
|
|||||||
self, width: int | None = None, height: int | None = None
|
self, width: int | None = None, height: int | None = None
|
||||||
) -> bytes | None:
|
) -> bytes | None:
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
return await self._host.api.get_snapshot(self._channel)
|
return await self._host.api.get_snapshot(self._channel, self._stream)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user