/
/
1"""Constants for the WiiM Provider."""
2
3from music_assistant_models.player import PlayerSource
4
5# Player ID prefix to avoid colliding with DLNA (which uses the raw UDN)
6PLAYER_ID_PREFIX = "wiim_"
7
8# Passive sources detected via current track URI
9SOURCE_AIRPLAY = "airplay"
10SOURCE_SPOTIFY = "spotify"
11SOURCE_UNKNOWN = "unknown"
12SOURCE_NETWORK = "Network"
13
14PASSIVE_SOURCES: dict[str, PlayerSource] = {
15 SOURCE_AIRPLAY: PlayerSource(
16 id=SOURCE_AIRPLAY,
17 name="AirPlay",
18 passive=True,
19 can_play_pause=True,
20 can_next_previous=True,
21 can_seek=True,
22 ),
23 SOURCE_SPOTIFY: PlayerSource(
24 id=SOURCE_SPOTIFY,
25 name="Spotify",
26 passive=True,
27 can_play_pause=True,
28 can_next_previous=True,
29 can_seek=True,
30 ),
31 SOURCE_UNKNOWN: PlayerSource(
32 id=SOURCE_UNKNOWN,
33 name="Unknown",
34 passive=True,
35 can_play_pause=True,
36 can_next_previous=True,
37 can_seek=True,
38 ),
39}
40
41# Input modes from device.supported_input_modes (non-passive, user-selectable)
42# Keys match the display names returned by the SDK
43INPUT_MODE_SOURCES: dict[str, PlayerSource] = {
44 SOURCE_NETWORK: PlayerSource(
45 id="network",
46 name=SOURCE_NETWORK,
47 passive=False,
48 can_play_pause=True,
49 can_next_previous=True,
50 can_seek=True,
51 ),
52 "Bluetooth": PlayerSource(
53 id="bluetooth",
54 name="Bluetooth",
55 passive=False,
56 can_play_pause=True,
57 can_next_previous=False,
58 can_seek=False,
59 ),
60 "Line In": PlayerSource(
61 id="line_in",
62 name="Line In",
63 passive=False,
64 can_play_pause=False,
65 can_next_previous=False,
66 can_seek=False,
67 ),
68 "Optical In": PlayerSource(
69 id="optical",
70 name="Optical In",
71 passive=False,
72 can_play_pause=False,
73 can_next_previous=False,
74 can_seek=False,
75 ),
76 "TV": PlayerSource(
77 id="hdmi",
78 name="TV",
79 passive=False,
80 can_play_pause=False,
81 can_next_previous=False,
82 can_seek=False,
83 ),
84 "Phono In": PlayerSource(
85 id="phono_in",
86 name="Phono In",
87 passive=False,
88 can_play_pause=False,
89 can_next_previous=False,
90 can_seek=False,
91 ),
92}
93
94# Reverse lookup: source ID -> SDK display name for select_source commands
95SOURCE_ID_TO_INPUT_MODE: dict[str, str] = {v.id: k for k, v in INPUT_MODE_SOURCES.items()}
96