From 0ec99720dc15814ae598dd50a1be7173ad1a0264 Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Tue, 14 Nov 2017 01:04:18 -0500 Subject: [PATCH 1/2] Bump version to 0.1.8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9f979d0c..e22de38e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='ring_doorbell', packages=['ring_doorbell'], - version='0.1.7', + version='0.1.8', description='A Python library to communicate with Ring' + ' Door Bell (https://ring.com/)', author='Marcelo Moreira de Mello', From 30a2f0c60479a780beae930742fb538dbb570f03 Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Tue, 21 Nov 2017 18:17:25 -0500 Subject: [PATCH 2/2] Added controllter to verify if account has subscription --- ring_doorbell/doorbot.py | 15 +++++++++++++++ tests/test_ring.py | 1 + 2 files changed, 16 insertions(+) diff --git a/ring_doorbell/doorbot.py b/ring_doorbell/doorbot.py index e77adcfd..c67d1858 100644 --- a/ring_doorbell/doorbot.py +++ b/ring_doorbell/doorbot.py @@ -247,6 +247,11 @@ def live_streaming_json(self): def recording_download(self, recording_id, filename=None, override=False): """Save a recording in MP4 format to a file or return raw.""" + if not self.has_subscription: + _LOGGER.warning("Your Ring account does not have" + + " an active subscription.") + return False + url = API_URI + URL_RECORDING.format(recording_id) try: req = self._ring.query(url, raw=True) @@ -268,6 +273,11 @@ def recording_download(self, recording_id, filename=None, override=False): def recording_url(self, recording_id): """Return HTTPS recording URL.""" + if not self.has_subscription: + _LOGGER.warning("Your Ring account does not have" + + " an active subscription.") + return False + url = API_URI + URL_RECORDING.format(recording_id) req = self._ring.query(url, raw=True) if req and req.status_code == 200: @@ -290,6 +300,11 @@ def subscribed_motion(self): return False return True + @property + def has_subscription(self): + """Return boolean if the account has subscription.""" + return self._attrs.get('features').get('show_recordings') + @property def volume(self): """Return volume.""" diff --git a/tests/test_ring.py b/tests/test_ring.py index 5881d877..cae84803 100644 --- a/tests/test_ring.py +++ b/tests/test_ring.py @@ -74,6 +74,7 @@ def test_doorbell_attributes(self, mock): self.assertEqual(-70.12345, dev.longitude) self.assertEqual('America/New_York', dev.timezone) self.assertEqual(1, dev.volume) + self.assertTrue(dev.has_subscription) self.assertEqual('online', dev.connection_status) self.assertIsInstance(dev.history(limit=1, kind='motion'),