A clean, modern Python web application for controlling Sonos speakers with voice assistant capabilities.
- 🎵 Sonos Speaker Control: Discover, control, and manage Sonos speakers
- 🤖 AI Assistant: Ask questions about your Sonos speakers
- 🌐 Web Interface: Intuitive Flask-based dashboard
- 🧭 Sonos Web App Integration: Companion mode to launch
play.sonos.comfrom the navigation menu - 💬 Conversation Management: Save and load conversation histories
Note: This version does not include Ollama or RAG features.
- 中文說明: See
README_zh-TW.md - 中文社群: https://www.facebook.com/groups/211308792045575
- Python 3.8+
- macOS/Linux/Windows
macOS:
- Double-click
INSTALL.command - Wait for installation to complete
- Double-click
START.commandto launch
Windows:
- Double-click
INSTALL.bat - Wait for installation to complete
- Double-click
START.batto launch
Linux:
- Run
./INSTALL.sh - Run
./START.sh
-
Clone the repository
git clone <repo-url> cd sonos_home
-
Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Setup environment
cp .env.example .env
-
Start the application
python run.py
-
Access the web interface
- Open
http://localhost:5050in your browser
- Open
sonos_home/
├── app/ # Flask application
│ ├── routes/ # API endpoints
│ ├── services/ # Business logic (Sonos, etc.)
│ ├── utils/ # Helper utilities
│ ├── templates/ # HTML templates
│ └── static/ # CSS, JS, assets
├── data/ # Runtime data
├── config.py # Configuration settings
├── run.py # Flask entry point
├── requirements.txt # Python dependencies
└── README.md # This file
Edit config.py to customize:
- Flask settings (debug mode, port, etc.)
- Sonos discovery timeout
To use the AI conversation features, add your API key in config.py:
Google Gemini:
- Get API key: https://makersuite.google.com/app/apikey
- Set
GEMINI_API_KEYinconfig.pyline 42
OpenAI:
- Get API key: https://platform.openai.com/api-keys
- Set
OPENAI_API_KEYinconfig.pyline 41 - Change
AI_PROVIDERto'openai'inconfig.pyline 36
GET /- Main dashboardPOST /api/sonos/discover- Discover speakers on networkPOST /api/sonos/play- Play on speakerPOST /api/sonos/pause- Pause playback
- Ensure speakers are on the same network
- Check firewall settings
- Increase
SONOS_DISCOVERY_TIMEOUTif needed
pytest tests/pylint app/./build_portable_app.sh # macOS/LinuxMIT License
Contributions welcome! Please follow these steps:
- Create a feature branch
- Make your changes
- Submit a pull request
For issues and questions, please open a GitHub issue.