Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b9c7539
feat(yandex_smarthome): add yandex_smarthome provider v1.4.0
github-actions[bot] Apr 24, 2026
c1be547
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] Apr 24, 2026
f108d57
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] Apr 24, 2026
51d0920
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] Apr 24, 2026
996bb1c
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] Apr 24, 2026
0d16cd0
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] Apr 24, 2026
6b9fa26
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
1941751
feat(yandex_smarthome): add yandex_smarthome provider v1.5.0
github-actions[bot] May 4, 2026
1dc381d
Merge branch 'dev' into upstream/yandex_smarthome
trudenboy May 4, 2026
0326e29
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
0914446
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
c6a6f77
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
a3d2e0f
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
01c3172
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
18c922f
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 4, 2026
72d55cf
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
dfaab6b
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
5628fe8
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
687b293
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
e47472a
Merge branch 'dev' into upstream/yandex_smarthome
trudenboy May 5, 2026
a830e7b
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
fc02259
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
dce8385
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
55135c9
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
d0555a8
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
c507840
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
442f7d3
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
086c0a8
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
468964f
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
00574c9
Potential fix for pull request finding
trudenboy May 5, 2026
e08ca79
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
fd8b62f
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
bcfcb11
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
4e017c8
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
a098b55
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
304eebd
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
03ebec1
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
461c029
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
6ca5b01
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
734e60c
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
26591c8
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
8f64f54
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 5, 2026
cf24e7f
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 6, 2026
1ad84a8
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 6, 2026
65266bd
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 6, 2026
2fddc2d
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 6, 2026
999dca5
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 6, 2026
e37cd36
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 6, 2026
85c66cc
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 7, 2026
0c19262
Merge branch 'dev' into upstream/yandex_smarthome
trudenboy May 7, 2026
af42754
Merge branch 'dev' into upstream/yandex_smarthome
trudenboy May 7, 2026
5937e76
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 7, 2026
214a246
Merge branch 'dev' into upstream/yandex_smarthome
trudenboy May 7, 2026
82db110
feat(yandex_smarthome): sync provider from ma-provider-yandex-smartho…
github-actions[bot] May 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
750 changes: 579 additions & 171 deletions music_assistant/providers/yandex_smarthome/__init__.py

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions music_assistant/providers/yandex_smarthome/_compat.py

This file was deleted.

135 changes: 135 additions & 0 deletions music_assistant/providers/yandex_smarthome/_smarthome_auto_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
"""Smart-home auto-create-skill helpers — URL derivation + preconditions.

Equivalent of the deleted ``derive_backend_uri`` / ``derive_auth_urls`` /
``derive_client_id`` / ``_resolve_base_url`` / ``check_preconditions``
that lived inside the old ``provider/auto_skill.py``. Narrower scope:
smart-home only — drops the ``skill_type="dialog"`` branch (that's alice's
concern, lives in trudenboy/ma-provider-yandex-alice).

These derivations live in the provider, not in the lib, because
``connection_type`` and the cloud-relay/direct-mode protocols are
Music-Assistant-specific concepts. ``ya-dialogs-api`` accepts the
already-computed URLs as plain string parameters.
"""

from __future__ import annotations

import contextlib
from dataclasses import dataclass
from typing import TYPE_CHECKING

from .constants import (
CLOUD_OAUTH_AUTHORIZE_URL,
CLOUD_OAUTH_TOKEN_URL,
CLOUD_SKILL_CLIENT_ID_TEMPLATE,
CLOUD_SKILL_CLIENT_SECRET,
CLOUD_SKILL_WEBHOOK_TEMPLATE,
CONNECTION_TYPE_CLOUD_PLUS,
CONNECTION_TYPE_DIRECT,
DIRECT_AUTH_BASE_PATH,
DIRECT_BACKEND_URI_PATH,
DIRECT_OAUTH_CLIENT_ID,
)

if TYPE_CHECKING:
from music_assistant.mass import MusicAssistant


