mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 18:36:35 +00:00
Set Error if entity is unavailable (#12791)
This commit is contained in:
parent
c9df93bc54
commit
00dcecabb7
@ -28,6 +28,7 @@ import { fireEvent } from "../../common/dom/fire_event";
|
|||||||
import { computeRTLDirection } from "../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../common/util/compute_rtl";
|
||||||
import { debounce } from "../../common/util/debounce";
|
import { debounce } from "../../common/util/debounce";
|
||||||
import { getSignedPath } from "../../data/auth";
|
import { getSignedPath } from "../../data/auth";
|
||||||
|
import { UNAVAILABLE_STATES } from "../../data/entity";
|
||||||
import type { MediaPlayerItem } from "../../data/media-player";
|
import type { MediaPlayerItem } from "../../data/media-player";
|
||||||
import {
|
import {
|
||||||
browseMediaPlayer,
|
browseMediaPlayer,
|
||||||
@ -45,6 +46,7 @@ import type { HomeAssistant } from "../../types";
|
|||||||
import { brandsUrl, extractDomainFromBrandUrl } from "../../util/brands-url";
|
import { brandsUrl, extractDomainFromBrandUrl } from "../../util/brands-url";
|
||||||
import { documentationUrl } from "../../util/documentation-url";
|
import { documentationUrl } from "../../util/documentation-url";
|
||||||
import "../entity/ha-entity-picker";
|
import "../entity/ha-entity-picker";
|
||||||
|
import "../ha-alert";
|
||||||
import "../ha-button-menu";
|
import "../ha-button-menu";
|
||||||
import "../ha-card";
|
import "../ha-card";
|
||||||
import "../ha-circular-progress";
|
import "../ha-circular-progress";
|
||||||
@ -246,6 +248,16 @@ export class HaMediaPlayerBrowse extends LitElement {
|
|||||||
],
|
],
|
||||||
replace: true,
|
replace: true,
|
||||||
});
|
});
|
||||||
|
} else if (
|
||||||
|
err.code === "entity_not_found" &&
|
||||||
|
UNAVAILABLE_STATES.includes(this.hass.states[this.entityId]?.state)
|
||||||
|
) {
|
||||||
|
this._setError({
|
||||||
|
message: this.hass.localize(
|
||||||
|
`ui.components.media-browser.media_player_unavailable`
|
||||||
|
),
|
||||||
|
code: "entity_not_found",
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this._setError(err);
|
this._setError(err);
|
||||||
}
|
}
|
||||||
@ -305,7 +317,11 @@ export class HaMediaPlayerBrowse extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (this._error) {
|
if (this._error) {
|
||||||
return html`
|
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>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +436,9 @@ export class HaMediaPlayerBrowse extends LitElement {
|
|||||||
this._error
|
this._error
|
||||||
? html`
|
? html`
|
||||||
<div class="container">
|
<div class="container">
|
||||||
${this._renderError(this._error)}
|
<ha-alert alert-type="error">
|
||||||
|
${this._renderError(this._error)}
|
||||||
|
</ha-alert>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: isTTSMediaSource(currentItem.media_content_id)
|
: isTTSMediaSource(currentItem.media_content_id)
|
||||||
|
@ -609,7 +609,8 @@
|
|||||||
"tv_show": "TV Show",
|
"tv_show": "TV Show",
|
||||||
"url": "URL",
|
"url": "URL",
|
||||||
"video": "Video"
|
"video": "Video"
|
||||||
}
|
},
|
||||||
|
"media_player_unavailable": "The selected media player is unavailable."
|
||||||
},
|
},
|
||||||
"calendar": {
|
"calendar": {
|
||||||
"my_calendars": "My Calendars",
|
"my_calendars": "My Calendars",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user