Skip to content

Commit 7a0565b

Browse files
committed
[ 1.0.35 ] * This release requires the SpotifyPlus Integration v1.0.90+ release; please make sure you update the SpotifyPlus integration prior to updating this SpotifyPlus Card release.
* Added `utils.getHomeAssistantErrorMessage` function to make error messages and warnings a little more user-friendly. * Added card version to General Editor form. * Added refresh of media list when a userpreset filtersection event is processed, which ensures that cached values are refreshed and any newly added favorites are displayed.
1 parent cdb7667 commit 7a0565b

37 files changed

+218
-138
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Change are listed in reverse chronological order (newest to oldest).
66

77
<span class="changelog">
88

9+
###### [ 1.0.35 ] - 2025/02/01
10+
11+
* This release requires the SpotifyPlus Integration v1.0.90+ release; please make sure you update the SpotifyPlus integration prior to updating this SpotifyPlus Card release.
12+
* Added `utils.getHomeAssistantErrorMessage` function to make error messages and warnings a little more user-friendly.
13+
* Added card version to General Editor form.
14+
* Added refresh of media list when a userpreset filtersection event is processed, which ensures that cached values are refreshed and any newly added favorites are displayed.
15+
916
###### [ 1.0.34 ] - 2025/01/26
1017

1118
* Added card configuration option `deviceDefaultId` for specifying a Device ID to use for all SpotifyPlus service calls that require a deviceId argument. This allows you to hide the Devices section, and utilize the specific device for all service requests that require a deviceId.

SpotifyPlusCard.njsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
<TypeScriptCompile Include="src\types\home-assistant-frontend\lovelace-card-config.ts" />
190190
<TypeScriptCompile Include="src\types\home-assistant-frontend\service-call-request.ts" />
191191
<TypeScriptCompile Include="src\types\home-assistant-frontend\service-call-response.ts" />
192+
<TypeScriptCompile Include="src\types\home-assistant-frontend\service-validation-error.ts" />
192193
<TypeScriptCompile Include="src\types\playerAlerts.ts" />
193194
<TypeScriptCompile Include="src\types\search-media-types.ts" />
194195
<TypeScriptCompile Include="src\types\spotifyplus-hass-entity.ts" />

src/card.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,6 @@ export class Card extends LitElement {
750750

751751
// execute the filter.
752752
browserBase.filterSectionMedia(evArgs);
753-
//super.requestUpdate();
754753

755754
}, 50);
756755

src/components/album-actions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { MediaPlayer } from '../model/media-player';
2525
import { SearchMediaTypes } from '../types/search-media-types';
2626
import { SearchMediaEvent } from '../events/search-media';
2727
import { getIdFromSpotifyUri } from '../services/spotifyplus-service';
28-
import { formatDateHHMMSSFromMilliseconds } from '../utils/utils';
28+
import { formatDateHHMMSSFromMilliseconds, getHomeAssistantErrorMessage } from '../utils/utils';
2929
import { openWindowNewTab } from '../utils/media-browser-utils';
3030
import { ALERT_INFO_PRESET_COPIED_TO_CLIPBOARD, ALERT_INFO_PRESET_JSON_COPIED_TO_CLIPBOARD, RADIO_SEARCH_KEY } from '../constants';
3131
import { GetCopyrights } from '../types/spotifyplus/copyright';
@@ -512,7 +512,7 @@ class AlbumActions extends FavActionsBase {
512512

513513
// clear the progress indicator and set alert error message.
514514
this.progressHide();
515-
this.alertErrorSet("Action failed: " + (error as Error).message);
515+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
516516
return true;
517517

518518
}
@@ -564,7 +564,7 @@ class AlbumActions extends FavActionsBase {
564564

565565
// clear results, and reject the promise.
566566
this.albumTracks = undefined;
567-
this.alertErrorSet("Get Album Tracks failed: " + (error as Error).message);
567+
this.alertErrorSet("Get Album Tracks failed: " + getHomeAssistantErrorMessage(error));
568568
reject(error);
569569

570570
})
@@ -593,7 +593,7 @@ class AlbumActions extends FavActionsBase {
593593

594594
// clear results, and reject the promise.
595595
this.isAlbumFavorite = undefined;
596-
this.alertErrorSet("Check Album Favorite failed: " + (error as Error).message);
596+
this.alertErrorSet("Check Album Favorite failed: " + getHomeAssistantErrorMessage(error));
597597
reject(error);
598598

599599
})
@@ -622,7 +622,7 @@ class AlbumActions extends FavActionsBase {
622622

623623
// clear results, and reject the promise.
624624
this.isArtistFavorite = undefined;
625-
this.alertErrorSet("Check Artist Following failed: " + (error as Error).message);
625+
this.alertErrorSet("Check Artist Following failed: " + getHomeAssistantErrorMessage(error));
626626
reject(error);
627627

628628
})
@@ -651,7 +651,7 @@ class AlbumActions extends FavActionsBase {
651651

652652
// clear the progress indicator and set alert error message.
653653
this.progressHide();
654-
this.alertErrorSet("Album actions refresh failed: " + (error as Error).message);
654+
this.alertErrorSet("Album actions refresh failed: " + getHomeAssistantErrorMessage(error));
655655
return true;
656656

657657
}

