Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/components/media-player/ha-media-player-browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import { computeRTLDirection } from "../../common/util/compute_rtl";
import { debounce } from "../../common/util/debounce";
import { getSignedPath } from "../../data/auth";
import { UNAVAILABLE_STATES } from "../../data/entity";
import type { MediaPlayerItem } from "../../data/media-player";
import {
browseMediaPlayer,
Expand All @@ -45,6 +46,7 @@ import type { HomeAssistant } from "../../types";
import { brandsUrl, extractDomainFromBrandUrl } from "../../util/brands-url";
import { documentationUrl } from "../../util/documentation-url";
import "../entity/ha-entity-picker";
import "../ha-alert";
import "../ha-button-menu";
import "../ha-card";
import "../ha-circular-progress";
Expand Down Expand Up @@ -246,6 +248,16 @@ export class HaMediaPlayerBrowse extends LitElement {
],
replace: true,
});
} else if (
err.code === "entity_not_found" &&
UNAVAILABLE_STATES.includes(this.hass.states[this.entityId]?.state)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this check still?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. If the entity isnt found for another reason then we still just show the error. Not sure if there is another reason but guessing it could be possible to ask for an entity that doesn't exist at all

) {
this._setError({
message: this.hass.localize(
`ui.components.media-browser.media_player_unavailable`
),
code: "entity_not_found",
});
} else {
this._setError(err);
}
Expand Down Expand Up @@ -305,7 +317,11 @@ export class HaMediaPlayerBrowse extends LitElement {
protected render(): TemplateResult {
if (this._error) {
return html`
<div class="container">${this._renderError(this._error)}</div>
<div class="container">
<ha-alert alert-type="error">
${this._renderError(this._error)}
</ha-alert>
</div>
`;
}

Expand Down Expand Up @@ -420,7 +436,9 @@ export class HaMediaPlayerBrowse extends LitElement {
this._error
? html`
<div class="container">
${this._renderError(this._error)}
<ha-alert alert-type="error">
${this._renderError(this._error)}
</ha-alert>
</div>
`
: isTTSMediaSource(currentItem.media_content_id)
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@
"tv_show": "TV Show",
"url": "URL",
"video": "Video"
}
},
"media_player_unavailable": "The selected media player is unavailable."
},
"calendar": {
"my_calendars": "My Calendars",
Expand Down