Skip to content

Commit

Permalink
Add properties for version
Browse files Browse the repository at this point in the history
  • Loading branch information
mkmer committed Jan 8, 2024
1 parent 30addb6 commit c6769c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
11 changes: 8 additions & 3 deletions blinkpy/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, sync):
self.network_id = None
self.thumbnail = None
self.serial = None
self.version = None
self._version = None
self.motion_enabled = None
self.battery_level = None
self.clip = None
Expand All @@ -53,7 +53,7 @@ def attributes(self):
"name": self.name,
"camera_id": self.camera_id,
"serial": self.serial,
"version": self.version,
"version": self._version,
"temperature": self.temperature,
"temperature_c": self.temperature_c,
"temperature_calibrated": self.temperature_calibrated,
Expand Down Expand Up @@ -100,6 +100,11 @@ def video_from_cache(self):
return self._cached_video
return None

@property
def version(self):
"""Return the camera Firmware version."""
return self._version

@property
def arm(self):
"""Return arm status of camera."""
Expand Down Expand Up @@ -234,7 +239,7 @@ def extract_config_info(self, config):
self.camera_id = str(config.get("id", "unknown"))
self.network_id = str(config.get("network_id", "unknown"))
self.serial = config.get("serial")
self.version = config.get("fw_version")
self._version = config.get("fw_version")
self.motion_enabled = config.get("enabled", "unknown")
self.battery_state = config.get("battery_state") or config.get("battery")
self.temperature = config.get("temperature")
Expand Down
11 changes: 8 additions & 3 deletions blinkpy/sync_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, blink, network_name, network_id, camera_list):
self.region_id = blink.auth.region_id
self.name = network_name
self.serial = None
self.version = None
self._version = None
self.status = "offline"
self.sync_id = None
self.host = None
Expand Down Expand Up @@ -73,7 +73,7 @@ def attributes(self):
"id": self.sync_id,
"network_id": self.network_id,
"serial": self.serial,
"version": self.version,
"version": self._version,
"status": self.status,
"region_id": self.region_id,
"local_storage": self.local_storage,
Expand All @@ -95,6 +95,11 @@ def online(self):
self.available = False
return False

@property
def version(self):
"""Return the Syncmodule Firmware version."""
return self._version

@property
def arm(self):
"""Return status of sync module: armed/disarmed."""
Expand Down Expand Up @@ -155,7 +160,7 @@ async def sync_initialize(self):
"Could not retrieve sync module information with response: %s", response
)
return False
self.version = self.summary.get("fw_version")
self._version = self.summary.get("fw_version")
return response

async def _init_local_storage(self, sync_id):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ def test_missing_attributes(self, mock_resp):
"""Test that attributes return None if missing."""
self.camera.temperature = None
self.camera.serial = None
self.camera._version = None
attr = self.camera.attributes
self.assertEqual(attr["serial"], None)
self.assertEqual(attr["temperature"], None)
self.assertEqual(attr["temperature_c"], None)
self.assertEqual(attr["version"],None)
self.assertEqual(self.camera.version,None)

def test_mini_missing_attributes(self, mock_resp):
"""Test that attributes return None if missing."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_sync_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ async def test_get_camera_info(self, mock_resp) -> None:
self.assertEqual(
await self.blink.sync["test"].get_camera_info("1234"), "foobar"
)
self.assertEqual(self.blink.sync["test"].version,None)

async def test_get_camera_info_fail(self, mock_resp) -> None:
"""Test handling of failed get camera info function."""
Expand Down

0 comments on commit c6769c1

Please sign in to comment.