From 825f7c4c523eef932028272952f3ac38cdab8822 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 14 Jun 2024 00:28:00 +0200 Subject: [PATCH] some tweaks to the hass provider --- music_assistant/common/models/config_entries.py | 4 ++++ .../server/providers/hass_players/__init__.py | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/music_assistant/common/models/config_entries.py b/music_assistant/common/models/config_entries.py index a51d1e9a..80100bf4 100644 --- a/music_assistant/common/models/config_entries.py +++ b/music_assistant/common/models/config_entries.py @@ -342,6 +342,10 @@ CONF_ENTRY_FLOW_MODE = ConfigEntry( default_value=False, ) +CONF_ENTRY_FLOW_MODE_DEFAULT_ENABLED = ConfigEntry.from_dict( + {**CONF_ENTRY_FLOW_MODE.to_dict(), "default_value": True} +) + CONF_ENTRY_FLOW_MODE_ENFORCED = ConfigEntry( key=CONF_FLOW_MODE, type=ConfigEntryType.BOOLEAN, diff --git a/music_assistant/server/providers/hass_players/__init__.py b/music_assistant/server/providers/hass_players/__init__.py index 40fd0f4b..e3a66ffb 100644 --- a/music_assistant/server/providers/hass_players/__init__.py +++ b/music_assistant/server/providers/hass_players/__init__.py @@ -16,6 +16,7 @@ from music_assistant.common.models.config_entries import ( CONF_ENTRY_CROSSFADE_DURATION, CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, CONF_ENTRY_ENFORCE_MP3, + CONF_ENTRY_FLOW_MODE_DEFAULT_ENABLED, ConfigEntry, ConfigValueOption, ConfigValueType, @@ -34,10 +35,9 @@ from music_assistant.server.providers.hass import DOMAIN as HASS_DOMAIN if TYPE_CHECKING: from collections.abc import AsyncGenerator - from hass_client.models import CompressedState + from hass_client.models import CompressedState, EntityStateEvent from hass_client.models import Device as HassDevice from hass_client.models import Entity as HassEntity - from hass_client.models import EntityStateEvent from hass_client.models import State as HassState from music_assistant.common.models.config_entries import ProviderConfig @@ -96,7 +96,7 @@ CONF_ENTRY_ENFORCE_MP3_DEFAULT_ENABLED = ConfigEntry.from_dict( PLAYER_CONFIG_ENTRIES = ( CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED, CONF_ENTRY_CROSSFADE_DURATION, - CONF_ENTRY_ENFORCE_MP3, + CONF_ENTRY_ENFORCE_MP3_DEFAULT_ENABLED, ) @@ -195,8 +195,12 @@ class HomeAssistantPlayers(PlayerProvider): player_id: str, ) -> tuple[ConfigEntry, ...]: """Return all (provider/player specific) Config Entries for the given player (if any).""" - base_entries = await super().get_player_config_entries(player_id) - return base_entries + PLAYER_CONFIG_ENTRIES + entries = await super().get_player_config_entries(player_id) + entries = entries + PLAYER_CONFIG_ENTRIES + if player := self.mass.players.get(player_id): + if PlayerFeature.ENQUEUE_NEXT not in player.supported_features: + entries += (CONF_ENTRY_FLOW_MODE_DEFAULT_ENABLED,) + return entries async def cmd_stop(self, player_id: str) -> None: """Send STOP command to given player. -- 2.34.1