Skip to content

Commit

Permalink
[ 1.0.28 ] * This release requires the SpotifyPlus Integration v1.0.8…
Browse files Browse the repository at this point in the history
…5+ release; please make sure you update the SpotifyPlus integration prior to updating this SpotifyPlus Card release.

  * Added `deviceBrowserItemsShowHiddenDevices` config option to show SpotifyPlus configured hidden devices in Device browser.  If true, the SpotifyPlus configuration option to hide specified device names in the media source list is ignored and ALL known devices are listed.
  * Added play button icon to player section, which will be displayed if the player state is IDLE.
  • Loading branch information
thlucas1 committed Jan 9, 2025
1 parent 851a8ec commit f2bbaea
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 36 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Change are listed in reverse chronological order (newest to oldest).

<span class="changelog">

###### [ 1.0.28 ] - 2025/01/09

* This release requires the SpotifyPlus Integration v1.0.85+ release; please make sure you update the SpotifyPlus integration prior to updating this SpotifyPlus Card release.
* Added `deviceBrowserItemsShowHiddenDevices` config option to show SpotifyPlus configured hidden devices in Device browser. If true, the SpotifyPlus configuration option to hide specified device names in the media source list is ignored and ALL known devices are listed.
* Added play button icon to player section, which will be displayed if the player state is IDLE.

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