@dataclass(frozen=True, slots=True)
class SmartHomeUrls:
"""The five pre-computed values ya_dialogs_api.auto_create_skill needs.

Pass these straight into ``auto_create_skill`` — they correspond to its
``backend_uri`` / ``oauth_authorize_url`` / ``oauth_token_url`` /
``oauth_client_id`` / ``oauth_client_secret`` keyword arguments.
"""

backend_uri: str
oauth_authorize_url: str
oauth_token_url: str
oauth_client_id: str
oauth_client_secret: str


def resolve_base_url(mass: MusicAssistant, override: str | None) -> str:
"""Pick override over ``mass.webserver.base_url``; strip trailing slashes.

``override`` is the user-set ``CONF_EXTERNAL_BASE_URL``. Lets users keep
MA's global Base URL pointing at the local address (so HA Ingress / local
UI keep working) while exposing a public HTTPS URL only to Yandex via a
reverse proxy.
"""
if override and override.strip():
return override.strip().rstrip("/")
fallback = ""
with contextlib.suppress(Exception):
fallback = str(mass.webserver.base_url)
return fallback.strip().rstrip("/")


def derive_smart_home_urls(
*,
connection_type: str,
base_url: str,
cloud_instance_id: str,
direct_client_secret: str,
) -> SmartHomeUrls:
"""Compute the five pre-computed values for ``auto_create_skill``.

cloud_plus
Backend uses :data:`CLOUD_SKILL_WEBHOOK_TEMPLATE` (the yaha-cloud
relay). OAuth uses yaha-cloud's own authorize/token endpoints.
``client_id`` is ``yandex_smart_home:{instance_id}``;
``client_secret`` is the literal ``"secret"`` required by the
relay protocol.

direct
Backend = ``base_url + DIRECT_BACKEND_URI_PATH``. OAuth uses MA's
own ``/api/yandex_smarthome/auth/{authorize,token}`` endpoints
served by ``provider/direct.py``. ``client_id`` is the social
redirect base (Yandex's existing OAuth client expects this exact
value); ``client_secret`` is the per-install random UUID minted on
first save.

Raises:
ValueError: ``cloud_plus`` without a registered cloud instance
id; ``direct`` without a client secret or with a non-HTTPS
base URL; any other ``connection_type``.
"""
if connection_type == CONNECTION_TYPE_CLOUD_PLUS:
if not cloud_instance_id:
msg = (
"Cloud Plus requires a registered yaha-cloud instance first. "
"Use the 'Register with cloud' action."
)
raise ValueError(msg)
return SmartHomeUrls(
backend_uri=CLOUD_SKILL_WEBHOOK_TEMPLATE,
oauth_authorize_url=CLOUD_OAUTH_AUTHORIZE_URL,
oauth_token_url=CLOUD_OAUTH_TOKEN_URL,
oauth_client_id=CLOUD_SKILL_CLIENT_ID_TEMPLATE.format(instance_id=cloud_instance_id),
oauth_client_secret=CLOUD_SKILL_CLIENT_SECRET,
)
if connection_type == CONNECTION_TYPE_DIRECT:
if not direct_client_secret:
msg = "Direct mode requires a generated Client Secret"
raise ValueError(msg)
if not base_url.startswith("https://"):
msg = (
"Direct mode requires MA to be reachable over HTTPS from "
f"the public internet (got base_url={base_url!r}). Yandex "
"rejects skills with non-HTTPS backends."
)
raise ValueError(msg)
return SmartHomeUrls(
backend_uri=f"{base_url}{DIRECT_BACKEND_URI_PATH}",
oauth_authorize_url=f"{base_url}{DIRECT_AUTH_BASE_PATH}/authorize",
oauth_token_url=f"{base_url}{DIRECT_AUTH_BASE_PATH}/token",
oauth_client_id=DIRECT_OAUTH_CLIENT_ID,
oauth_client_secret=direct_client_secret,
)
msg = (
f"auto-create is not supported for connection_type={connection_type!r}; "
"use cloud_plus or direct."
)
raise ValueError(msg)
Loading
Loading