mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Added support for enable/disable motion detection (#11583)
* Added support for enable/disable motion detection * Changed name of variable for exception, lint error * Moved motion_detection_enabled property to the other properties
This commit is contained in:
parent
2224d05607
commit
965bd8a2e0
@ -82,6 +82,7 @@ class UnifiVideoCamera(Camera):
|
|||||||
self.is_streaming = False
|
self.is_streaming = False
|
||||||
self._connect_addr = None
|
self._connect_addr = None
|
||||||
self._camera = None
|
self._camera = None
|
||||||
|
self._motion_status = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -94,6 +95,12 @@ class UnifiVideoCamera(Camera):
|
|||||||
caminfo = self._nvr.get_camera(self._uuid)
|
caminfo = self._nvr.get_camera(self._uuid)
|
||||||
return caminfo['recordingSettings']['fullTimeRecordEnabled']
|
return caminfo['recordingSettings']['fullTimeRecordEnabled']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def motion_detection_enabled(self):
|
||||||
|
"""Camera Motion Detection Status."""
|
||||||
|
caminfo = self._nvr.get_camera(self._uuid)
|
||||||
|
return caminfo['recordingSettings']['motionRecordEnabled']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brand(self):
|
def brand(self):
|
||||||
"""Return the brand of this camera."""
|
"""Return the brand of this camera."""
|
||||||
@ -165,3 +172,26 @@ class UnifiVideoCamera(Camera):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
return _get_image()
|
return _get_image()
|
||||||
|
|
||||||
|
def set_motion_detection(self, mode):
|
||||||
|
"""Set motion detection on or off."""
|
||||||
|
from uvcclient.nvr import NvrError
|
||||||
|
if mode is True:
|
||||||
|
set_mode = 'motion'
|
||||||
|
else:
|
||||||
|
set_mode = 'none'
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._nvr.set_recordmode(self._uuid, set_mode)
|
||||||
|
self._motion_status = mode
|
||||||
|
except NvrError as err:
|
||||||
|
_LOGGER.error("Unable to set recordmode to " + set_mode)
|
||||||
|
_LOGGER.debug(err)
|
||||||
|
|
||||||
|
def enable_motion_detection(self):
|
||||||
|
"""Enable motion detection in camera."""
|
||||||
|
self.set_motion_detection(True)
|
||||||
|
|
||||||
|
def disable_motion_detection(self):
|
||||||
|
"""Disable motion detection in camera."""
|
||||||
|
self.set_motion_detection(False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user