diff --git a/docs/FEATURE_HISTORY.md b/docs/FEATURE_HISTORY.md index 2738370..b912412 100644 --- a/docs/FEATURE_HISTORY.md +++ b/docs/FEATURE_HISTORY.md @@ -231,6 +231,20 @@ This document tracks the detailed evolution of features and capabilities in the - **Parameter Validation**: Complete input validation and error handling - **Usage Examples**: Extensive real-world usage examples +### Phase 9: Bug Fixes and Stability (February 2025) + +#### Critical Bug Fixes +- **PlayNotificationBeep HTTP Method Fix**: Corrected `/playNotification` endpoint to use GET instead of POST + - **Issue**: `go run ./cmd/soundtouch-cli --host sp beep` was failing with HTTP 400 status + - **Root Cause**: Go client was sending POST requests while SoundTouch devices expect GET requests + - **Fix**: Updated `PlayNotificationBeep()` method to use the existing `c.get()` method with `StationResponse` model + - **Verification**: Tested with SoundTouch 20, confirmed compatibility with curl equivalent (`curl http://:8090/playNotification`) + +#### Code Quality Improvements +- **Consistent HTTP Method Usage**: Leveraged existing client patterns instead of manual HTTP handling +- **Model Reuse**: Used existing `StationResponse` struct for `/playNotification` XML response parsing +- **Documentation Updates**: Added troubleshooting guide for speaker notification issues + ## Feature Implementation Statistics ### API Endpoint Coverage Evolution @@ -245,6 +259,7 @@ This document tracks the detailed evolution of features and capabilities in the | Phase 6 | 2 | 24 | 92% | | Phase 7 | 3 | 27 | 96% | | Phase 8 | 2 | 29 | 100% | +| Phase 9 | 0 | 29 | 100% (Bug fixes) | ### Testing Evolution @@ -257,6 +272,7 @@ This document tracks the detailed evolution of features and capabilities in the - **Phase 6**: Zone management tests (250 tests) - **Phase 7**: Advanced audio tests (300+ tests) - **Phase 8**: Speaker notification tests (330+ tests) +- **Phase 9**: Bug fix verification tests (335+ tests) #### Integration Test Coverage - **Real Device Testing**: SoundTouch 10 and SoundTouch 20 @@ -275,6 +291,7 @@ This document tracks the detailed evolution of features and capabilities in the - **Phase 6**: `zone` - **Phase 7**: Advanced audio commands - **Phase 8**: `speaker` (TTS, URL, beep notifications) +- **Phase 9**: Bug fixes (speaker beep reliability) #### CLI Feature Enhancements - **Host:Port Parsing**: Support for `192.168.1.100:8090` format diff --git a/docs/SPEAKER_ENDPOINT.md b/docs/SPEAKER_ENDPOINT.md index 37de257..7ccc0c1 100644 --- a/docs/SPEAKER_ENDPOINT.md +++ b/docs/SPEAKER_ENDPOINT.md @@ -39,6 +39,8 @@ Plays notification content on the speaker. Plays a simple notification beep sound. +**Important**: This endpoint requires a GET request, not POST. Earlier versions of this client library incorrectly used POST and would fail with HTTP 400 status. + **Response:** ```xml @@ -134,6 +136,7 @@ func main() { func main() { client := client.NewClient(config) + // Uses GET request (fixed in v2025.02+) err := client.PlayNotificationBeep() if err != nil { log.Fatal(err) diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index 76b7fa6..c40b98b 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -355,6 +355,90 @@ client.SetBalanceSafe(10) // Falls back gracefully --- +## 🔔 **Speaker Notification Issues** + +### ❌ "speaker beep" command fails with status 400 + +**Symptoms:** +```bash +$ go run ./cmd/soundtouch-cli --host 192.168.178.35 sp beep +Playing notification beep from 192.168.178.35:8090... +✗ Failed to play notification beep: API request failed with status 400 +``` + +**Cause:** +This was a bug in earlier versions where the Go client incorrectly used POST instead of GET for the `/playNotification` endpoint. + +**Solution:** +Update to the latest version. The fix changed the `PlayNotificationBeep()` method to use GET requests: + +```go +// Fixed implementation (v2025.02+) +func (c *Client) PlayNotificationBeep() error { + var status models.StationResponse + return c.get("/playNotification", &status) +} +``` + +**Verification:** +Both commands should now work identically: +```bash +# CLI command +go run ./cmd/soundtouch-cli --host 192.168.178.35 sp beep + +# Direct curl (for comparison) +curl http://192.168.178.35:8090/playNotification +``` + +### ❌ "speaker" commands not supported + +**Symptoms:** +``` +✗ Failed to play notification: endpoint not supported +``` + +**Causes & Solutions:** + +#### 1. **Device Model Compatibility** +- ✅ **Supported**: SoundTouch 10 (ST-10), SoundTouch 20 (ST-20) +- ❌ **Not Supported**: SoundTouch 300 (ST-300), older models + +**Solution:** Verify device model with: +```bash +soundtouch-cli --host info +``` + +#### 2. **Missing App Key (TTS/URL only)** +TTS and URL playback require an app key, but beep does not: +```bash +# Beep - no app key needed +soundtouch-cli --host speaker beep + +# TTS - app key required +soundtouch-cli --host speaker tts --text "Hello" --app-key "your-key" +``` + +### ❌ "Device is busy" during notifications + +**Symptoms:** +``` +✗ Failed to play notification: device is busy +``` + +**Solutions:** + +#### 1. **Wait for Current Notification to Complete** +Only one notification can play at a time. Wait a few seconds and retry. + +#### 2. **Check Current Playback Status** +```go +nowPlaying, _ := client.GetNowPlaying() +fmt.Printf("Current source: %s, status: %s\n", + nowPlaying.Source, nowPlaying.PlayStatus) +``` + +--- + ## 📡 **WebSocket Issues** ### ❌ "WebSocket connection failed" diff --git a/pkg/client/client.go b/pkg/client/client.go index e84abd6..c6d047d 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -1677,7 +1677,8 @@ func (c *Client) PlayCustom(playInfo *models.PlayInfo) error { // PlayNotificationBeep plays a notification beep on the device func (c *Client) PlayNotificationBeep() error { - return c.post("/playNotification", nil) + var status models.StationResponse + return c.get("/playNotification", &status) } // postPlayInfo sends a PlayInfo request to the /speaker endpoint