mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-18 00:26:29 +00:00
Files in cmd/ examples/ scripts/ referenced docs/guides/ and docs/reference/ which moved to docs/content/docs/guides/ and docs/content/docs/reference/. A few links to loose files at the docs/ root were updated to their new location under docs/content/docs/appendix/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Music Service Account Management Example
This example demonstrates how to manage music streaming service accounts and network music library connections on Bose SoundTouch devices.
Overview
The SoundTouch device can store credentials for various music streaming services and network music libraries. This allows you to:
- Add streaming service accounts (Spotify, Pandora, Amazon Music, Deezer, iHeartRadio)
- Configure network music libraries (NAS/UPnP/DLNA servers)
- Remove accounts when no longer needed
- List currently configured accounts
Running the Example
-
Update the device IP address in
main.go:config := &client.Config{ Host: "192.0.2.100", // Replace with your device IP Port: 8090, Timeout: 10 * time.Second, } -
Run the example:
go run main.go
Supported Music Services
Streaming Services (require username/password)
- Spotify Premium: Personal Spotify accounts
- Pandora: Pandora Music Service accounts
- Amazon Music: Amazon Music accounts
- Deezer Premium: Deezer subscription accounts
- iHeartRadio: iHeartRadio accounts
Network Music Libraries (no password required)
- STORED_MUSIC: NAS, UPnP, and DLNA media servers
- LOCAL_MUSIC: Local music servers
Key Features Demonstrated
1. Adding Accounts
// Convenience methods for popular services
err := client.AddSpotifyAccount("user@spotify.com", "password")
err := client.AddPandoraAccount("username", "password")
err := client.AddAmazonMusicAccount("username", "password")
// Generic method for any service
credentials := models.NewMusicServiceCredentials("TIDAL", "Tidal HiFi", "user", "pass")
err := client.SetMusicServiceAccount(credentials)
// Network music library (no password needed)
err := client.AddStoredMusicAccount("server-guid/0", "My Music Server")
2. Removing Accounts
// Convenience methods
err := client.RemoveSpotifyAccount("user@spotify.com")
err := client.RemovePandoraAccount("username")
// Generic removal method
credentials := models.NewSpotifyCredentials("user@spotify.com", "") // Empty password = removal
err := client.RemoveMusicServiceAccount(credentials)
3. Validating Credentials
credentials := models.NewSpotifyCredentials("user", "pass")
if err := credentials.Validate(); err != nil {
log.Fatal("Invalid credentials:", err)
}
4. Checking Account Status
sources, err := client.GetSources()
if err != nil {
log.Fatal(err)
}
// Look for sources with accounts configured
for _, source := range sources.Sources {
if source.SourceAccount != "" {
fmt.Printf("Service: %s, Account: %s, Status: %s\n",
source.Source, source.SourceAccount, source.Status)
}
}
CLI Usage Examples
After setting up accounts programmatically, you can also manage them via the CLI:
# List configured accounts
soundtouch-cli --host 192.0.2.10 account list
# Add accounts via CLI
soundtouch-cli --host 192.0.2.10 account add-spotify --user user@spotify.com --password mypass
soundtouch-cli --host 192.0.2.10 account add-pandora --user pandora_user --password pandora_pass
soundtouch-cli --host 192.0.2.10 account add-nas --user "guid/0" --name "My NAS"
# Remove accounts
soundtouch-cli --host 192.0.2.10 account remove-spotify --user user@spotify.com
Network Music Libraries
For STORED_MUSIC (NAS/UPnP) services:
- The
userfield should contain the UPnP server GUID followed by/0 - You can find the GUID by discovering UPnP devices on your network
- No password is required
- You can specify a custom display name for the library
Example GUID format: d09708a1-5953-44bc-a413-123456789012/0
Error Handling
The example includes comprehensive error handling for common scenarios:
- Network connectivity issues
- Invalid credentials
- Missing required fields
- Service-specific authentication failures
Security Notes
- Credentials are sent securely to the SoundTouch device over your local network
- The device stores encrypted credentials internally
- Passwords are only required during the initial setup
- Use the removal methods to completely delete stored credentials
Next Steps
After configuring accounts:
- Use
source listto verify services are available - Use
source selectto choose a music service - Use
browsecommands to explore content - Use
playcommands to start playback
See the CLI Reference for complete documentation.