Documentation
ΒΆ
Overview ΒΆ
Package soundtouch provides a comprehensive Go library and CLI tool for controlling Bose SoundTouch devices.
This library implements the complete Bose SoundTouch Web API, enabling programmatic control of SoundTouch speakers including playback control, volume management, source selection, multiroom zone management, and real-time event monitoring via WebSocket connections.
Quick Start ΒΆ
Install the library:
go get github.com/gesellix/bose-soundtouch
Basic usage example:
package main
import (
"fmt"
"log"
"github.com/gesellix/bose-soundtouch/pkg/client"
)
func main() {
// Create a client for your SoundTouch device
config := &client.Config{
Host: "192.168.1.100",
Port: 8090,
}
client := client.NewClient(config)
// Get device information
info, err := client.GetInfo()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Device: %s\n", info.Name)
// Control playback
err = client.Play()
if err != nil {
log.Fatal(err)
}
// Set volume
err = client.SetVolume(50)
if err != nil {
log.Fatal(err)
}
}
Device Discovery ΒΆ
Automatically discover SoundTouch devices on your network:
import "github.com/gesellix/bose-soundtouch/pkg/discovery"
// Discover devices using UPnP/SSDP
service := discovery.NewService(5*time.Second)
devices, err := service.DiscoverDevices(ctx)
if err != nil {
log.Fatal(err)
}
for _, device := range devices {
fmt.Printf("Found device: %s at %s\n", device.Name, device.Host)
}
Real-time Events ΒΆ
Monitor device state changes in real-time using WebSocket connections:
// Subscribe to device events
events, err := client.SubscribeToEvents(ctx)
if err != nil {
log.Fatal(err)
}
for event := range events {
switch e := event.(type) {
case *models.NowPlayingUpdated:
fmt.Printf("Now playing: %s by %s\n", e.Track, e.Artist)
case *models.VolumeUpdated:
fmt.Printf("Volume changed to: %d\n", e.ActualVolume)
}
}
Multiroom Zone Management ΒΆ
Create and manage multiroom zones:
// Create a zone with multiple speakers
zone := &models.Zone{
Master: "192.168.1.100",
Members: []models.ZoneMember{
{IPAddress: "192.168.1.101"},
{IPAddress: "192.168.1.102"},
},
}
err = client.SetZone(zone)
CLI Tool ΒΆ
The package includes a comprehensive CLI tool for device control:
# Install the CLI go install github.com/gesellix/bose-soundtouch/cmd/soundtouch-cli@latest # Discover devices soundtouch-cli discover devices # Control a device soundtouch-cli --host 192.168.1.100 play start soundtouch-cli --host 192.168.1.100 volume set --level 50 soundtouch-cli --host 192.168.1.100 source select --source SPOTIFY
Supported Features ΒΆ
- β Device Information & Capabilities
- β Playback Control (Play/Pause/Stop/Next/Previous)
- β Volume, Bass, and Balance Control
- β Source Selection (Spotify, Bluetooth, AUX, etc.)
- β Preset Management
- β Clock/Time Management
- β Network Information
- β Real-time WebSocket Events
- β Multiroom Zone Management
- β Device Discovery (UPnP/SSDP and mDNS)
- β Cross-platform Support (Windows, macOS, Linux)
Package Structure ΒΆ
- client: HTTP client for SoundTouch Web API
- discovery: Device discovery using UPnP/SSDP and mDNS
- models: Data structures for API requests/responses
- config: Configuration management
- cmd/soundtouch-cli: Command-line interface tool
Hardware Compatibility ΒΆ
This library has been tested with real Bose SoundTouch hardware and supports all SoundTouch-compatible devices including:
- SoundTouch 10, 20, 30 series
- SoundTouch Portable
- Wave SoundTouch music system
- And other SoundTouch-enabled Bose speakers
Implementation Notes ΒΆ
This implementation is based on the official Bose SoundTouch Web API documentation and provides 90% coverage of all available endpoints. It is an independent project and is not affiliated with or endorsed by Bose Corporation.
For detailed API documentation, examples, and advanced usage patterns, visit: https://pkg.go.dev/github.com/gesellix/bose-soundtouch
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
example-mdns
command
Package main provides an example of discovering SoundTouch devices using mDNS.
|
Package main provides an example of discovering SoundTouch devices using mDNS. |
|
example-unified
command
Package main provides an example of discovering SoundTouch devices using all three mechanisms.
|
Package main provides an example of discovering SoundTouch devices using all three mechanisms. |
|
example-upnp
command
Package main provides an example of discovering SoundTouch devices using UPnP.
|
Package main provides an example of discovering SoundTouch devices using UPnP. |
|
mdns-scanner
command
Package main provides a simple mDNS scanner to discover SoundTouch devices on the network.
|
Package main provides a simple mDNS scanner to discover SoundTouch devices on the network. |
|
soundtouch-cli
command
Package main provides the soundtouch-cli balance control commands.
|
Package main provides the soundtouch-cli balance control commands. |
|
websocket-demo
command
Package main provides a demonstration of WebSocket event handling for Bose SoundTouch devices.
|
Package main provides a demonstration of WebSocket event handling for Bose SoundTouch devices. |
|
examples
|
|
|
advanced-audio-controls
command
Package main provides an example of using advanced audio controls.
|
Package main provides an example of using advanced audio controls. |
|
zone-slave-operations
command
Package main provides an example of using zone slave operations.
|
Package main provides an example of using zone slave operations. |
|
pkg
|
|
|
client
Package client provides a comprehensive HTTP client for controlling Bose SoundTouch devices.
|
Package client provides a comprehensive HTTP client for controlling Bose SoundTouch devices. |
|
config
Package config provides configuration management for the Bose SoundTouch Go library.
|
Package config provides configuration management for the Bose SoundTouch Go library. |
|
discovery
Package discovery provides device discovery functionality for Bose SoundTouch devices using mDNS and UPnP protocols.
|
Package discovery provides device discovery functionality for Bose SoundTouch devices using mDNS and UPnP protocols. |
|
models
Package models provides data structures and types for the Bose SoundTouch API.
|
Package models provides data structures and types for the Bose SoundTouch API. |