Pywiim
Python library for controlling WiiM and LinkPlay-based audio devices. Provides async HTTP API client, UPnP event subscriptions for real-time updates, device discovery tools, and comprehensive diagnostics. Full type hints, error handling, and support for playback control, audio settings, groups, presets, and more.
Install / Use
/learn @mjcumming/PywiimREADME
pywiim
Python library for WiiM and LinkPlay device control with command-line tools for discovery, diagnostics, and monitoring.
Overview
pywiim provides control of WiiM and LinkPlay-based audio devices through a Python API and command-line tools. The library handles playback control, volume management, multiroom audio, EQ settings, presets, and more.
Key Features
- MCP Server - Expose WiiM control to Cursor, Claude Desktop, and other MCP hosts.
pip install pywiim[mcp]thenwiim-mcp. Control playback, volume, and more via AI assistants. - Playback Control - Play, pause, stop, next/previous track, seek
- Volume & Audio - Volume control, mute, channel balance, audio output selection (Line Out, Optical, Coax, USB Out, HDMI Out, Bluetooth/Headphones)
- Sources - Intelligent model-specific source management (Bluetooth, Line In, Optical In, Coaxial, USB, HDMI ARC, Phono) and streaming services. Authoritative hardware filtering and UI-ready formatting.
- Source Catalog - Structured source metadata via
player.source_catalog(source type, selectability, and per-source capability flags) for integrations like Music Assistant. - Multiroom Audio - Create/join/leave groups, synchronized volume and playback
- EQ & Presets - 10-band EQ with presets, 20 preset stations; Parametric EQ (PEQ) on WiiM (10-band per-source, stereo/L-R, presets; see [PR #12]
- Timers & Alarms - Sleep timers and alarm clocks (WiiM devices)
- State Synchronization - UPnP events with HTTP polling fallback
- Device Discovery - SSDP/UPnP discovery with network scanning fallback
- Multi-vendor Support - WiiM, Arylic, Audio Pro, and generic LinkPlay devices
Device Compatibility:
- All LinkPlay devices: Core playback, volume, sources, multiroom, presets
- Device-dependent features: EQ support (varies by device)
- WiiM devices only: Alarm clocks, sleep timers, audio output mode selection, and Parametric EQ (PEQ) (LV2 PEQ API)
The library automatically detects device capabilities and adapts functionality accordingly.
Installation
Install pywiim to use the command-line tools for discovering, testing, and monitoring your WiiM/LinkPlay devices, or to use the Python library in your projects.
Prerequisites
- Python 3.11 or later
- pip (usually included with Python)
Installing Python:
- Linux/macOS: Usually pre-installed. If not, use your package manager or download from python.org
- Windows: Download from python.org and check "Add Python to PATH" during installation
Install pywiim
pip install pywiim
The CLI tools (wiim-discover, wiim-diagnostics, wiim-monitor, wiim-verify) are automatically installed and available in your PATH.
Verify installation:
wiim-discover --help
Note for Windows users: If the commands are not found after installation, ensure Python's Scripts directory is in your PATH (usually C:\Users\YourName\AppData\Local\Programs\Python\Python3X\Scripts), or restart your terminal.
Command-Line Tools
The library includes four powerful CLI tools that are automatically installed with pywiim. These tools provide an easy way to discover, diagnose, monitor, and test your WiiM/LinkPlay devices without writing any code.
Quick Start
-
Discover devices on your network:
wiim-discover -
Test a device (replace
192.168.1.100with your device IP):wiim-verify 192.168.1.100 -
Monitor a device in real-time:
wiim-monitor 192.168.1.100 -
Run diagnostics:
wiim-diagnostics 192.168.1.100
1. Device Discovery (wiim-discover)
Discover all WiiM/LinkPlay devices on your network using SSDP/UPnP or network scanning.
What it does:
- Automatically finds all WiiM and LinkPlay-based devices on your local network
- Validates discovered devices by testing their API
- Displays device information (name, model, firmware, IP, MAC, UUID)
- Supports multiple discovery methods for maximum compatibility
Usage:
# Basic discovery (SSDP/UPnP)
wiim-discover
# Output as JSON (useful for scripting)
wiim-discover --output json
# Skip API validation (faster, less detailed)
wiim-discover --no-validate
# Verbose logging
wiim-discover --verbose
# Custom SSDP timeout
wiim-discover --ssdp-timeout 10
Options:
--ssdp-timeout <seconds>- SSDP discovery timeout (default: 5)--no-validate- Skip API validation of discovered devices--output <text|json>- Output format (default: text)--verbose, -v- Enable verbose logging
Example Output:
🔍 Discovering WiiM/LinkPlay devices via SSDP...
Device: WiiM Mini
IP Address: 192.168.1.100:80
Protocol: HTTP
Model: WiiM Mini
Firmware: 4.8.123456
MAC Address: AA:BB:CC:DD:EE:FF
UUID: 12345678-1234-1234-1234-123456789abc
Vendor: WiiM
Discovered via: SSDP
Status: Validated ✓
See Discovery Documentation for more information.
2. Diagnostic Tool (wiim-diagnostics)
Comprehensive diagnostic tool for troubleshooting device issues and gathering information for support.
What it does:
- Gathers complete device information (model, firmware, MAC, UUID, capabilities)
- Includes UPnP
description.xmlcapability enrichment (advertised services like PlayQueue/QPlay) - Tests all API endpoints to verify functionality
- Tests feature support (presets, EQ, multiroom, Bluetooth, etc.)
- Generates detailed JSON reports for sharing with developers
- Identifies errors and warnings
Usage:
# Basic diagnostic
wiim-diagnostics 192.168.1.100
# Save report to file (for sharing with support)
wiim-diagnostics 192.168.1.100 --output report.json
# HTTPS device
wiim-diagnostics 192.168.1.100 --port 443
# Verbose output
wiim-diagnostics 192.168.1.100 --verbose
Options:
<device_ip>- Device IP address or hostname (required)--port <port>- Device port (default: 80, use 443 for HTTPS)--output <file>- Save report to JSON file--verbose- Enable detailed logging
What it tests:
- Device information retrieval
- Capability detection
- All status endpoints
- Feature support detection
- API endpoint availability
- Error conditions
Example Output:
🔍 Starting comprehensive device diagnostic...
Device: 192.168.1.100:80
📋 Gathering device information...
✓ Device: WiiM Mini (WiiM Mini)
✓ Firmware: 4.8.123456
✓ MAC: AA:BB:CC:DD:EE:FF
🔧 Detecting device capabilities...
✓ Vendor: WiiM
✓ Device Type: WiiM
✓ Supports EQ: Yes
✓ Supports Presets: Yes
...
See Diagnostics Documentation for more information.
3. Real-time Monitor (wiim-monitor)
Monitor your device in real-time with adaptive polling and UPnP event support.
What it does:
- Displays live device status with automatic updates
- Uses UPnP events for instant updates when available
- Falls back to adaptive HTTP polling
- Shows play state, volume, mute, track info, and playback position
- Displays device role in multiroom groups
- Tracks statistics (poll count, state changes, UPnP events)
Usage:
# Basic monitoring
wiim-monitor 192.168.1.100
# Specify callback host for UPnP (if auto-detection fails)
wiim-monitor 192.168.1.100 --callback-host 192.168.1.254
# Verbose logging
wiim-monitor 192.168.1.100 --verbose
# Custom log level
wiim-monitor 192.168.1.100 --log-level DEBUG
# Verbose UPnP event logging (shows full event JSON/XML)
wiim-monitor 192.168.1.100 --upnp-verbose
Options:
<device_ip>- Device IP address or hostname (required)--callback-host <ip>- Override UPnP callback host (auto-detected by default)--verbose, -v- Enable verbose logging--log-level <level>- Set log level (DEBUG, INFO, WARNING, ERROR)--upnp-verbose- Enable verbose UPnP event logging (shows full event JSON/XML data)
What it displays:
- Play state (playing, paused, stopped)
- Volume level and mute status
- Current track (title, artist, album)
- Playback position and duration
- Device role (solo/master/slave)
- Group information (if in a group)
- Update source (polling or UPnP event)
- Statistics on exit
Example Output:
🎵 Monitoring WiiM Mini (192.168.1.100)...
UPnP: Enabled ✓ (events: 0)
Polling: Adaptive (interval: 2.0s)
📊 Status:
State: playing
Volume: 50% (muted: No)
Source: wifi
Role: solo
🎶 Track:
Title: Song Title
Artist: Artist Name
Album: Album Name
Position: 1:23 / 3:45
[UPnP] State changed: volume → 55%
Press Ctrl+C to stop monitoring and view statistics.
4. Feature Verification (wiim-verify)
Comprehensive testing tool that verifies all device features and endpoints with safety constraints.
What it does:
- Tests all playback
