Implement /name, /capabilities, and /presets informational endpoints

## New Endpoints

### GET /name 
- Simple device name retrieval with XML parsing
- Helper methods for name validation and display
- Real device name integration with anonymization

### GET /capabilities 
- Comprehensive device capabilities detection
- Complex XML structure with nested network, DSP, and system configurations
- Smart categorization: System Features, Audio Features, Network Features
- Capability-specific helper methods (HasLRStereoCapability, HasDualModeNetwork, etc.)
- Extended capabilities parsing with URLs and metadata

### GET /presets 
- Complete preset management with timestamps and metadata
- Spotify playlist integration with anonymized account information
- Smart filtering: by source, used/empty slots, most recent, oldest presets
- Comprehensive analysis: preset summaries with source breakdowns
- Time-based operations: creation/update timestamps with formatted display

## Device Introspection Features

### Capability Detection
- System capabilities: Light Switch, Clock Display, BCO Reset, Power Saving
- Audio capabilities: L/R Stereo support, DSP Mono/Stereo availability
- Network capabilities: Dual Mode, WSAPI Proxy, Hosted WiFi Configuration
- Extended capabilities: Custom endpoint discovery with URL mapping

### Preset Analysis
- Usage pattern analysis (used vs empty slots)
- Source distribution (Spotify, TuneIn, etc.)
- Temporal analysis (most recent, oldest presets)
- Content metadata extraction (artwork URLs, display names)

## Enhanced CLI Tool

### New Commands
- Added -name command with simple device identification
- Added -capabilities command with categorized feature display
- Added -presets command with comprehensive preset analysis
- Enhanced help system with all new command examples

### Rich Output Formatting
- Capability categorization with bullet-point display
- Preset timeline with creation/update timestamps
- Smart metadata display (artwork, source accounts, content types)
- Device-specific feature highlighting (different capabilities per device)

## Real Device Integration

### Multi-Device Testing
- Device 192.168.178.28: SoundTouch 10 with Light Switch, Clock Display, Hosted WiFi
- Device 192.168.178.35: SoundTouch 20 with L/R Stereo, Dual Mode networking
- Verified capability differences between device models
- Real preset data with anonymized Spotify account information

### Edge Case Handling
- Non-responsive endpoints (/trackInfo timeout handling)
- Empty preset configurations
- Missing capability sections
- Device-specific feature variations

## Quality & Testing

### Comprehensive Test Coverage
- 15+ unit tests for XML models with real device response patterns
- Client integration tests with mock HTTP servers
- Edge case validation (empty names, missing capabilities, no presets)
- Timestamp parsing and validation with Unix epoch conversion

### Production-Ready Features
- Type-safe XML unmarshaling with custom validation
- Robust error handling for network and parsing failures
- Privacy protection with anonymized real device data
- Documentation updates with real-world usage examples

## API Coverage Progress

 Complete Information Endpoints:
- GET /info - Device information
- GET /name - Device name
- GET /capabilities - Device capabilities
- GET /presets - Configured presets
- GET /now_playing - Current playback status
- GET /sources - Available audio sources

🔄 Next Phase - Control Endpoints:
- POST /key - Media controls
- GET/POST /volume - Volume management
- WebSocket / - Real-time events

Features:
 Comprehensive device introspection and capability detection
 Smart preset management with timeline analysis
 Multi-device support with hardware-specific feature detection
 Production-ready error handling and data validation
 Rich CLI interface with categorized output formatting
 Real device integration with privacy-protected test data
This commit is contained in:
Tobias Gesellchen
2026-01-08 23:32:18 +01:00
parent 5caad90d51
commit de2ff3550f
13 changed files with 1694 additions and 13 deletions
+1
View File
@@ -78,6 +78,7 @@ When creating test data for API endpoints, prefer real device responses over hyp
- **Usage**: Fetch real responses to create accurate test fixtures
- **Privacy**: Anonymize any personal data (account names, personal playlists, etc.)
- **Coverage**: Use multiple real devices to cover different response variations
- **Non-responsive endpoints**: Some endpoints like `/trackInfo` may not respond or exist on all devices
## Additional Notes
+10 -2
View File
@@ -310,6 +310,9 @@ func (c Config) Validate() error
- [x] DeviceInfo - Device information endpoint
- [x] NowPlaying - Current playback status endpoint
- [x] Sources - Available audio sources endpoint
- [x] Name - Device name endpoint
- [x] Capabilities - Device capabilities endpoint
- [x] Presets - Configured presets endpoint
- [x] Custom XML unmarshaling for enums
- [x] Validation and defaults
- [x] **CLI tool for testing** ✅ DONE
@@ -318,6 +321,9 @@ func (c Config) Validate() error
- [x] Device info retrieval
- [x] Now playing status
- [x] Audio sources listing
- [x] Device name retrieval
- [x] Device capabilities inspection
- [x] Preset configuration listing
- [x] **Unit tests with mocks** ✅ DONE
- [x] HTTP client tests
- [x] XML parsing tests
@@ -659,11 +665,13 @@ docker-compose up # Mock devices + web app
### Phase 1-2 (Foundation)
- ✅ Stable HTTP API connection to SoundTouch devices
- ✅ XML model coverage for implemented APIs (DeviceInfo, NowPlaying, Sources)
- ✅ XML model coverage for implemented APIs (DeviceInfo, NowPlaying, Sources, Name, Capabilities, Presets)
- ✅ Automatic device discovery via UPnP
- ✅ Functional CLI tool with discovery, info, now playing, and sources commands
- ✅ Functional CLI tool with discovery, info, now playing, sources, name, capabilities, and presets commands
- ✅ Now Playing endpoint with comprehensive status information
- ✅ Sources endpoint with filtering and categorization features
- ✅ Device identification endpoints (name, capabilities)
- ✅ Preset management with comprehensive analysis and filtering
### Phase 3-4 (Real-time & Web)
- ✅ WebSocket event streaming with reconnection