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.
This commit is contained in:
B10m
2018-02-03 00:32:20 +01:00
parent 87b83465b3
commit 017d8aa6c0
+8 -3
View File
@@ -97,7 +97,7 @@ class BlinkCamera(object):
self.urls = self.blink.urls self.urls = self.blink.urls
self.id = str(config['device_id']) # pylint: disable=invalid-name self.id = str(config['device_id']) # pylint: disable=invalid-name
self.name = config['name'] self.name = config['name']
self._status = config['armed'] self._status = config['active']
self.thumbnail = "{}{}.jpg".format(self.urls.base_url, self.thumbnail = "{}{}.jpg".format(self.urls.base_url,
config['thumbnail']) config['thumbnail'])
self.clip = "{}{}".format(self.urls.base_url, config['video']) self.clip = "{}{}".format(self.urls.base_url, config['video'])
@@ -110,10 +110,15 @@ class BlinkCamera(object):
self.arm_link = None self.arm_link = None
self.region_id = config['region_id'] self.region_id = config['region_id']
@property
def status(self):
"""Return camera status."""
return self._status
@property @property
def armed(self): def armed(self):
"""Return camera arm status.""" """Return camera arm status."""
return self._status return True if self._status == 'armed' else False
@property @property
def battery_string(self): def battery_string(self):
@@ -143,7 +148,7 @@ class BlinkCamera(object):
def update(self, values): def update(self, values):
"""Update camera information.""" """Update camera information."""
self.name = values['name'] self.name = values['name']
self._status = values['armed'] self._status = values['active']
self.thumbnail = "{}{}.jpg".format( self.thumbnail = "{}{}.jpg".format(
self.urls.base_url, values['thumbnail']) self.urls.base_url, values['thumbnail'])
self.clip = "{}{}".format( self.clip = "{}{}".format(