Skip to content

Commit 9ba75f8

Browse files
committed
Add suitable defaults for disconnected device status
1 parent f95e7cd commit 9ba75f8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/tplink_omada_client/devices.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def ip_address(self) -> str:
7171
return self._data["ip"]
7272

7373
@property
74-
def display_uptime(self) -> str:
74+
def display_uptime(self) -> Optional[str]:
7575
"""Uptime of the device, as a display string"""
7676
if self._data["statusCategory"] == DeviceStatusCategory.CONNECTED:
7777
return self._data["uptime"]
@@ -83,22 +83,22 @@ def cpu_usage(self) -> int:
8383
if self._data["statusCategory"] == DeviceStatusCategory.CONNECTED:
8484
return self._data["cpuUtil"]
8585
else:
86-
return math.nan
86+
return 0
8787

8888
@property
8989
def mem_usage(self) -> int:
9090
if self._data["statusCategory"] == DeviceStatusCategory.CONNECTED:
9191
return self._data["memUtil"]
9292
else:
93-
return math.nan
93+
return 0
9494

9595
@property
9696
def uptime(self) -> int:
9797
"""Uptime of the device, as a display string"""
9898
if self._data["statusCategory"] == DeviceStatusCategory.CONNECTED:
9999
return self._data["uptimeLong"]
100100
else:
101-
return math.nan
101+
return 0
102102

103103
@property
104104
def firmware_version(self) -> str:
@@ -115,15 +115,15 @@ def need_upgrade(self) -> bool:
115115
if self._data["statusCategory"] == DeviceStatusCategory.CONNECTED:
116116
return self._data["needUpgrade"]
117117
else:
118-
return None
118+
return False
119119

120120
@property
121121
def fw_download(self) -> bool:
122122
"""True, if a firmware upgrade is being downloaded."""
123123
if self._data["statusCategory"] == DeviceStatusCategory.CONNECTED:
124124
return self._data["fwDownload"]
125125
else:
126-
return None
126+
return False
127127

128128

129129
class OmadaLink(OmadaApiData):

0 commit comments

Comments
 (0)