v0.1.18 - CommandResponse Wrapper for Flexible Data Access (2025-12-07)¶
What Changed?¶
This release introduces CommandResponse, a new wrapper class that provides both raw (nested) and flattened JSON structures for all Command methods. Users can now easily access device responses in the format that best suits their needsβeither the original nested structure for developers or a flat structure for data export. This improves the user experience for beginners while maintaining full access to detailed information.
What's New¶
Main Feature: CommandResponse Wrapper¶
What it does:
All Command methods now return a CommandResponse object with two attributes:
raw: The original nested JSON structure from the deviceflat: An automatically generated flattened JSON structure with underscore-separated keys
How to use it:
from kazunoko import connect, Command
with connect() as device:
cmd = Command(device)
result = cmd.status()
# Access nested data (developer-friendly)
print(result.raw.version)
print(result.raw.status)
# Access flattened data (export-friendly)
result.flat.model_dump() # {"type": "...", "status": "...", ...}
Code example:
# Before (v0.1.17):
response = cmd.status()
# User had to use flatten() manually for export
# After (v0.1.18):
response = cmd.status()
response.flat.model_dump() # Ready for JSON/CSV export
response.raw.model_dump() # Full nested structure for analysis
Installation¶
Quick Start¶
# Get the release
git checkout vX.Y.Z
# Setup
task env:setup
# Run CLI
uv run kazunoko --help
What's Different from the Last Version?¶
β Added¶
CommandResponsedataclass withrawandflatattributesCommandResponse._flatten()static method for automatic JSON flattening- New public API:
CommandResponsein__init__.py
π§ Changed¶
- All
Commandmethods now returnCommandResponseinstead ofResponse - Affected methods:
help(),status(),version(),poll_count(),deadtime(),uptime(),reset(),mac_address(),queue_stats(),led(),threshold(),thresholds(),rtc_time(),read() - CLI updated to use
response.flat.model_dump()for flattened output flatten()function removed from public API (moved to internal use)
π Fixed¶
- None
Is It Safe to Upgrade?¶
Backward Compatible: No (Breaking Change)
- Breaking Change: All
Commandmethods now returnCommandResponseinstead ofResponse - Existing code using
cmd.status()directly will need to access.rawor.flatattributes - The
flatten()function has been removed from the public API (internal use only) - Migration Path: Change
response.fieldtoresponse.raw.fieldor useresponse.flat.model_dump()for exports
Tests Passed¶
- β Builds without errors
- β
Linting passes (
ruff check) - β
All Command methods return
CommandResponse - β Flattening works correctly for nested and flat JSON
- β CLI works with flattened responses
Release Details¶
- Date: 2025-12-07
- Version: v0.1.18
- Files Changed: 4 (command.py, cli.py, init.py, parser.py)
- Commits: 4
e7afda8feat: Add CommandResponse wrapper for flexible data access5e64fe7refactor: Export CommandResponse from public API6046305refactor: Update CLI to use CommandResponse attributes47a9b03refactor: Unify all Command methods to return CommandResponse
Next Steps¶
- Add comprehensive unit tests for
CommandResponsebehavior - Consider async/await support for streaming detection events
- Explore type hints optimization for better IDE autocomplete