mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 00:56:16 +00:00
feat: add events subscribe command to CLI
Add WebSocket event monitoring functionality to soundtouch-cli: • New 'events subscribe' command for real-time device monitoring • Support for all 8 event types: nowPlaying, volume, connection, preset, zone, bass, sdkInfo, userActivity • Event filtering with --filter flag (comma-separated list) • Duration limits with --duration flag • Reconnection control with --no-reconnect flag • Verbose logging with --verbose flag • Comprehensive test coverage with 349+ test cases • Full documentation updates in CLI-REFERENCE.md and websocket-events.md Usage examples: - soundtouch-cli --host 192.168.1.100 events subscribe - soundtouch-cli --host 192.168.1.100 events subscribe --filter volume,nowPlaying - soundtouch-cli --host 192.168.1.100 events subscribe --duration 5m --verbose Resolves README discrepancy - the documented command now works as expected. All golangci-lint issues resolved, maintains code quality standards.
This commit is contained in:
@@ -772,6 +772,58 @@ soundtouch-cli --host 192.168.1.10 speaker beep
|
||||
- Currently playing content is paused during notification and resumed after
|
||||
- If device is zone master, notification plays on all zone members
|
||||
|
||||
### WebSocket Events
|
||||
|
||||
#### `events <subcommand>`
|
||||
|
||||
Real-time device event monitoring via WebSocket connection.
|
||||
|
||||
##### `events subscribe`
|
||||
|
||||
Subscribe to real-time device events and display them in the terminal.
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
soundtouch-cli --host <device> events subscribe [flags]
|
||||
```
|
||||
|
||||
**Flags:**
|
||||
- `--filter, -f <types>` - Filter events by type (comma-separated)
|
||||
- `--duration, -d <duration>` - How long to listen (0 = infinite)
|
||||
- `--no-reconnect` - Disable automatic reconnection
|
||||
- `--verbose, -v` - Enable verbose logging
|
||||
|
||||
**Event Types:**
|
||||
- `nowPlaying` - Track changes, playback status
|
||||
- `volume` - Volume and mute changes
|
||||
- `connection` - Network connectivity status
|
||||
- `preset` - Preset configuration changes
|
||||
- `zone` - Multiroom zone changes
|
||||
- `bass` - Bass level changes
|
||||
- `sdkInfo` - SDK version information
|
||||
- `userActivity` - User interaction notifications
|
||||
|
||||
**Examples:**
|
||||
```bash
|
||||
# Monitor all events
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe
|
||||
|
||||
# Monitor only volume and now playing events
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe --filter volume,nowPlaying
|
||||
|
||||
# Monitor for 5 minutes with verbose output
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe --duration 5m --verbose
|
||||
|
||||
# Monitor zone events without automatic reconnection
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe --filter zone --no-reconnect
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
- WebSocket connection automatically reconnects on connection loss (unless disabled)
|
||||
- Press Ctrl+C to stop monitoring
|
||||
- Events are displayed in real-time with emoji indicators
|
||||
- Verbose mode shows additional technical details
|
||||
|
||||
## Common Usage Patterns
|
||||
|
||||
### Quick Device Setup
|
||||
|
||||
@@ -64,7 +64,27 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
### Using the CLI Demo
|
||||
### Using the CLI
|
||||
|
||||
The recommended way to monitor WebSocket events is through the built-in CLI command:
|
||||
|
||||
```bash
|
||||
# Monitor all events from a specific device
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe
|
||||
|
||||
# Monitor only volume and now playing events
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe --filter volume,nowPlaying
|
||||
|
||||
# Monitor for 5 minutes with verbose output
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe --duration 5m --verbose
|
||||
|
||||
# Monitor zone events without automatic reconnection
|
||||
soundtouch-cli --host 192.168.1.10 events subscribe --filter zone --no-reconnect
|
||||
```
|
||||
|
||||
### Using the CLI Demo (Alternative)
|
||||
|
||||
For development or testing purposes, you can also use the standalone demo:
|
||||
|
||||
```bash
|
||||
# Auto-discover device and monitor all events
|
||||
|
||||
Reference in New Issue
Block a user