Add arm property to camera, deprecate motion enable method

This commit is contained in:
Kevin Fronczak
2020-05-27 21:44:07 +00:00
parent 38fed26742
commit 00c2c2cc29
2 changed files with 28 additions and 0 deletions
+19
View File
@@ -77,12 +77,31 @@ class BlinkCamera:
return self._cached_video return self._cached_video
return None return None
@property
def arm(self):
"""Return arm status of camera."""
return self.motion_enabled
@arm.setter
def arm(self, value):
"""Set camera arm status."""
if value:
return api.request_motion_detection_enable(
self.sync.blink, self.network_id, self.camera_id
)
return api.request_motion_detection_disable(
self.sync.blink, self.network_id, self.camera_id
)
def snap_picture(self): def snap_picture(self):
"""Take a picture with camera to create a new thumbnail.""" """Take a picture with camera to create a new thumbnail."""
return api.request_new_image(self.sync.blink, self.network_id, self.camera_id) return api.request_new_image(self.sync.blink, self.network_id, self.camera_id)
def set_motion_detect(self, enable): def set_motion_detect(self, enable):
"""Set motion detection.""" """Set motion detection."""
_LOGGER.warning(
"Method is deprecated as of v0.16.0 and will be removed in a future version. Please use the BlinkCamera.arm property instead."
)
if enable: if enable:
return api.request_motion_detection_enable( return api.request_motion_detection_enable(
self.sync.blink, self.network_id, self.camera_id self.sync.blink, self.network_id, self.camera_id
+9
View File
@@ -144,6 +144,15 @@ class TestBlinkCameraSetup(unittest.TestCase):
self.assertEqual(self.camera.clip, None) self.assertEqual(self.camera.clip, None)
self.assertEqual(self.camera.video_from_cache, None) self.assertEqual(self.camera.video_from_cache, None)
def test_camera_arm_status(self, mock_resp):
"""Test arming and disarming camera."""
self.camera.motion_enabled = None
self.assertFalse(self.camera.arm)
self.camera.motion_enabled = False
self.assertFalse(self.camera.arm)
self.camera.motion_enabled = True
self.assertTrue(self.camera.arm)
@mock.patch("blinkpy.camera.api.request_motion_detection_enable") @mock.patch("blinkpy.camera.api.request_motion_detection_enable")
@mock.patch("blinkpy.camera.api.request_motion_detection_disable") @mock.patch("blinkpy.camera.api.request_motion_detection_disable")
def test_motion_detection_enable_disable(self, mock_dis, mock_en, mock_rep): def test_motion_detection_enable_disable(self, mock_dis, mock_en, mock_rep):