From b68bc0e0f7ace1bfd8d0f33b2ed5ca52cd19422a Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 8 Mar 2025 01:31:38 +0100 Subject: [PATCH] Fix: always use fallback default supported samplerate for esphome player --- music_assistant/constants.py | 10 +++++----- music_assistant/providers/hass_players/__init__.py | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/music_assistant/constants.py b/music_assistant/constants.py index 53f5b571..459c1e8c 100644 --- a/music_assistant/constants.py +++ b/music_assistant/constants.py @@ -569,6 +569,11 @@ def create_sample_rates_config_entry( ) -> ConfigEntry: """Create sample rates config entry based on player specific helpers.""" assert CONF_ENTRY_SAMPLE_RATES.options + # if no supported sample rates are defined, we apply the default 44100 as only option + if not supported_sample_rates and max_sample_rate is None: + supported_sample_rates = [44100] + if not supported_bit_depths and max_bit_depth is None: + supported_bit_depths = [16] final_supported_sample_rates = supported_sample_rates or [] final_supported_bit_depths = supported_bit_depths or [] conf_entry = ConfigEntry.from_dict(CONF_ENTRY_SAMPLE_RATES.to_dict()) @@ -576,11 +581,6 @@ def create_sample_rates_config_entry( options: list[ConfigValueOption] = [] default_value: list[str] = [] - if not supported_sample_rates and max_sample_rate is None: - supported_sample_rates = [44100] - if not supported_bit_depths and max_bit_depth is None: - supported_bit_depths = [16] - for option in CONF_ENTRY_SAMPLE_RATES.options: option_value = cast(str, option.value) sample_rate_str, bit_depth_str = option_value.split(MULTI_VALUE_SPLITTER, 1) diff --git a/music_assistant/providers/hass_players/__init__.py b/music_assistant/providers/hass_players/__init__.py index 42bccb2d..b408ed1e 100644 --- a/music_assistant/providers/hass_players/__init__.py +++ b/music_assistant/providers/hass_players/__init__.py @@ -216,7 +216,11 @@ class HomeAssistantPlayers(PlayerProvider): bit_depth = supported_format["sample_bytes"] * 8 if bit_depth not in supported_bit_depths: supported_bit_depths.append(bit_depth) - + if not supported_sample_rates: + # esphome device with no media pipeline configured + # simply use the default config of the media pipeline + supported_sample_rates = [48000] + supported_bit_depths = [16] return ( *base_entries, # New ESPHome mediaplayer (used in Voice PE) uses FLAC 48khz/16 bits -- 2.34.1