Skip to content
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
29 changes: 18 additions & 11 deletions homeassistant/components/uvc/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
[
UnifiVideoCamera(nvrconn, camera[identifier], camera["name"], password)
for camera in cameras
]
],
True,
)
return True

Expand All @@ -85,17 +86,22 @@ def __init__(self, camera, uuid, name, password):
self._connect_addr = None
self._camera = None
self._motion_status = False
self._caminfo = None

@property
def name(self):
"""Return the name of this camera."""
return self._name

@property
def should_poll(self):
"""If this entity should be polled."""
return True

@property
def supported_features(self):
"""Return supported features."""
caminfo = self._nvr.get_camera(self._uuid)
channels = caminfo["channels"]
channels = self._caminfo["channels"]
for channel in channels:
if channel["isRtspEnabled"]:
return SUPPORT_STREAM
Expand All @@ -105,14 +111,12 @@ def supported_features(self):
@property
def is_recording(self):
"""Return true if the camera is recording."""
caminfo = self._nvr.get_camera(self._uuid)
return caminfo["recordingSettings"]["fullTimeRecordEnabled"]
return self._caminfo["recordingSettings"]["fullTimeRecordEnabled"]

@property
def motion_detection_enabled(self):
"""Camera Motion Detection Status."""
caminfo = self._nvr.get_camera(self._uuid)
return caminfo["recordingSettings"]["motionRecordEnabled"]
return self._caminfo["recordingSettings"]["motionRecordEnabled"]

@property
def brand(self):
Expand All @@ -122,13 +126,11 @@ def brand(self):
@property
def model(self):
"""Return the model of this camera."""
caminfo = self._nvr.get_camera(self._uuid)
return caminfo["model"]
return self._caminfo["model"]

def _login(self):
"""Login to the camera."""

caminfo = self._nvr.get_camera(self._uuid)
caminfo = self._caminfo
if self._connect_addr:
addrs = [self._connect_addr]
else:
Expand Down Expand Up @@ -164,6 +166,7 @@ def _login(self):
return None

self._camera = camera
self._caminfo = caminfo
return True

def camera_image(self):
Expand Down Expand Up @@ -219,3 +222,7 @@ async def stream_source(self):
return channel["rtspUris"][0]

return None

def update(self):
"""Update the info."""
self._caminfo = self._nvr.get_camera(self._uuid)
1 change: 1 addition & 0 deletions tests/components/uvc/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def setup_method(self, method):
],
}
self.nvr.server_version = (3, 2, 0)
self.uvc.update()

def test_properties(self):
"""Test the properties."""
Expand Down