/
/
/
1"""Readers for the Hue Lights Sync playback settings."""
2
3from __future__ import annotations
4
5from typing import TYPE_CHECKING
6
7from .constants import (
8 CONF_BRIGHTNESS,
9 CONF_COLOR_MODE,
10 CONF_HUE_LATENCY_MS,
11 DEFAULT_BRIGHTNESS,
12 DEFAULT_COLOR_MODE,
13 DEFAULT_HUE_LATENCY_MS,
14)
15
16if TYPE_CHECKING:
17 from music_assistant_models.config_entries import ProviderConfig
18
19
20def get_color_mode(config: ProviderConfig) -> str:
21 """
22 Return the configured visualization mode.
23
24 :param config: Provider config to read the setting from.
25 """
26 value = config.get_value(CONF_COLOR_MODE)
27 return DEFAULT_COLOR_MODE if value is None else str(value)
28
29
30def get_brightness(config: ProviderConfig) -> int:
31 """
32 Return the configured brightness percentage.
33
34 :param config: Provider config to read the setting from.
35 """
36 value = config.get_value(CONF_BRIGHTNESS)
37 # stored numbers can come back as float or str, so normalize before truncating
38 return DEFAULT_BRIGHTNESS if value is None else int(float(str(value)))
39
40
41def get_hue_latency_ms(config: ProviderConfig) -> int:
42 """
43 Return the configured latency compensation in milliseconds.
44
45 :param config: Provider config to read the setting from.
46 """
47 value = config.get_value(CONF_HUE_LATENCY_MS)
48 return DEFAULT_HUE_LATENCY_MS if value is None else int(float(str(value)))
49