Skip to content

feat: add ConnectionStatus enum for device connection state#54

Merged
eman merged 2 commits intomainfrom
feature/connection-status-enum
Dec 26, 2025
Merged

feat: add ConnectionStatus enum for device connection state#54
eman merged 2 commits intomainfrom
feature/connection-status-enum

Conversation

@eman
Copy link
Copy Markdown
Owner

@eman eman commented Dec 26, 2025

  • Create ConnectionStatus IntEnum with DISCONNECTED (1) and CONNECTED (2) values
  • Update DeviceInfo.connected field to use ConnectionStatusField with proper type validation
  • Add enum_validator converter for automatic integer-to-enum conversion
  • Set default value to ConnectionStatus.DISCONNECTED

This provides type-safe handling of device connection status based on reverse-engineered Navien protocol documentation (REVERSE_ENGINEERED_FIELDS.md).

BREAKING CHANGE: DeviceInfo.connected is now an enum instead of int. Use .value to get the integer representation or compare directly with ConnectionStatus values.

Related to: #95

eman added 2 commits December 25, 2025 19:38
- Create ConnectionStatus IntEnum with DISCONNECTED (1) and CONNECTED (2) values
- Update DeviceInfo.connected field to use ConnectionStatusField with proper type validation
- Add enum_validator converter for automatic integer-to-enum conversion
- Set default value to ConnectionStatus.DISCONNECTED

This provides type-safe handling of device connection status based on reverse-engineered
Navien protocol documentation (REVERSE_ENGINEERED_FIELDS.md).

BREAKING CHANGE: DeviceInfo.connected is now an enum instead of int. Use .value to get
the integer representation or compare directly with ConnectionStatus values.

Related to: #95
- Add public auth_response property to NavienAuthClient to avoid accessing private _auth_response attribute
- Fix type annotation in OutputFormatter.__init__ to prevent no-redef mypy error
- Keep necessary mypy overrides for click and cli modules due to untyped decorators

This resolves all CI failures while maintaining the ConnectionStatus enum feature.
@eman eman requested a review from Copilot December 26, 2025 04:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces type-safe connection status handling by replacing the integer-based connected field with an IntEnum type. The change provides explicit semantic meaning to connection states (DISCONNECTED=1, CONNECTED=2) based on reverse-engineered protocol documentation. Additionally, the PR includes several type checking improvements: exposing the auth response property for cleaner access patterns, fixing type annotations in the CLI output formatter, and adding mypy configuration to ignore CLI-related type errors.

Key Changes:

  • Adds ConnectionStatus enum with DISCONNECTED (1) and CONNECTED (2) values
  • Updates DeviceInfo.connected to use type-validated enum field with proper default
  • Exposes auth_response property on NavienAuthClient to eliminate unsafe casting

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/nwp500/enums.py Introduces ConnectionStatus IntEnum for device connection state representation
src/nwp500/models.py Updates DeviceInfo to use ConnectionStatusField with enum validation and proper default
src/nwp500/auth.py Exposes auth_response property and refactors authenticate() to use it instead of cast(Any)
src/nwp500/cli/rich_output.py Fixes type annotation style in OutputFormatter constructor
pyproject.toml Adds mypy overrides to ignore CLI module type errors

@eman eman merged commit 72357ea into main Dec 26, 2025
7 checks passed
@eman eman deleted the feature/connection-status-enum branch December 26, 2025 04:21
@eman eman restored the feature/connection-status-enum branch January 16, 2026 01:16
@eman eman deleted the feature/connection-status-enum branch January 26, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants