Skip to content

Add device-info CLI command and InstallType enum#56

Merged
eman merged 4 commits intomainfrom
feat/device-info-command
Dec 26, 2025
Merged

Add device-info CLI command and InstallType enum#56
eman merged 4 commits intomainfrom
feat/device-info-command

Conversation

@eman
Copy link
Copy Markdown
Owner

@eman eman commented Dec 26, 2025

Summary

New CLI command to retrieve basic device information from REST API, plus new InstallType enum for device installation classification.

Features Added

1. New device-info CLI Command

Retrieves basic device information via REST API (DeviceInfo model):

# Get basic device info
python3 -m nwp500.cli device-info

# Get raw JSON
python3 -m nwp500.cli device-info --raw

This complements the existing info command which gets DeviceFeature via MQTT.

2. InstallType Enum

New enum for device installation classification:

  • InstallType.RESIDENTIAL = "R" - Residential use
  • InstallType.COMMERCIAL = "C" - Commercial use

3. String Enum Validator

New str_enum_validator() converter for string-based enums, similar to the existing enum_validator() but for str-based enums.

Changes

  • DeviceInfo Model: install_type field now uses InstallType enum instead of plain string with automatic validation
  • CLI Documentation: Updated README to clarify distinction between info (MQTT) and device-info (REST API) commands
  • Enums: Added INSTALL_TYPE_TEXT mapping for human-readable display

Testing

✅ All 378 tests passing
✅ Linting checks passing
✅ Type checking passing

Documentation

  • Updated CHANGELOG.rst with version 7.2.1
  • Updated README.rst with new command usage

Added new CLI command to retrieve basic device information from REST API
and new InstallType enum for device installation classification.

Features:
- New 'device-info' CLI command to get DeviceInfo via REST API
- New InstallType enum (RESIDENTIAL='R', COMMERCIAL='C')
- New str_enum_validator() converter for string-based enums
- DeviceInfo.install_type now uses InstallType enum with validation
- Added INSTALL_TYPE_TEXT mapping for display

This complements the existing 'info' command which gets DeviceFeature
via MQTT, providing a lighter-weight option for basic device information.

All 378 tests passing.
…sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
eman added 2 commits December 25, 2025 21:43
Resolved conflicts:
- Removed tou_status_to_python function (consolidated to device_bool_to_python)
- Updated DeviceInfo.connected field to use ConnectionStatus enum
- Changed DeviceInfo.install_type to plain string (removed InstallType enum)
- Removed TestTouStatusConverter tests (functionality now covered by device_bool tests)
- Remove unused imports (str_enum_validator, InstallType)
- Update CLI handler to work with string install_type
- Fix line length in device info output
@eman
Copy link
Copy Markdown
Owner Author

eman commented Dec 26, 2025

Merge Update

Successfully merged main branch into feat/device-info-command to resolve conflicts.

Changes Made

Resolved conflicts:

  • Removed tou_status_to_python function (consolidated to device_bool_to_python)
  • Updated DeviceInfo.connected field to use ConnectionStatus enum (from main)
  • Changed DeviceInfo.install_type back to plain str type (removed InstallType enum per main branch changes)
  • Removed TestTouStatusConverter tests (functionality now covered by device_bool tests)
  • Updated CLI handler to work with string-based install_type instead of enum

Note: The InstallType enum and str_enum_validator introduced in this PR were removed during the merge to align with main branch's decision to keep install_type as a plain string. The CLI command functionality remains intact.

Validation

  • ✅ All linting checks passed
  • ✅ Type checking passed
  • ✅ All 363 tests passed

@eman eman requested a review from Copilot December 26, 2025 06:03
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 adds a new CLI command for retrieving basic device information via REST API and introduces an InstallType enum for device installation classification.

Key Changes:

  • New device-info CLI command that fetches device information from the REST API (complementing the existing info command which uses MQTT)
  • InstallType enum added to classify devices as residential or commercial installations
  • str_enum_validator() converter function for validating string-based enums

Reviewed changes

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

Show a summary per file
File Description
src/nwp500/enums.py Adds InstallType enum and INSTALL_TYPE_TEXT mapping for residential/commercial classification
src/nwp500/converters.py Implements str_enum_validator() function for string-based enum validation
src/nwp500/cli/handlers.py Adds handle_get_device_info_rest() handler to fetch and display device info via REST API
src/nwp500/cli/main.py Implements device-info CLI command with raw JSON output option
src/nwp500/cli/init.py Exports new handle_get_device_info_rest handler
src/nwp500/init.py Exports InstallType enum in public API
README.rst Updates CLI documentation to distinguish between info (MQTT) and device-info (REST API) commands
CHANGELOG.rst Documents version 7.2.1 changes including new command and enum

@eman eman merged commit 478c624 into main Dec 26, 2025
7 checks passed
@eman eman deleted the feat/device-info-command branch December 26, 2025 06:06
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