* This release requires the SpotifyPlus Integration v1.0.76+ release; please make sure you update the SpotifyPlus integration prior to updating this SpotifyPlus Card release.
Expand Down
4 changes: 4 additions & 0 deletions src/components/player-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class PlayerControls extends LitElement {
this.mediaControlService = this.store.mediaControlService;

const stopped = [MediaPlayerState.ON, MediaPlayerState.PLAYING, MediaPlayerState.PAUSED, MediaPlayerState.BUFFERING].includes(this.player.state) && nothing;
const idle = [MediaPlayerState.IDLE].includes(this.player.state) && nothing;

// set button color based on selected option.
const colorRepeat = [RepeatMode.ONE, RepeatMode.ALL].includes(this.player.attributes.repeat || RepeatMode.OFF);
Expand All @@ -99,6 +100,9 @@ class PlayerControls extends LitElement {
<ha-icon-button @click=${() => this.onClickAction(REPEAT_SET)} hide=${this.hideFeature(REPEAT_SET)} .path=${this.getRepeatIcon()} label="Repeat" style=${this.styleIcon(colorRepeat)} ></ha-icon-button>
<ha-icon-button @click=${() => this.onClickAction(PLAY_QUEUE)} hide=${this.hideFeature(PLAY_QUEUE)} .path=${mdiPlaylistMusic} label="Play Queue Information" style=${this.styleIcon(colorQueueItems)} ></ha-icon-button>
</div>
<div class="iconsIdle" hide=${idle}>
<ha-icon-button @click=${() => this.onClickAction(PLAY)} hide=${this.hideFeature(PLAY)} .path=${mdiPlay} label="Play" style=${this.styleIcon(true)}></ha-icon-button>
</div>
<spc-player-volume hide=${stopped} .store=${this.store} .player=${this.player} class="player-volume-container"></spc-player-volume>
<div class="iconsPower">
<ha-icon-button @click=${() => this.onClickAction(TURN_ON)} hide=${this.hideFeature(TURN_ON)} .path=${mdiPower} label="Turn On" style=${this.styleIcon(colorPower)}></ha-icon-button>
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from 'lit';

/** current version of the card. */
export const CARD_VERSION = '1.0.27';
export const CARD_VERSION = '1.0.28';

/** SpotifyPlus integration domain identifier. */
export const DOMAIN_SPOTIFYPLUS = 'spotifyplus';
Expand Down
6 changes: 6 additions & 0 deletions src/editor/device-browser-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ const CONFIG_SETTINGS_SCHEMA = [
required: false,
selector: { boolean: {} },
},
{
name: 'deviceBrowserItemsShowHiddenDevices',
label: 'Show SpotifyPlus configured hidden devices in Device browser',
required: false,
selector: { boolean: {} },
},
];


Expand Down
7 changes: 5 additions & 2 deletions src/sections/device-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ export class DeviceBrowser extends FavBrowserBase {
const refresh = this.refreshDeviceList || false; // refresh device list (defaults to cached list).
const sortResult = true; // true to sort returned items; otherwise, false

// get source items to omit.
const sourceListHide = player.attributes.sp_source_list_hide || [];
// get source items to omit; show / hide based on config setting (hidden by default).
let sourceListHide = player.attributes.sp_source_list_hide || [];
if ((this.config.deviceBrowserItemsShowHiddenDevices && true) == true) {
sourceListHide = [];
}

// call the service to retrieve the media list.
this.spotifyPlusService.GetSpotifyConnectDevices(player.id, refresh, sortResult, sourceListHide)
Expand Down
1 change: 1 addition & 0 deletions src/sections/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export class Player extends LitElement implements playerAlerts {
headerBackgroundColor = 'transparent';
controlsBackgroundColor = 'transparent';
backgroundSize = BRAND_LOGO_IMAGE_SIZE;
this.store.card.footerBackgroundColor = undefined;
}

// set player controls and volume controls icon size.
Expand Down
5 changes: 5 additions & 0 deletions src/services/spotifyplus-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { HomeAssistant } from '../types/home-assistant-frontend/home-assistant';
import { ServiceCallRequest } from '../types/home-assistant-frontend/service-call-request';
import {
mdiCastAudio,
mdiGoogleChrome,
mdiMicrosoftEdge,
mdiSpeaker,
Expand Down Expand Up @@ -2233,6 +2234,8 @@ export class SpotifyPlusService {
responseObj.image_url = getMdiIconImageUrl(mdiMicrosoftEdge);
} else if (sourceCompare.includes('web player')) {
responseObj.image_url = getMdiIconImageUrl(mdiWeb);
} else if (responseObj.IsChromeCast == true) {
responseObj.image_url = getMdiIconImageUrl(mdiCastAudio);
} else {
responseObj.image_url = getMdiIconImageUrl(mdiSpeaker);
}
Expand Down Expand Up @@ -2325,6 +2328,8 @@ export class SpotifyPlusService {
item.image_url = getMdiIconImageUrl(mdiMicrosoftEdge);
} else if (sourceCompare.includes('web player')) {
item.image_url = getMdiIconImageUrl(mdiWeb);
} else if (item.IsChromeCast == true) {
item.image_url = getMdiIconImageUrl(mdiCastAudio);
} else {
item.image_url = getMdiIconImageUrl(mdiSpeaker);
}
Expand Down
6 changes: 6 additions & 0 deletions src/types/card-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export interface CardConfig extends LovelaceCardConfig {
*/
deviceBrowserItemsHideSubTitle?: boolean;

/**
* Show SpotifyPlus configured hidden devices in Device browser.
* Default is false.
*/
deviceBrowserItemsShowHiddenDevices?: boolean;

/**
* Title displayed at the top of the Episode Favorites media browser section form.
* Omit this parameter to hide the title display area.
Expand Down
6 changes: 6 additions & 0 deletions src/types/spotifyplus/spotify-connect-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export interface ISpotifyConnectDevice {
Id: string;


/**
* True if the device is a Google ChromeCast device; otherwise, False.
*/
IsChromeCast: boolean;


/**
* Image to use for media browser displays.
*
Expand Down
47 changes: 14 additions & 33 deletions src/types/spotifyplus/zeroconf-discovery-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ export interface IZeroconfDiscoveryResult {
HostTTL: number;


/**
* Result ID (e.g. "Bose-ST10-1" (192.168.1.81:8200)).
*
* This is a helper property, and not part of the Zeroconf interface.
*/
Id: string;


/**
* True if the device is a Google ChromeCast device; otherwise, False.
*/
IsChromeCast: boolean;


/**
* Returns True if the device is a dynamic device;
* otherwise, False.
Expand Down Expand Up @@ -155,36 +169,3 @@ export interface IZeroconfDiscoveryResult {


}


//# external package imports.
//from zeroconf import ServiceInfo

// @property
// def ServiceInfo(self) -> ServiceInfo:
// """
// Zeroconf Service info object.
// """
// return self._ServiceInfo


// def GetEndpointUrl(self, action:str) -> str:
// """
// Gets a Spotify Zeroconf API endpoint url for the specified action key.

// Args:
// action (str):
// Spotify Zeroconf endpoint action to formulate (e.g. 'getInfo', 'addUser', 'resetUsers', etc).

// Returns:
// A string containing the endpoint url for the specified action key.
// """
// return "http://{ip}:{port}{cpath}?action={action}&version={version}".format(
// ip=self.HostIpAddress,
// port=self.HostIpPort,
// cpath=self.SpotifyConnectCPath,
// action=action,
// version=self.SpotifyConnectVersion or ''
// )


0 comments on commit f2bbaea

Please sign in to comment.