Skip to content

Commit

Permalink
Merge pull request #719 from mkmer/doorbell_motion_control
Browse files Browse the repository at this point in the history
Enable Doorbell arm functionality
  • Loading branch information
fronzbot authored May 20, 2023
2 parents a40011c + 2883b5f commit ee88040
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
11 changes: 7 additions & 4 deletions blinkpy/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,17 @@ def __init__(self, sync):
@property
def arm(self):
"""Return camera arm status."""
return self.sync.arm
return self.motion_enabled

@arm.setter
def arm(self, value):
"""Set camera arm status."""
_LOGGER.warning(
"Individual camera motion detection enable/disable for Blink Doorbell is unsupported at this time."
)
url = f"{self.sync.urls.base_url}/api/v1/accounts/{self.sync.blink.account_id}/networks/{self.sync.network_id}/doorbells/{self.camera_id}"
if value:
url = f"{url}/enable"
else:
url = f"{url}/disable"
return api.http_post(self.sync.blink, url)

def snap_picture(self):
"""Snap picture for a blink doorbell camera."""
Expand Down
17 changes: 17 additions & 0 deletions tests/test_cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,29 @@ def tearDown(self):
def test_camera_arm_status(self, mock_resp):
"""Test arming and disarming camera."""
self.camera.motion_enabled = None
self.camera.arm = None
self.assertFalse(self.camera.arm)
self.camera.arm = False
self.camera.motion_enabled = False
self.assertFalse(self.camera.arm)
self.camera.arm = True
self.camera.motion_enabled = True
self.assertTrue(self.camera.arm)

def test_doorbell_camera_arm(self, mock_resp):
"""Test arming and disarming camera."""
self.blink.sync.arm = False
doorbell_camera = BlinkDoorbell(self.blink.sync["test"])
doorbell_camera.motion_enabled = None
doorbell_camera.arm = None
self.assertFalse(doorbell_camera.arm)
doorbell_camera.arm = False
doorbell_camera.motion_enabled = False
self.assertFalse(doorbell_camera.arm)
doorbell_camera.arm = True
doorbell_camera.motion_enabled = True
self.assertTrue(doorbell_camera.arm)

def test_missing_attributes(self, mock_resp):
"""Test that attributes return None if missing."""
self.camera.temperature = None
Expand Down

0 comments on commit ee88040

Please sign in to comment.