diff --git a/blinkpy/sync_module.py b/blinkpy/sync_module.py index 15854d7..ee465c7 100644 --- a/blinkpy/sync_module.py +++ b/blinkpy/sync_module.py @@ -189,7 +189,7 @@ class BlinkSyncModule(): clip = entry['media'] timestamp = entry['created_at'] if self.check_new_video_time(timestamp): - self.motion[name] = True + self.motion[name] = True and self.arm self.last_record[name] = {'clip': clip, 'time': timestamp} except KeyError: _LOGGER.debug("No new videos since last refresh.") diff --git a/tests/test_sync_module.py b/tests/test_sync_module.py index a581c5a..266b773 100644 --- a/tests/test_sync_module.py +++ b/tests/test_sync_module.py @@ -43,6 +43,7 @@ class TestBlinkSyncModule(unittest.TestCase): None, {'devicestatus': {}}, ] + self.blink.sync['test'].network_info = {'network': {'armed': True}} def tearDown(self): """Clean up after test.""" @@ -109,6 +110,24 @@ class TestBlinkSyncModule(unittest.TestCase): self.assertTrue(sync_module.check_new_videos()) self.assertEqual(sync_module.motion, {'foo': False}) + def test_check_no_motion_if_not_armed(self, mock_resp): + """Test that motion detection is not set if module unarmed.""" + mock_resp.return_value = { + 'media': [{ + 'device_name': 'foo', + 'media': '/foo/bar.mp4', + 'created_at': '1990-01-01T00:00:00+00:00' + }] + } + sync_module = self.blink.sync['test'] + sync_module.cameras = {'foo': None} + sync_module.blink.last_refresh = 1000 + self.assertTrue(sync_module.check_new_videos()) + self.assertEqual(sync_module.motion, {'foo': True}) + sync_module.network_info = {'network': {'armed': False}} + self.assertTrue(sync_module.check_new_videos()) + self.assertEqual(sync_module.motion, {'foo': False}) + def test_check_multiple_videos(self, mock_resp): """Test motion found even with multiple videos.""" mock_resp.return_value = {