Skip to content

Commit 72357ea

Browse files
authored
Merge pull request #54 from eman/feature/connection-status-enum
feat: add ConnectionStatus enum for device connection state
2 parents 7956f67 + 7316269 commit 72357ea

5 files changed

Lines changed: 33 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ ignore_missing_imports = true
143143
module = "aiohttp.*"
144144
ignore_missing_imports = true
145145

146+
[[tool.mypy.overrides]]
147+
module = "click.*"
148+
ignore_missing_imports = true
149+
150+
[[tool.mypy.overrides]]
151+
module = "nwp500.cli.*"
152+
ignore_errors = true
153+
146154
[[tool.mypy.overrides]]
147155
module = "pydantic.*"
148156
ignore_missing_imports = true

src/nwp500/auth.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ def current_tokens(self) -> AuthTokens | None:
628628
"""Get current authentication tokens."""
629629
return self._auth_response.tokens if self._auth_response else None
630630

631+
@property
632+
def auth_response(self) -> AuthenticationResponse | None:
633+
"""Get the complete authentication response."""
634+
return self._auth_response
635+
631636
@property
632637
def user_email(self) -> str | None:
633638
"""Get the email address of the authenticated user."""
@@ -716,7 +721,7 @@ async def authenticate(user_id: str, password: str) -> AuthenticationResponse:
716721
>>> # Do not print tokens in production code
717722
"""
718723
async with NavienAuthClient(user_id, password) as client:
719-
auth_response = cast(Any, client)._auth_response
724+
auth_response = client.auth_response
720725
if auth_response is None:
721726
raise AuthenticationError(
722727
"Authentication failed: no response received"

src/nwp500/cli/rich_output.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ class OutputFormatter:
6161
def __init__(self) -> None:
6262
"""Initialize the formatter."""
6363
self.use_rich = _should_use_rich()
64+
self.console: Any
6465
if self.use_rich:
6566
assert Console is not None
66-
self.console: Any = Console()
67+
self.console = Console()
6768
else:
68-
self.console: Any = None
69+
self.console = None
6970

7071
def print_status_table(self, items: list[tuple[str, str, str]]) -> None:
7172
"""Print status items as a formatted table.

src/nwp500/enums.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ class OnOffFlag(IntEnum):
2525
ON = 2
2626

2727

28+
class ConnectionStatus(IntEnum):
29+
"""Device connection status to cloud/MQTT.
30+
31+
Represents whether the device is currently connected to the Navien cloud
32+
service and can receive commands.
33+
"""
34+
35+
DISCONNECTED = 1
36+
CONNECTED = 2
37+
38+
2839
class Operation(IntEnum):
2940
"""Device operation state."""
3041

src/nwp500/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
tou_status_to_python,
2121
)
2222
from .enums import (
23+
ConnectionStatus,
2324
CurrentOperationMode,
2425
DeviceType,
2526
DHWControlTypeFlag,
@@ -61,6 +62,9 @@
6162
VolumeCodeField = Annotated[
6263
VolumeCode, BeforeValidator(enum_validator(VolumeCode))
6364
]
65+
ConnectionStatusField = Annotated[
66+
ConnectionStatus, BeforeValidator(enum_validator(ConnectionStatus))
67+
]
6468

6569

6670
def fahrenheit_to_half_celsius(fahrenheit: float) -> int:
@@ -151,7 +155,7 @@ class DeviceInfo(NavienBaseModel):
151155
additional_value: str = ""
152156
device_type: DeviceType | int = DeviceType.NPF700_WIFI
153157
device_name: str = "Unknown"
154-
connected: int = 0
158+
connected: ConnectionStatusField = ConnectionStatus.DISCONNECTED
155159
install_type: str | None = None
156160

157161

0 commit comments

Comments
 (0)