Sonos Music Search Skill
A custom ClawHub skill that combines Brave Search and Sonos CLI to let you search for and play music on your Sonos speakers directly from the command line.
Features
- Uses Brave Search to find Spotify tracks across the web
- Automatically plays found tracks on your specified Sonos speaker
- Supports viewing currently playing track
- Configurable safe search mode via
SAFESEARCH_MODEenvironment variable - Smart Spotify URI construction (strips tracking query parameters)
- Device discovery with caching and timeout protection
Prerequisites
- Node.js >= 14
- A Sonos speaker on the same network
- A Brave Search API key (Get one here)
- Spotify account linked to your Sonos system
Installation
- Install dependencies:
npm install - Set your Brave Search API key:
export BRAVE_API_KEY=your-api-key - (Optional) Configure safe search mode:
export SAFESEARCH_MODE=moderate(default:moderate, options:off,moderate,strict)
Usage
Play a track
node src/index.js play "Living Room" "pink floyd comfortably numb"
View currently playing track
node src/index.js current "Living Room"
Programmatic usage
const { searchAndPlay, getCurrentTrack } = require('./src/index');
const result = await searchAndPlay('Living Room', 'pink floyd comfortably numb');
console.log(result);
// { success: true, track: '...', speaker: 'Living Room', uri: 'spotify:track:...' }
const track = await getCurrentTrack('Living Room');
console.log(track);
// { title: 'Comfortably Numb', artist: 'Pink Floyd', album: '...', duration: 382 }
Configuration
| Environment Variable | Required | Default | Description |
|---|---|---|---|
BRAVE_API_KEY |
Yes | - | Your Brave Search API key |
SAFESEARCH_MODE |
No | moderate |
Safe search mode: off/moderate/strict |
Audit the skill
npm run audit
Format markdown files
npm run format
Publish to ClawHub
clawhub publish .
License
MIT