From 017d8aa6c0306c4d2975c69fcf8a9e718964ab72 Mon Sep 17 00:00:00 2001 From: B10m Date: Sat, 3 Feb 2018 00:32:20 +0100 Subject: [PATCH] Handle the armed status better Blink allows users to arm/disarm individual cameras. This is pretty useful for inside and outside cameras, for instance. The 'armed' information in the JSON however, merely indicates whether the *system* is armed, not whether the camera itself is armed. This value, which is the same as blink.arm, does not indicate whether the camera has motion detection enabled. In the JSON, the true status information lies in the 'active' key. The value can be 'armed', 'disarmed' or 'disabled'. This commit reflects that value in the armed property. --- blinkpy/blinkpy.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blinkpy/blinkpy.py b/blinkpy/blinkpy.py index 582d692..74fc85e 100644 --- a/blinkpy/blinkpy.py +++ b/blinkpy/blinkpy.py @@ -97,7 +97,7 @@ class BlinkCamera(object): self.urls = self.blink.urls self.id = str(config['device_id']) # pylint: disable=invalid-name self.name = config['name'] - self._status = config['armed'] + self._status = config['active'] self.thumbnail = "{}{}.jpg".format(self.urls.base_url, config['thumbnail']) self.clip = "{}{}".format(self.urls.base_url, config['video']) @@ -110,10 +110,15 @@ class BlinkCamera(object): self.arm_link = None self.region_id = config['region_id'] + @property + def status(self): + """Return camera status.""" + return self._status + @property def armed(self): """Return camera arm status.""" - return self._status + return True if self._status == 'armed' else False @property def battery_string(self): @@ -143,7 +148,7 @@ class BlinkCamera(object): def update(self, values): """Update camera information.""" self.name = values['name'] - self._status = values['armed'] + self._status = values['active'] self.thumbnail = "{}{}.jpg".format( self.urls.base_url, values['thumbnail']) self.clip = "{}{}".format(