5 Commits
Author SHA1 Message Date
Tobias Gesellchen 6f27a559e4 fix: auto-resolve whitespace and formatting issues using golangci-lint --fix
- Used 'golangci-lint run --fix' to automatically resolve formatting issues
- Fixed all 52 remaining wsl_v5 (whitespace) issues automatically
- Applied go fmt to ensure consistent formatting across codebase
- Touched 49 files with automatic formatting improvements

MAJOR PROGRESS: Reduced total issues from 79 to 27 (66% reduction!)
Remaining issues:
- gocyclo: 14 (complexity - requires manual refactoring)
- revive: 5 (style/naming)
- staticcheck: 5 (static analysis)
- unparam: 3 (unused parameters)
2026-01-09 23:12:08 +01:00
Tobias Gesellchen a8d9ab99c4 Fix linting issues and test failures
- Fix bodyclose issues by properly closing WebSocket response body
- Fix errcheck issues by checking errors on resp.Body.Close(), conn.Close(), etc.
- Fix errorlint issue by using errors.As() instead of type assertion
- Fix nilerr issue by adding proper logging for UPnP discovery failures
- Fix gocritic issues:
  - Convert if-else chains to switch statements
  - Fix parameter type combining (paramTypeCombine)
  - Fix range value copying (rangeValCopy)
  - Fix exitAfterDefer by calling cancel() before log.Fatalf()
- Add package comments to fix revive package-comments issues
- Rename ClientConfig to Config to avoid type name stuttering
- Add missing exported constant comments
- Fix unused parameter issues by renaming to _
- Fix empty block issues
- Add t.Helper() to test helper functions
- Update User-Agent and fix GetNetworkSummary behavior to match test expectations

Reduces linting issues from 151 to 108 (28% improvement).
All tests now pass.
2026-01-09 13:52:57 +01:00
Tobias Gesellchen e46f050e45 Complete key controls implementation with all 24 documented keys
Enhanced Key Support:
• Expanded from 13 to 24 total key commands
• Added power and system controls (POWER, MUTE)
• Added rating controls (THUMBS_UP, THUMBS_DOWN, BOOKMARK)
• Added playback mode controls (SHUFFLE_OFF/ON, REPEAT_OFF/ONE/ALL)
• Added input controls (AUX_INPUT)
• Organized keys into logical categories for better documentation

CLI Enhancements:
• New direct command flags: -power, -mute, -thumbs-up, -thumbs-down
• Enhanced help output with categorized key listing
• Updated flag descriptions to show all available keys
• Added practical examples for new key commands

Technical Improvements:
• Updated IsValidKey() validation for all 24 keys
• Enhanced GetAllValidKeys() to return complete key set
• Comprehensive test coverage for all new key constants
• Proper error handling and validation for new commands

Real Device Testing:
• POWER command tested successfully on SoundTouch device
• MUTE command tested successfully on SoundTouch device
• All new keys follow proper press+release pattern
• Maintains backward compatibility with existing commands

Documentation Updates:
• API-Endpoints-Overview.md - Complete categorized key reference
• KEY-CONTROLS.md - Enhanced with all playback, rating, and system controls
• STATUS.md - Updated project status to reflect completed key implementation
• CLI help output shows all 24 keys with usage examples

Key Categories Implemented:
- Playback Controls (5 keys): PLAY, PAUSE, STOP, PREV_TRACK, NEXT_TRACK
- Rating Controls (3 keys): THUMBS_UP, THUMBS_DOWN, BOOKMARK
- Power/System Controls (2 keys): POWER, MUTE
- Volume Controls (2 keys): VOLUME_UP, VOLUME_DOWN
- Preset Controls (6 keys): PRESET_1 through PRESET_6
- Input Controls (1 key): AUX_INPUT
- Shuffle Controls (2 keys): SHUFFLE_OFF, SHUFFLE_ON
- Repeat Controls (3 keys): REPEAT_OFF, REPEAT_ONE, REPEAT_ALL

This completes the key controls implementation phase with full API compliance
and comprehensive device testing validation.
2026-01-09 08:58:23 +01:00
Tobias Gesellchen b4e6ce7042 feat: implement GET/POST /volume endpoints with press+release key pattern
Volume Control Implementation:
• Complete GET/POST /volume endpoint implementation with XML models
• Volume model with validation, clamping, and safety features
• Client methods: GetVolume(), SetVolume(), IncreaseVolume(), DecreaseVolume()
• CLI commands: -volume, -set-volume, -inc-volume, -dec-volume with safety limits
• Comprehensive volume level categorization and helper methods

Key Controls Enhancement:
• Fix press+release pattern: SendKey() now sends both press and release states
• Follows API documentation requirement for proper key simulation
• Add SendKeyPressOnly() and SendKeyReleaseOnly() for advanced usage
• Update documentation to reflect press+release behavior
• Add test for press+release pattern validation

Safety Features:
• Volume warnings for levels >30 with 2-second delay
• Increment/decrement limits (10 up, 20 down per command)
• Automatic volume clamping to 0-100 range
• Clear volume level descriptions (Mute, Quiet, Medium, High, Loud)

Testing & Documentation:
• Comprehensive volume control tests (30+ test cases)
• Complete documentation in docs/VOLUME-CONTROLS.md
• Updated key controls documentation for press+release pattern
• Real device testing with both SoundTouch 10 and 20
• All tests pass, no diagnostics errors

Real Device Integration:
• Fixed volume key press issues through proper press+release cycle
• Tested volume API endpoints with actual devices
• Safe volume levels maintained during testing

Breaking Changes: None
Backward Compatibility: Fully maintained

Production Ready:
 Volume control endpoints (GET/POST /volume)
 Enhanced key controls with proper press+release pattern
 Comprehensive safety features for volume management
 Real device validation and testing
2026-01-08 23:56:17 +01:00
Tobias Gesellchen 7d73da7986 feat: implement POST /key endpoint for media controls with host:port parsing
Major Features:
• POST /key endpoint implementation with XML model and validation
• Comprehensive media control commands (play, pause, stop, volume, presets)
• Automatic host:port parsing in CLI for improved UX
• Production-ready with full test coverage

Key Control Implementation:
• Add Key model with XML marshaling and validation (pkg/models/key.go)
• Support all standard keys: PLAY, PAUSE, STOP, PREV_TRACK, NEXT_TRACK, VOLUME_UP/DOWN, PRESET_1-6
• Client methods: SendKey(), Play(), Pause(), Stop(), VolumeUp(), VolumeDown(), SelectPreset()
• CLI commands: -play, -pause, -stop, -next, -prev, -volume-up, -volume-down, -preset, -key
• Critical fix: Use 'Gabbo' as sender (only accepted value by SoundTouch API)

Host:Port Parsing Enhancement:
• Support -host 192.168.178.28:8090 format in addition to separate -host/-port flags
• Robust parsing with IPv4, IPv6, and hostname support
• Graceful fallback for invalid input
• Backward compatible with existing usage

Testing & Documentation:
• Comprehensive unit tests for key functionality and host:port parsing
• Integration tested with real SoundTouch 10 and SoundTouch 20 devices
• Complete documentation in docs/KEY-CONTROLS.md and docs/HOST-PORT-PARSING.md
• All tests pass, no diagnostics errors

Breaking Changes: None
Backward Compatibility: Fully maintained

Tested with:
• SoundTouch 10 (192.168.178.28:8090) 
• SoundTouch 20 (192.168.178.35:8090) 
2026-01-08 23:46:34 +01:00