music-assistant-server

1.9 KBPY
__init__.py
1.9 KB59 lines • python
1"""HEOS Player Provider for HEOS system to work with 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, ProviderFeature
9
10from music_assistant.constants import CONF_IP_ADDRESS
11
12from .provider import HeosPlayerProvider
13
14if TYPE_CHECKING:
15    from music_assistant_models.config_entries import ConfigValueType, ProviderConfig
16    from music_assistant_models.provider import ProviderManifest
17
18    from music_assistant.mass import MusicAssistant
19    from music_assistant.models import ProviderInstanceType
20
21SUPPORTED_FEATURES = {
22    ProviderFeature.SYNC_PLAYERS,
23}
24
25
26async def setup(
27    mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
28) -> ProviderInstanceType:
29    """Initialize HEOS instance with given configuration."""
30    return HeosPlayerProvider(mass, manifest, config, SUPPORTED_FEATURES)
31
32
33async def get_config_entries(
34    mass: MusicAssistant,
35    instance_id: str | None = None,
36    action: str | None = None,
37    values: dict[str, ConfigValueType] | None = None,
38) -> tuple[ConfigEntry, ...]:
39    """
40    Return Config entries to setup this provider.
41
42    instance_id: id of an existing provider instance (None if new instance setup).
43    action: [optional] action key called from config entries UI.
44    values: the (intermediate) raw values for config entries sent with the action.
45    """
46    # ruff: noqa: ARG001
47    return (
48        ConfigEntry(
49            key=CONF_IP_ADDRESS,
50            type=ConfigEntryType.STRING,
51            label="Main controller hostname or IP address.",
52            required=False,
53            description="Hostname or IP address of the HEOS device "
54            "to be used as the main controller. It is recommended to use a "
55            "wired device as the main controller.",
56            category="advanced",
57        ),
58    )
59