Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types for update_stats #657

Merged
merged 10 commits into from
May 9, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions aiounifi/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,19 @@ class TypedDeviceUplink(TypedDict):
uplink_remote_port: int


class TypedDeviceUpdtimeStats(TypedDict):
kimdv marked this conversation as resolved.
Show resolved Hide resolved
"""Device uptime stats type definition."""

WAN: TypedDeviceUpdtimeStatsWan
Kane610 marked this conversation as resolved.
Show resolved Hide resolved
WAN2: TypedDeviceUpdtimeStatsWan


class TypedDeviceUpdtimeStatsWan(TypedDict):
kimdv marked this conversation as resolved.
Show resolved Hide resolved
"""Device uptime stats wan type definition."""

monitors: list[dict[str, Any]]
kimdv marked this conversation as resolved.
Show resolved Hide resolved


class TypedDeviceWlanOverrides(TypedDict):
"""Device wlan overrides type definition."""

Expand Down Expand Up @@ -489,6 +502,7 @@ class TypedDevice(TypedDict):
uplink_depth: int
uplink_table: list # type: ignore[type-arg]
uptime: int
uptime_stats: TypedDeviceUpdtimeStats
user_num_sta: int
user_wlan_num_sta: int
usg_caps: int
Expand Down Expand Up @@ -971,6 +985,11 @@ def uptime(self) -> int:
"""Uptime of device."""
return self.raw.get("uptime", 0)

@property
def uptime_stats(self) -> TypedDeviceUpdtimeStats | None:
"""Uptime statistics."""
data = self.raw["uptime_stats"]
kimdv marked this conversation as resolved.
Show resolved Hide resolved

@property
def user_num_sta(self) -> int:
"""Amount of connected clients."""
Expand Down