src/components/artist-actions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { MediaPlayer } from '../model/media-player';
2929
import { SearchMediaTypes } from '../types/search-media-types';
3030
import { SearchMediaEvent } from '../events/search-media';
3131
import { openWindowNewTab } from '../utils/media-browser-utils';
32-
import { unescapeHtml } from '../utils/utils';
32+
import { getHomeAssistantErrorMessage, unescapeHtml } from '../utils/utils';
3333
import { GetUserPresetConfigEntry, GetUserPresetConfigEntryJson } from '../types/spotifyplus/user-preset';
3434
import { ALERT_INFO_PRESET_COPIED_TO_CLIPBOARD, ALERT_INFO_PRESET_JSON_COPIED_TO_CLIPBOARD } from '../constants';
3535
import { IArtist, GetGenres } from '../types/spotifyplus/artist';
@@ -411,7 +411,7 @@ class ArtistActions extends FavActionsBase {
411411

412412
// clear the progress indicator and set alert error message.
413413
this.progressHide();
414-
this.alertErrorSet("Action failed: " + (error as Error).message);
414+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
415415
return true;
416416

417417
}
@@ -460,7 +460,7 @@ class ArtistActions extends FavActionsBase {
460460
.catch(error => {
461461

462462
if (debuglog.enabled) {
463-
debuglog("updateActions - Get Artist Info failed: " + (error as Error).message);
463+
debuglog("updateActions - Get Artist Info failed: " + getHomeAssistantErrorMessage(error));
464464
}
465465

466466
// clear results, and resolve the promise; we do this, as the GetArtistInfo is an
@@ -470,7 +470,7 @@ class ArtistActions extends FavActionsBase {
470470

471471
// clear results, and reject the promise.
472472
//this.artistInfo = undefined;
473-
//this.alertErrorSet("Get Artist Info failed: " + (error as Error).message);
473+
//this.alertErrorSet("Get Artist Info failed: " + getHomeAssistantErrorMessage(error));
474474
//reject(error);
475475

476476
})
@@ -499,7 +499,7 @@ class ArtistActions extends FavActionsBase {
499499

500500
// clear results, and reject the promise.
501501
this.isArtistFavorite = undefined;
502-
this.alertErrorSet("Check Artist Favorites failed: " + (error as Error).message);
502+
this.alertErrorSet("Check Artist Favorites failed: " + getHomeAssistantErrorMessage(error));
503503
reject(error);
504504

505505
})
@@ -528,7 +528,7 @@ class ArtistActions extends FavActionsBase {
528528

529529
// clear the progress indicator and set alert error message.
530530
this.progressHide();
531-
this.alertErrorSet("Artist actions refresh failed: " + (error as Error).message);
531+
this.alertErrorSet("Artist actions refresh failed: " + getHomeAssistantErrorMessage(error));
532532
return true;
533533

534534
}

src/components/audiobook-actions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Section } from '../types/section';
2222
import { MediaPlayer } from '../model/media-player';
2323
import { SearchMediaTypes } from '../types/search-media-types';
2424
import { SearchMediaEvent } from '../events/search-media';
25-
import { formatDateHHMMSSFromMilliseconds, unescapeHtml } from '../utils/utils';
25+
import { formatDateHHMMSSFromMilliseconds, getHomeAssistantErrorMessage, unescapeHtml } from '../utils/utils';
2626
import { openWindowNewTab } from '../utils/media-browser-utils';
2727
import { ALERT_INFO_PRESET_COPIED_TO_CLIPBOARD, ALERT_INFO_PRESET_JSON_COPIED_TO_CLIPBOARD } from '../constants';
2828
import { GetCopyrights } from '../types/spotifyplus/copyright';
@@ -324,7 +324,7 @@ class AudiobookActions extends FavActionsBase {
324324

325325
// clear the progress indicator and set alert error message.
326326
this.progressHide();
327-
this.alertErrorSet("Action failed: " + (error as Error).message);
327+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
328328
return true;
329329

330330
}
@@ -377,7 +377,7 @@ class AudiobookActions extends FavActionsBase {
377377

378378
// clear results, and reject the promise.
379379
this.audiobookChapters = undefined;
380-
this.alertErrorSet("Get Audiobook Chapters failed: " + (error as Error).message);
380+
this.alertErrorSet("Get Audiobook Chapters failed: " + getHomeAssistantErrorMessage(error));
381381
reject(error);
382382

383383
})
@@ -406,7 +406,7 @@ class AudiobookActions extends FavActionsBase {
406406

407407
// clear results, and reject the promise.
408408
this.isAudiobookFavorite = undefined;
409-
this.alertErrorSet("Check Audiobook Favorites failed: " + (error as Error).message);
409+
this.alertErrorSet("Check Audiobook Favorites failed: " + getHomeAssistantErrorMessage(error));
410410
reject(error);
411411

412412
})
@@ -435,7 +435,7 @@ class AudiobookActions extends FavActionsBase {
435435

436436
// clear the progress indicator and set alert error message.
437437
this.progressHide();
438-
this.alertErrorSet("Audiobook actions refresh failed: " + (error as Error).message);
438+
this.alertErrorSet("Audiobook actions refresh failed: " + getHomeAssistantErrorMessage(error));
439439
return true;
440440

441441
}

