diff --git a/pyproject.toml b/pyproject.toml index 0c888ef..ba43af5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -143,6 +143,14 @@ ignore_missing_imports = true module = "aiohttp.*" ignore_missing_imports = true +[[tool.mypy.overrides]] +module = "click.*" +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = "nwp500.cli.*" +ignore_errors = true + [[tool.mypy.overrides]] module = "pydantic.*" ignore_missing_imports = true diff --git a/src/nwp500/auth.py b/src/nwp500/auth.py index 42584f7..6e4e451 100644 --- a/src/nwp500/auth.py +++ b/src/nwp500/auth.py @@ -628,6 +628,11 @@ def current_tokens(self) -> AuthTokens | None: """Get current authentication tokens.""" return self._auth_response.tokens if self._auth_response else None + @property + def auth_response(self) -> AuthenticationResponse | None: + """Get the complete authentication response.""" + return self._auth_response + @property def user_email(self) -> str | None: """Get the email address of the authenticated user.""" @@ -716,7 +721,7 @@ async def authenticate(user_id: str, password: str) -> AuthenticationResponse: >>> # Do not print tokens in production code """ async with NavienAuthClient(user_id, password) as client: - auth_response = cast(Any, client)._auth_response + auth_response = client.auth_response if auth_response is None: raise AuthenticationError( "Authentication failed: no response received" diff --git a/src/nwp500/cli/rich_output.py b/src/nwp500/cli/rich_output.py index eae02ac..c3838e7 100644 --- a/src/nwp500/cli/rich_output.py +++ b/src/nwp500/cli/rich_output.py @@ -61,11 +61,12 @@ class OutputFormatter: def __init__(self) -> None: """Initialize the formatter.""" self.use_rich = _should_use_rich() + self.console: Any if self.use_rich: assert Console is not None - self.console: Any = Console() + self.console = Console() else: - self.console: Any = None + self.console = None def print_status_table(self, items: list[tuple[str, str, str]]) -> None: """Print status items as a formatted table. diff --git a/src/nwp500/enums.py b/src/nwp500/enums.py index cfc6ab0..512c899 100644 --- a/src/nwp500/enums.py +++ b/src/nwp500/enums.py @@ -25,6 +25,17 @@ class OnOffFlag(IntEnum): ON = 2 +class ConnectionStatus(IntEnum): + """Device connection status to cloud/MQTT. + + Represents whether the device is currently connected to the Navien cloud + service and can receive commands. + """ + + DISCONNECTED = 1 + CONNECTED = 2 + + class Operation(IntEnum): """Device operation state.""" diff --git a/src/nwp500/models.py b/src/nwp500/models.py index d3c01e8..22e484e 100644 --- a/src/nwp500/models.py +++ b/src/nwp500/models.py @@ -20,6 +20,7 @@ tou_status_to_python, ) from .enums import ( + ConnectionStatus, CurrentOperationMode, DeviceType, DHWControlTypeFlag, @@ -61,6 +62,9 @@ VolumeCodeField = Annotated[ VolumeCode, BeforeValidator(enum_validator(VolumeCode)) ] +ConnectionStatusField = Annotated[ + ConnectionStatus, BeforeValidator(enum_validator(ConnectionStatus)) +] def fahrenheit_to_half_celsius(fahrenheit: float) -> int: @@ -151,7 +155,7 @@ class DeviceInfo(NavienBaseModel): additional_value: str = "" device_type: DeviceType | int = DeviceType.NPF700_WIFI device_name: str = "Unknown" - connected: int = 0 + connected: ConnectionStatusField = ConnectionStatus.DISCONNECTED install_type: str | None = None