Add Yandex Station player provider
Yandex Station Player Provider
Source: trudenboy/ma-provider-yandex-station — synced from v1.4.12. Adapted from AlexxIT/YandexStation (MIT license).
Play music on Yandex Station smart speakers via the local Glagol WebSocket protocol, with an optional reverse-direction "intercept" mode that redirects native Station playback to another MA player.
Related PRs
- Documentation PR: music-assistant/music-assistant.io#625
Dependencies
ya-passport-auth==1.3.0— Yandex Passport authentication (Device Flow, QR login, cookie login, token refresh, device tokens)
Features
Core
- Local playback via Glagol WebSocket
externalCommandBypass/radio_play - Auto-discovery via mDNS (
_yandexio._tcp.local.) - Cloud discovery fallback via Quasar IoT API + Glagol device_list API
- Real-time state updates from Glagol WebSocket
Authentication (via ya-passport-auth)
- Device Flow — short user code on an MA-hosted page, polls Passport until confirmation (yields x_token + music_token + refresh_token for silent auto-refresh)
- QR code — scan with the Yandex app (yields x_token + music_token)
- Cookies fallback — advanced option, accepts JSON array or raw cookie string
- Silent credential refresh cascade: music_token → x_token → refresh_token
- Optional "Remember session" toggle — disabling immediately drops long-lived tokens
Transport Controls
- Play / Pause / Stop / Resume
- Next / Previous track
- Seek (rewind)
- Volume set / mute
- Power on/off via Yandex scenarios
Playback
- FLAC lossless streaming with Content-Length header
- Track info display (title, artist, cover, duration)
- Automatic track transitions on queue advancement
- Pause via
radio_playwith unreachable URL (fully local, no cloud) - Resume via MA queue replay
- Detect physical pause during external playback
Announcements
- Audio announcement via stream URL — blocks until playback ends
- Volume save/restore around announcements
- 30s safety timeout
Voice Control (Experimental, off by default)
- Detect Alice activation during bypass playback
- Auto-resume after informational queries (weather, etc.)
- Auto-resume after volume adjustments
- Stay paused on control commands (стоп, пауза)
- Accept native playback when Alice starts her own music
Intercept Mode (Experimental, off by default — new in v1.4.0)
Redirects native Station playback to a configured target MA player. When the Station starts native Yandex Music playback (typically via an Alice voice command, but also via a touch on the Station UI), the provider:
- Resolves the track via the
yandex_musicMA music provider. - Stops the Station's native player.
- Starts the same track on the chosen target.
Volume / seek / pause / Alice-speech mirror from the Station to the target while intercept is active.
Gated by two switches (both default OFF):
- Provider-level master toggle (
intercept_feature_enabled). - Per-player toggle (
intercept_enabled) + target dropdown filtered by required features (PLAY_MEDIA,PAUSE,VOLUME_SET,SEEK).
Hardened across four review rounds (PR #45 in source repo) for: serialised dispatch under _intercept_lock, debounced failure paths, target availability pre-validation, self-stop window, seek baseline anchored at play-start, idempotent Alice-pause, and decoupled session/debounce cleanup.
Architecture
MA Core ──play_media()──▶ YandexStationPlayer ──radio_play──▶ Glagol WS ──▶ Yandex Station
◀── state updates
◀──intercept handoff── (resolve via yandex_music) ──◀── Alice plays X
| Module | Purpose |
|---|---|
__init__.py |
setup(), get_config_entries() — Device Flow / QR / cookies auth actions, remember-session toggle, intercept master switch |
provider.py |
mDNS discovery, Quasar API fallback, player lifecycle, silent re-auth cascade |
player.py |
Transport controls, state updates, play_media() via radio_play, announcements, voice-control, intercept dispatch and mirroring |
glagol.py |
Persistent WebSocket client, auto-reconnect, command send/receive |
quasar.py |
Cloud API for device list and config |
session.py |
HTTP client with cookie persistence, delegates auth to injected PassportClient |
auth.py |
Device Flow / QR / cookies login + refresh_music_token / refresh_credentials_via_passport / validate_x_token |
protobuf.py |
Minimal protobuf encoder/decoder for externalCommandBypass |
constants.py |
API URLs, config keys, protocol constants |
Changed files
| File | Status | Lines |
|---|---|---|
music_assistant/providers/yandex_station/__init__.py |
added | +249 |
music_assistant/providers/yandex_station/auth.py |
added | +437 |
music_assistant/providers/yandex_station/constants.py |
added | +43 |
music_assistant/providers/yandex_station/glagol.py |
added | +315 |
music_assistant/providers/yandex_station/icon.svg |
added | +9 |
music_assistant/providers/yandex_station/manifest.json |
added | +16 |
music_assistant/providers/yandex_station/player.py |
added | +925 |
music_assistant/providers/yandex_station/protobuf.py |
added | +109 |
music_assistant/providers/yandex_station/provider.py |
added | +568 |
music_assistant/providers/yandex_station/quasar.py |
added | +101 |
music_assistant/providers/yandex_station/session.py |
added | +215 |
tests/providers/yandex_station/__init__.py |
added | +1 |
tests/providers/yandex_station/test_auth.py |
added | +761 |
tests/providers/yandex_station/test_intercept.py |
added | +788 |
tests/providers/yandex_station/test_player_state.py |
added | +146 |
tests/providers/yandex_station/test_protobuf.py |
added | +23 |
tests/providers/yandex_station/test_provider_cascade.py |
added | +580 |
Total: 17 files, +5286 / -0 lines.
Tests (101 total)
- test_auth.py (40) — Device Flow, QR, cookie login, token refresh, x_token validation, safe-session-id guard
- test_provider_cascade.py (17) — silent auth cascade (music → x_token → refresh_token), session reuse, transient-failure handling, 401 retry
- test_player_state.py (5) — physical pause detection, external-playback startup window, voice-interaction guard
- test_protobuf.py (2) — protobuf encode/decode roundtrip
- test_intercept.py (37) — intercept feature: track_id parser, both kill switches, missing yandex_music, missing/unavailable target, anti-loop, debounce (success and failure paths), volume/seek/pause mirroring, Alice handling (idempotency, debounce clearing, blocks new handoff in same tick), self-stop window, concurrent ticks serialised, cmd_pause-raise cleanup, dropdown feature filter, real-entrypoint integration through
_on_glagol_update
🔒 Dependency Security Report
📦 Modified Dependencies
music_assistant/providers/yandex_station/manifest.json
Added:
- ✅ ya-passport-auth ==1.4.1
🔍 Vulnerability Scan Results
No known vulnerabilities found
| Name | Skip Reason |
|---|---|
| torch | Dependency not found on PyPI and could not be audited: torch (2.11.0+cpu) |
| torchaudio | Dependency not found on PyPI and could not be audited: torchaudio (2.11.0+cpu) |
| ✅ No known vulnerabilities found |
Automated Security Checks
- ✅ Vulnerability Scan: Passed - No known vulnerabilities
- ✅ Trusted Sources: All packages have verified source repositories
- ✅ Typosquatting Check: No suspicious package names detected
- ✅ License Compatibility: All licenses are OSI-approved and compatible
- ✅ Supply Chain Risk: Passed - packages appear mature and maintained
Manual Review
Maintainer approval required:
- [ ] I have reviewed the changes above and approve these dependency updates
To approve: Comment /approve-dependencies or manually add the dependencies-reviewed label.
The refactoring discussed in #3606 is already done — the comment may predate it.
Core Passport logic (Device Flow / QR / cookie login, token exchange, polling, refresh) lives in a separate pip package — ya-passport-auth (~=1.3.0), pinned in requirements_all.txt. Both yandex_station (this PR) and yandex_music (#3606) depend on the same PassportClient and authenticate uniformly through it.
What's left in each provider's auth.py is a thin MA-integration shim: AuthenticationHelper wiring and the aiohttp device-code page — it can't live in ya-passport-auth because it depends on music_assistant.
Please look at the failing tests