/
/
/
1"""DLNA/uPNP Player provider for Music Assistant.
2
3Most of this code is based on the implementation within Home Assistant:
4https://github.com/home-assistant/core/blob/dev/homeassistant/components/dlna_dmr
5
6All rights/credits reserved.
7"""
8
9from __future__ import annotations
10
11from typing import TYPE_CHECKING
12
13from music_assistant_models.config_entries import ConfigEntry, ConfigValueType
14from music_assistant_models.enums import ConfigEntryType, ProviderFeature
15
16from .constants import CONF_NETWORK_SCAN
17from .provider import DLNAPlayerProvider
18
19if TYPE_CHECKING:
20 from music_assistant_models.config_entries import ProviderConfig
21 from music_assistant_models.provider import ProviderManifest
22
23 from music_assistant import MusicAssistant
24 from music_assistant.models import ProviderInstanceType
25
26SUPPORTED_FEATURES: set[ProviderFeature] = (
27 set()
28) # we don't have any special supported features (yet)
29
30
31async def setup(
32 mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
33) -> ProviderInstanceType:
34 """Initialize provider(instance) with given configuration."""
35 return DLNAPlayerProvider(mass, manifest, config, SUPPORTED_FEATURES)
36
37
38async def get_config_entries(
39 mass: MusicAssistant,
40 instance_id: str | None = None,
41 action: str | None = None,
42 values: dict[str, ConfigValueType] | None = None,
43) -> tuple[ConfigEntry, ...]:
44 """
45 Return Config entries to setup this provider.
46
47 instance_id: id of an existing provider instance (None if new instance setup).
48 action: [optional] action key called from config entries UI.
49 values: the (intermediate) raw values for config entries sent with the action.
50 """
51 # ruff: noqa: ARG001
52 return (
53 ConfigEntry(
54 key=CONF_NETWORK_SCAN,
55 type=ConfigEntryType.BOOLEAN,
56 label="Allow network scan for discovery",
57 default_value=False,
58 description="Enable network scan for discovery of players. \n"
59 "Can be used if (some of) your players are not automatically discovered.",
60 ),
61 )
62