music-assistant-server

3.3 KBPY
__init__.py
3.3 KB102 lines • python
1"""FullyKiosk 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, ConfigValueType
8from music_assistant_models.enums import ConfigEntryType, ProviderFeature
9
10from music_assistant.constants import (
11    CONF_IP_ADDRESS,
12    CONF_PASSWORD,
13    CONF_PORT,
14    CONF_SSL_FINGERPRINT,
15    CONF_USE_SSL,
16    CONF_VERIFY_SSL,
17)
18
19from .provider import FullyKioskProvider
20
21if TYPE_CHECKING:
22    from music_assistant_models.config_entries import ProviderConfig
23    from music_assistant_models.provider import ProviderManifest
24
25    from music_assistant.mass import MusicAssistant
26    from music_assistant.models import ProviderInstanceType
27
28SUPPORTED_FEATURES: set[ProviderFeature] = (
29    set()
30)  # we don't have any special supported features (yet)
31
32
33async def setup(
34    mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
35) -> ProviderInstanceType:
36    """Initialize provider(instance) with given configuration."""
37    return FullyKioskProvider(mass, manifest, config, SUPPORTED_FEATURES)
38
39
40async def get_config_entries(
41    mass: MusicAssistant,
42    instance_id: str | None = None,
43    action: str | None = None,
44    values: dict[str, ConfigValueType] | None = None,
45) -> tuple[ConfigEntry, ...]:
46    """
47    Return Config entries to setup this provider.
48
49    instance_id: id of an existing provider instance (None if new instance setup).
50    action: [optional] action key called from config entries UI.
51    values: the (intermediate) raw values for config entries sent with the action.
52    """
53    # ruff: noqa: ARG001
54    return (
55        ConfigEntry(
56            key=CONF_IP_ADDRESS,
57            type=ConfigEntryType.STRING,
58            label="IP-Address (or hostname) of the device running Fully Kiosk/app.",
59            required=True,
60        ),
61        ConfigEntry(
62            key=CONF_PASSWORD,
63            type=ConfigEntryType.SECURE_STRING,
64            label="Password to use to connect to the Fully Kiosk API.",
65            required=True,
66        ),
67        ConfigEntry(
68            key=CONF_PORT,
69            type=ConfigEntryType.STRING,
70            default_value="2323",
71            label="Port to use to connect to the Fully Kiosk API (default is 2323).",
72            required=True,
73            advanced=True,
74        ),
75        ConfigEntry(
76            key=CONF_USE_SSL,
77            type=ConfigEntryType.BOOLEAN,
78            label="Use HTTPS when connecting to the Fully Kiosk API.",
79            default_value=False,
80            advanced=True,
81        ),
82        ConfigEntry(
83            key=CONF_VERIFY_SSL,
84            type=ConfigEntryType.BOOLEAN,
85            label="Verify HTTPS certificates (recommended).",
86            default_value=True,
87            description="Disabling verification trusts any certificate (no validation).",
88            advanced=True,
89        ),
90        ConfigEntry(
91            key=CONF_SSL_FINGERPRINT,
92            type=ConfigEntryType.STRING,
93            label="TLS certificate fingerprint",
94            description=(
95                "Optional SHA-256 hex fingerprint. When provided it must "
96                "match the device certificate and overrides the verify setting."
97            ),
98            required=False,
99            advanced=True,
100        ),
101    )
102