music-assistant-server

2.3 KBPY
__init__.py
2.3 KB66 lines • python
1"""Media Assistant Player Provider for Music Assistant."""
2
3from __future__ import annotations
4
5from typing import TYPE_CHECKING
6
7from music_assistant_models.config_entries import ConfigEntry
8from music_assistant_models.enums import ConfigEntryType
9
10from music_assistant.constants import CONF_ENTRY_MANUAL_DISCOVERY_IPS
11
12from .constants import CONF_AUTO_DISCOVER, CONF_ROKU_APP_ID
13from .provider import MediaAssistantprovider
14
15if TYPE_CHECKING:
16    from music_assistant_models.config_entries import ConfigValueType, ProviderConfig
17    from music_assistant_models.provider import ProviderManifest
18
19    from music_assistant.mass import MusicAssistant
20    from music_assistant.models import ProviderInstanceType
21
22
23async def setup(
24    mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
25) -> ProviderInstanceType:
26    """Initialize provider(instance) with given configuration."""
27    return MediaAssistantprovider(mass, manifest, config)
28
29
30async def get_config_entries(
31    mass: MusicAssistant,
32    instance_id: str | None = None,
33    action: str | None = None,
34    values: dict[str, ConfigValueType] | None = None,
35) -> tuple[ConfigEntry, ...]:
36    """
37    Return Config entries to setup this provider.
38
39    instance_id: id of an existing provider instance (None if new instance setup).
40    action: [optional] action key called from config entries UI.
41    values: the (intermediate) raw values for config entries sent with the action.
42    """
43    # ruff: noqa: ARG001
44    return (
45        CONF_ENTRY_MANUAL_DISCOVERY_IPS,
46        ConfigEntry(
47            key=CONF_ROKU_APP_ID,
48            type=ConfigEntryType.STRING,
49            label="App ID of Media Assistant",
50            default_value="782875",
51            description="By default, Music Assistant will use the Roku Channel Store version "
52            "of Media Assistant (ID: 782875). If you sideloaded the App on your Roku "
53            "this will need to be set to (ID: dev).",
54            required=False,
55            advanced=True,
56        ),
57        ConfigEntry(
58            key=CONF_AUTO_DISCOVER,
59            type=ConfigEntryType.BOOLEAN,
60            label="Allow automatic Roku discovery",
61            default_value=True,
62            description="Enable automatic discovery of Roku players.",
63            advanced=True,
64        ),
65    )
66