Skip to content

Commit

Permalink
Add hdd_list, hdd_type, hdd_available
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG committed Feb 19, 2024
1 parent cdd41d0 commit d606a67
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions reolink_aio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,8 @@ def hdd_info(self) -> list[dict]:
return self._hdd_info

@property
def hdds_available(self) -> list[int]:
available_hdds = []
for idx, hdd in enumerate(self._hdd_info):
if hdd.get("format") == 1 and hdd.get("mount") == 1:
available_hdds.append(idx)
return available_hdds
def hdd_list(self) -> list[int]:
return list(range(0, len(self._hdd_info)))

@property
def stream(self) -> str:
Expand Down Expand Up @@ -450,6 +446,25 @@ def hdd_storage(self, index) -> float:

return round(100*(1-self._hdd_info[index].get("size", 1)/self._hdd_info[index].get("capacity", 1)), 2)

def hdd_type(self, index) -> str:
"""Return the storage type, 'SD', 'HDD' or 'unknown'."""
if index >= len(self._hdd_info):
return "unknown"

type = self._hdd_info[index].get("storageType", 2)
if type == 1:
return "HDD"
if type == 2:
return "SD"

return "unknown"

def hdd_available(self, index) -> bool:
if index >= len(self._hdd_info):
return False

return self._hdd_info[index].get("format") == 1 and self._hdd_info[index].get("mount") == 1

def timezone(self) -> Optional[tzinfo]:
"""Get the timezone of the device
Expand Down

0 comments on commit d606a67

Please sign in to comment.