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:
+8
-3
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user