Add RTSP stream support for UVC (Unifi Video Client) integration (#30297)
* Add SUPPORT_STREAM to supported_features. * Implement stream_source with channel RTSP URIs. * Add Tests for Stream Support. * Make stream_source async. * Removed unused import. * Re-wrote test to remove warning, and lint error.
This commit is contained in:
1 parent
b097a64010
commit
3a18ef219b
2 files changed
+49
-1
No files matched your search
@@ -6,7 +6,7 @@ import requests
|
||||
from uvcclient import camera as uvc_camera, nvr
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
|
||||
from homeassistant.const import CONF_PORT, CONF_SSL
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@@ -92,6 +92,17 @@ class UnifiVideoCamera(Camera):
|
||||
"""Return the name of this camera."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return supported features."""
|
||||
caminfo = self._nvr.get_camera(self._uuid)
|
||||
channels = caminfo["channels"]
|
||||
for channel in channels:
|
||||
if channel["isRtspEnabled"]:
|
||||
return SUPPORT_STREAM
|
||||
|
||||
return 0
|
||||
|
||||
@property
|
||||
def is_recording(self):
|
||||
"""Return true if the camera is recording."""
|
||||
@@ -199,3 +210,13 @@ class UnifiVideoCamera(Camera):
|
||||
def disable_motion_detection(self):
|
||||
"""Disable motion detection in camera."""
|
||||
self.set_motion_detection(False)
|
||||
|
||||
async def stream_source(self):
|
||||
"""Return the source of the stream."""
|
||||
caminfo = self._nvr.get_camera(self._uuid)
|
||||
channels = caminfo["channels"]
|
||||
for channel in channels:
|
||||
if channel["isRtspEnabled"]:
|
||||
return channel["rtspUris"][0]
|
||||
|
||||
return None
|
||||
Reference in new issue
Block a user