Skip to content

Commit

Permalink
[ 1.0.27 ] * Added extra state attribute media_playlist_content_id
Browse files Browse the repository at this point in the history
…that contains the Content ID of current playing playlist context if one is active; otherwise, None.

  * Added property `media_player.media_playlist_content_id` that contains the Content ID of current playing playlist context if one is active; otherwise, None.
  * Added property `media_player.media_playlist_content_type` that contains the Content Type of current playing playlist if one is playing; otherwise, None.
  * Added property `media_player.media_playlist_description` that contains the Description of current playing playlist if one is playing; otherwise, None.
  * Added property `media_player.media_playlist_image_url` that contains the Image URL of current playing playlist if one is playing; otherwise, None.
  * Updated `use_ssl` description on all of the Zeroconf Device services.
  • Loading branch information
thlucas1 committed Jun 12, 2024
1 parent e9f7dd3 commit dd11439
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Change are listed in reverse chronological order (newest to oldest).

<span class="changelog">

###### [ 1.0.27 ] - 2024/06/12

* Added extra state attribute `media_playlist_content_id` that contains the Content ID of current playing playlist context if one is active; otherwise, None.
* Added property `media_player.media_playlist_content_id` that contains the Content ID of current playing playlist context if one is active; otherwise, None.
* Added property `media_player.media_playlist_content_type` that contains the Content Type of current playing playlist if one is playing; otherwise, None.
* Added property `media_player.media_playlist_description` that contains the Description of current playing playlist if one is playing; otherwise, None.
* Added property `media_player.media_playlist_image_url` that contains the Image URL of current playing playlist if one is playing; otherwise, None.
* Updated `use_ssl` description on all of the Zeroconf Device services.

###### [ 1.0.26 ] - 2024/06/10

Expand Down
2 changes: 1 addition & 1 deletion custom_components/spotifyplus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"urllib3>=1.21.1,<1.27",
"zeroconf>=0.132.2"
],
"version": "1.0.26",
"version": "1.0.27",
"zeroconf": [ "_spotify-connect._tcp.local." ]
}
44 changes: 42 additions & 2 deletions custom_components/spotifyplus/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ def extra_state_attributes(self):
if self._playerState.Device is not None:
attributes[ATTR_SPOTIFYPLUS_DEVICE_ID] = self._playerState.Device.Id
attributes[ATTR_SPOTIFYPLUS_DEVICE_NAME] = self._playerState.Device.Name

# add currently active playlist information.
if self._playlist is not None:
attributes['media_playlist_content_id'] = self._playlist.Uri

return attributes

Expand Down Expand Up @@ -437,12 +441,44 @@ def media_track(self) -> int | None:

@property
def media_playlist(self):
""" Title of Playlist currently playing. """
""" Title of current playing playlist. """
if self._playlist is not None:
return self._playlist.Name
return None


@property
@property
def media_playlist_content_id(self):
""" Content ID of current playing playlist. """
if self._playlist is not None:
return self._playlist.Uri
return None


@property
def media_playlist_content_type(self):
""" Content Type of current playing playlist. """
if self._playlist is not None:
return self._playlist.Type
return None


def media_playlist_description(self):
""" Description of current playing playlist. """
if self._playlist is not None:
return self._playlist.Description
return None


@property
def media_playlist_image_url(self):
""" Image URL of current playing playlist. """
if self._playlist is not None:
return self._playlist.ImageUrl
return None


@property
def source(self) -> str | None:
""" Return the current playback device. """
Expand Down Expand Up @@ -921,7 +957,7 @@ def update(self) -> None:

# did the now playing context change?
context:Context = self._playerState.Context
if context is not None and (self._playlist is None or self._playlist.Uri != context.Uri):
if (context is not None) and (self._playlist is None or self._playlist.Uri != context.Uri):

# yes - if it's a playlist, then we need to update the stored playlist reference.
self._playlist = None
Expand All @@ -942,6 +978,10 @@ def update(self) -> None:

self._playlist = None

elif (context is None):

self._playlist = None

except SpotifyWebApiError as ex:

_logsi.LogException(None, ex)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/spotifyplus/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ zeroconf_device_connect:
text:
use_ssl:
name: Use SSL?
description: Spotify Connect Zeroconf API version number that the device supports (e.g. False).
description: True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP).
example: "False"
required: false
selector:
Expand Down
6 changes: 3 additions & 3 deletions custom_components/spotifyplus/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@
},
"use_ssl": {
"name": "Use SSL?",
"description": "Spotify Connect Zeroconf API version number that the device supports (e.g. False)."
"description": "True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP)."
},
"username": {
"name": "Spotify User Name",
Expand Down Expand Up @@ -1154,7 +1154,7 @@
},
"use_ssl": {
"name": "Use SSL?",
"description": "Spotify Connect Zeroconf API version number that the device supports (e.g. False)."
"description": "True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP)."
}
}
},
Expand Down Expand Up @@ -1184,7 +1184,7 @@
},
"use_ssl": {
"name": "Use SSL?",
"description": "Spotify Connect Zeroconf API version number that the device supports (e.g. False)."
"description": "True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP)."
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions custom_components/spotifyplus/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@
},
"use_ssl": {
"name": "Use SSL?",
"description": "Spotify Connect Zeroconf API version number that the device supports (e.g. False)."
"description": "True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP)."
},
"username": {
"name": "Spotify User Name",
Expand Down Expand Up @@ -1154,7 +1154,7 @@
},
"use_ssl": {
"name": "Use SSL?",
"description": "Spotify Connect Zeroconf API version number that the device supports (e.g. False)."
"description": "True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP)."
}
}
},
Expand Down Expand Up @@ -1184,7 +1184,7 @@
},
"use_ssl": {
"name": "Use SSL?",
"description": "Spotify Connect Zeroconf API version number that the device supports (e.g. False)."
"description": "True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support; otherwise, False to utilize HTTP. Default is False (HTTP)."
}
}
},
Expand Down

0 comments on commit dd11439

Please sign in to comment.