From 897b92c5fdfdc402037d5d72087e02ac68a745d4 Mon Sep 17 00:00:00 2001 From: Todd Lucas Date: Sat, 28 Dec 2024 11:10:17 -0600 Subject: [PATCH] [ 1.0.76 ] * Updated logic to correctly account for idle state; the integration will go into idle state (instead of staying in paused state) after it detects that the Spotify Web API has dropped the current play state (e.g. the device disconnects from Spotify Connect). * Added extra state attribute: `sp_source_list_hide` - List of device names (in lower-case) to hide from the source list. * Updated underlying `spotifywebapiPython` package requirement to version 1.0.130. --- CHANGELOG.md | 6 ++++++ custom_components/spotifyplus/instancedata_spotifyplus.py | 2 +- custom_components/spotifyplus/manifest.json | 4 ++-- custom_components/spotifyplus/media_player.py | 7 ++++++- requirements.txt | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ca7cb2..9948b47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ Change are listed in reverse chronological order (newest to oldest). +###### [ 1.0.76 ] - 2024/12/28 + + * Updated logic to correctly account for idle state; the integration will go into idle state (instead of staying in paused state) after it detects that the Spotify Web API has dropped the current play state (e.g. the device disconnects from Spotify Connect). + * Added extra state attribute: `sp_source_list_hide` - List of device names (in lower-case) to hide from the source list. + * Updated underlying `spotifywebapiPython` package requirement to version 1.0.130. + ###### [ 1.0.75 ] - 2024/12/21 * Added service `get_cover_image_file` to get the contents of an image url and transfer the contents to the local file system. This service should only be used to download images for playlists that contain public domain images. It should not be used to download copyright protected images, as that would violate the Spotify Web API Terms of Service. diff --git a/custom_components/spotifyplus/instancedata_spotifyplus.py b/custom_components/spotifyplus/instancedata_spotifyplus.py index 98564bb..c2fc14d 100644 --- a/custom_components/spotifyplus/instancedata_spotifyplus.py +++ b/custom_components/spotifyplus/instancedata_spotifyplus.py @@ -113,7 +113,7 @@ def OptionScriptTurnOn(self) -> str | None: @property def OptionSourceListHide(self) -> list: """ - The list of devices to hide from the source list. + The list of device names (in lower-case) to hide from the source list. """ result:list = [] diff --git a/custom_components/spotifyplus/manifest.json b/custom_components/spotifyplus/manifest.json index a92c1c7..4686096 100644 --- a/custom_components/spotifyplus/manifest.json +++ b/custom_components/spotifyplus/manifest.json @@ -18,10 +18,10 @@ "requests_oauthlib>=1.3.1", "soco>=0.30.4", "smartinspectPython>=3.0.33", - "spotifywebapiPython>=1.0.129", + "spotifywebapiPython>=1.0.130", "urllib3>=1.21.1,<1.27", "zeroconf>=0.132.2" ], - "version": "1.0.75", + "version": "1.0.76", "zeroconf": [ "_spotify-connect._tcp.local." ] } diff --git a/custom_components/spotifyplus/media_player.py b/custom_components/spotifyplus/media_player.py index f8e7d5b..f505059 100644 --- a/custom_components/spotifyplus/media_player.py +++ b/custom_components/spotifyplus/media_player.py @@ -142,6 +142,7 @@ ATTR_SPOTIFYPLUS_PLAYING_TYPE = "sp_playing_type" ATTR_SPOTIFYPLUS_PLAYLIST_NAME = "sp_playlist_name" ATTR_SPOTIFYPLUS_PLAYLIST_URI = "sp_playlist_uri" +ATTR_SPOTIFYPLUS_SOURCE_LIST_HIDE = "sp_source_list_hide" ATTR_SPOTIFYPLUS_TRACK_IS_EXPLICIT = "sp_track_is_explicit" ATTR_SPOTIFYPLUS_USER_COUNTRY = "sp_user_country" ATTR_SPOTIFYPLUS_USER_DISPLAY_NAME = "sp_user_display_name" @@ -440,7 +441,9 @@ def extra_state_attributes(self) -> dict: attributes[ATTR_SPOTIFYPLUS_USER_PRODUCT] = ATTRVALUE_UNKNOWN attributes[ATTR_SPOTIFYPLUS_USER_URI] = ATTRVALUE_UNKNOWN - self.data.spotifyClient.UserProfile.DisplayName + # add configuration options information. + if (self.data is not None): + attributes[ATTR_SPOTIFYPLUS_SOURCE_LIST_HIDE] = self.data.OptionSourceListHide # add currently active playstate information. if self._playerState is not None: @@ -1640,6 +1643,8 @@ def _UpdateHAFromPlayerPlayState(self, playerPlayState:PlayerPlayState) -> None: if self._attr_state is not MediaPlayerState.OFF: if self._isInCommandEvent: pass + elif (playerPlayState.IsEmpty): + self._attr_state = MediaPlayerState.IDLE elif playerPlayState.IsPlaying == True: self._attr_state = MediaPlayerState.PLAYING elif playerPlayState.IsPlaying == False: diff --git a/requirements.txt b/requirements.txt index 2cc9c3f..f23765a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ homeassistant==2024.5.0 ruff==0.1.3 soco>=0.30.4 smartinspectPython>=3.0.33 -spotifywebapiPython>=1.0.129 +spotifywebapiPython>=1.0.130