src/components/device-actions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { sharedStylesFavActions } from '../styles/shared-styles-fav-actions';
1414
import { FavActionsBase } from './fav-actions-base';
1515
import { Section } from '../types/section';
1616
import { MediaPlayer } from '../model/media-player';
17-
import { copyToClipboard } from '../utils/utils';
17+
import { copyToClipboard, getHomeAssistantErrorMessage } from '../utils/utils';
1818
import { ISpotifyConnectDevice } from '../types/spotifyplus/spotify-connect-device';
1919

2020
/**
@@ -320,7 +320,7 @@ class DeviceActions extends FavActionsBase {
320320

321321
// clear the progress indicator and set alert error message.
322322
this.progressHide();
323-
this.alertErrorSet("Action failed: " + (error as Error).message);
323+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
324324
return true;
325325

326326
}
@@ -389,7 +389,7 @@ class DeviceActions extends FavActionsBase {
389389

390390
// clear results, and reject the promise.
391391
this.deviceInfo = undefined;
392-
this.alertErrorSet("Get Spotify Connect Device failed: " + (error as Error).message);
392+
this.alertErrorSet("Get Spotify Connect Device failed: " + getHomeAssistantErrorMessage(error));
393393
reject(error);
394394

395395
})
@@ -418,7 +418,7 @@ class DeviceActions extends FavActionsBase {
418418

419419
// clear the progress indicator and set alert error message.
420420
this.progressHide();
421-
this.alertErrorSet("Update device actions failed: " + (error as Error).message);
421+
this.alertErrorSet("Update device actions failed: " + getHomeAssistantErrorMessage(error));
422422
return true;
423423

424424
}

src/components/episode-actions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Section } from '../types/section';
2121
import { MediaPlayer } from '../model/media-player';
2222
import { SearchMediaTypes } from '../types/search-media-types';
2323
import { SearchMediaEvent } from '../events/search-media';
24-
import { formatDateHHMMSSFromMilliseconds, unescapeHtml } from '../utils/utils';
24+
import { formatDateHHMMSSFromMilliseconds, getHomeAssistantErrorMessage, unescapeHtml } from '../utils/utils';
2525
import { openWindowNewTab } from '../utils/media-browser-utils';
2626
import { ALERT_INFO_PRESET_COPIED_TO_CLIPBOARD, ALERT_INFO_PRESET_JSON_COPIED_TO_CLIPBOARD } from '../constants';
2727
import { GetUserPresetConfigEntry, GetUserPresetConfigEntryJson } from '../types/spotifyplus/user-preset';
@@ -378,7 +378,7 @@ class EpisodeActions extends FavActionsBase {
378378

379379
// clear the progress indicator and set alert error message.
380380
this.progressHide();
381-
this.alertErrorSet("Action failed: " + (error as Error).message);
381+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
382382
return true;
383383

384384
}
@@ -456,7 +456,7 @@ class EpisodeActions extends FavActionsBase {
456456

457457
// clear results, and reject the promise.
458458
this.episode = undefined;
459-
this.alertErrorSet("Get Episode call failed: " + (error as Error).message);
459+
this.alertErrorSet("Get Episode call failed: " + getHomeAssistantErrorMessage(error));
460460
reject(error);
461461

462462
})
@@ -485,7 +485,7 @@ class EpisodeActions extends FavActionsBase {
485485

486486
// clear results, and reject the promise.
487487
this.isShowFavorite = undefined;
488-
this.alertErrorSet("Check Show Favorite failed: " + (error as Error).message);
488+
this.alertErrorSet("Check Show Favorite failed: " + getHomeAssistantErrorMessage(error));
489489
reject(error);
490490

491491
})
@@ -514,7 +514,7 @@ class EpisodeActions extends FavActionsBase {
514514

515515
// clear results, and reject the promise.
516516
this.isEpisodeFavorite = undefined;
517-
this.alertErrorSet("Check Episode Favorites failed: " + (error as Error).message);
517+
this.alertErrorSet("Check Episode Favorites failed: " + getHomeAssistantErrorMessage(error));
518518
reject(error);
519519

520520
})
@@ -543,7 +543,7 @@ class EpisodeActions extends FavActionsBase {
543543

544544
// clear the progress indicator and set alert error message.
545545
this.progressHide();
546-
this.alertErrorSet("Episode actions refresh failed: " + (error as Error).message);
546+
this.alertErrorSet("Episode actions refresh failed: " + getHomeAssistantErrorMessage(error));
547547
return true;
548548

549549
}

src/components/fav-actions-base.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Store } from '../model/store';
77
import { Section } from '../types/section';
88
import { MediaPlayer } from '../model/media-player';
99
import { SpotifyPlusService } from '../services/spotifyplus-service';
10-
import { isCardInEditPreview } from '../utils/utils';
10+
import { getHomeAssistantErrorMessage, isCardInEditPreview } from '../utils/utils';
1111
import { ProgressStartedEvent } from '../events/progress-started';
1212
import { ProgressEndedEvent } from '../events/progress-ended';
1313
import { SearchMediaTypes } from '../types/search-media-types';
@@ -238,7 +238,7 @@ export class FavActionsBase extends LitElement {
238238
catch (error) {
239239

240240
// set error status,
241-
this.alertErrorSet("Could not add media item to play queue. " + (error as Error).message);
241+
this.alertErrorSet("Could not add media item to play queue. " + getHomeAssistantErrorMessage(error));
242242

243243
}
244244
finally {
@@ -273,7 +273,7 @@ export class FavActionsBase extends LitElement {
273273
catch (error) {
274274

275275
// set error status,
276-
this.alertErrorSet("Could not play media item. " + (error as Error).message);
276+
this.alertErrorSet("Could not play media item. " + getHomeAssistantErrorMessage(error));
277277

278278
}
279279
finally {

src/components/player-body-audiobook.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { MediaPlayer } from '../model/media-player';
2222
import { SearchMediaTypes } from '../types/search-media-types';
2323
import { SearchMediaEvent } from '../events/search-media';
2424
import { getIdFromSpotifyUri } from '../services/spotifyplus-service';
25-
import { formatDateHHMMSSFromMilliseconds, unescapeHtml } from '../utils/utils';
25+
import { formatDateHHMMSSFromMilliseconds, getHomeAssistantErrorMessage, unescapeHtml } from '../utils/utils';
2626
import { openWindowNewTab } from '../utils/media-browser-utils';
2727
import { ALERT_INFO_PRESET_COPIED_TO_CLIPBOARD, ALERT_INFO_PRESET_JSON_COPIED_TO_CLIPBOARD } from '../constants';
2828
import { GetAudiobookAuthors, GetAudiobookNarrators } from '../types/spotifyplus/audiobook-simplified';
@@ -403,7 +403,7 @@ export class PlayerBodyAudiobook extends PlayerBodyBase {
403403

404404
// clear the progress indicator and set alert error message.
405405
this.progressHide();
406-
this.alertErrorSet("Action failed: " + (error as Error).message);
406+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
407407
return true;
408408

409409
}
@@ -465,7 +465,7 @@ export class PlayerBodyAudiobook extends PlayerBodyBase {
465465

466466
// clear results, and reject the promise.
467467
this.chapter = undefined;
468-
this.alertErrorSet("Get Episode call failed: " + (error as Error).message);
468+
this.alertErrorSet("Get Episode call failed: " + getHomeAssistantErrorMessage(error));
469469
reject(error);
470470

471471
})
@@ -494,7 +494,7 @@ export class PlayerBodyAudiobook extends PlayerBodyBase {
494494

495495
// clear results, and reject the promise.
496496
this.isAudiobookFavorite = undefined;
497-
this.alertErrorSet("Check Audiobook Favorites failed: " + (error as Error).message);
497+
this.alertErrorSet("Check Audiobook Favorites failed: " + getHomeAssistantErrorMessage(error));
498498
reject(error);
499499

500500
})
@@ -523,7 +523,7 @@ export class PlayerBodyAudiobook extends PlayerBodyBase {
523523

524524
// clear results, and reject the promise.
525525
this.isChapterFavorite = undefined;
526-
this.alertErrorSet("Check Episode Favorites failed: " + (error as Error).message);
526+
this.alertErrorSet("Check Episode Favorites failed: " + getHomeAssistantErrorMessage(error));
527527
reject(error);
528528

529529
})
@@ -555,7 +555,7 @@ export class PlayerBodyAudiobook extends PlayerBodyBase {
555555

556556
// clear the progress indicator and set alert error message.
557557
this.progressHide();
558-
this.alertErrorSet("Audiobook actions refresh failed: " + (error as Error).message);
558+
this.alertErrorSet("Audiobook actions refresh failed: " + getHomeAssistantErrorMessage(error));
559559
return true;
560560

561561
}

src/components/player-body-queue.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { sharedStylesGrid } from '../styles/shared-styles-grid.js';
1515
import { sharedStylesMediaInfo } from '../styles/shared-styles-media-info.js';
1616
import { sharedStylesFavActions } from '../styles/shared-styles-fav-actions.js';
1717
import { getMediaListTrackUrisRemaining } from '../utils/media-browser-utils.js';
18+
import { getHomeAssistantErrorMessage } from '../utils/utils';
1819
import { PlayerBodyBase } from './player-body-base';
1920
import { MediaPlayer } from '../model/media-player';
2021
import { IPlayerQueueInfo } from '../types/spotifyplus/player-queue-info';
@@ -248,7 +249,7 @@ export class PlayerBodyQueue extends PlayerBodyBase {
248249

249250
// clear the progress indicator and set alert error message.
250251
this.progressHide();
251-
this.alertErrorSet("Action failed: " + (error as Error).message);
252+
this.alertErrorSet("Action failed: " + getHomeAssistantErrorMessage(error));
252253
return true;
253254

254255
}
@@ -324,7 +325,7 @@ export class PlayerBodyQueue extends PlayerBodyBase {
324325

325326
// clear results, and reject the promise.
326327
this.queueInfo = undefined;
327-
this.alertErrorSet("Get Player Queue Info call failed: " + (error as Error).message);
328+
this.alertErrorSet("Get Player Queue Info call failed: " + getHomeAssistantErrorMessage(error));
328329
reject(error);
329330

330331
})
@@ -356,7 +357,7 @@ export class PlayerBodyQueue extends PlayerBodyBase {
356357

357358
// clear the progress indicator and set alert error message.
358359
this.progressHide();
359-
this.alertErrorSet("Queue info refresh failed: " + (error as Error).message);
360+
this.alertErrorSet("Queue info refresh failed: " + getHomeAssistantErrorMessage(error));
360361
return true;
361362

362363
}

0 commit comments

Comments
 (0)