fix: Substantially reduce cases where errors block whole card (#1764)
This commit is contained in:
@@ -3,14 +3,11 @@ import { CSSResultGroup, html, LitElement, TemplateResult, unsafeCSS } from 'lit
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
import { createRef, Ref, ref } from 'lit/directives/ref.js';
|
||||
import { CameraConfig } from '../../../config/types';
|
||||
import { localize } from '../../../localize/localize';
|
||||
import '../../../patches/ha-camera-stream';
|
||||
import '../../../patches/ha-hls-player.js';
|
||||
import '../../../patches/ha-web-rtc-player.js';
|
||||
import liveHAStyle from '../../../scss/live-ha.scss';
|
||||
import { FrigateCardMediaPlayer } from '../../../types.js';
|
||||
import { renderMessage } from '../../message';
|
||||
import { getStateObjOrDispatchError } from '../../../utils/get-state-obj';
|
||||
|
||||
@customElement('frigate-card-live-ha')
|
||||
export class FrigateCardLiveHA extends LitElement implements FrigateCardMediaPlayer {
|
||||
@@ -66,22 +63,12 @@ export class FrigateCardLiveHA extends LitElement implements FrigateCardMediaPla
|
||||
return;
|
||||
}
|
||||
|
||||
const stateObj = getStateObjOrDispatchError(this, this.hass, this.cameraConfig);
|
||||
if (!stateObj) {
|
||||
return;
|
||||
}
|
||||
if (stateObj.state === 'unavailable') {
|
||||
return renderMessage({
|
||||
message: localize('error.live_camera_unavailable'),
|
||||
type: 'error',
|
||||
icon: 'mdi:connection',
|
||||
context: this.cameraConfig,
|
||||
});
|
||||
}
|
||||
return html` <frigate-card-ha-camera-stream
|
||||
${ref(this._playerRef)}
|
||||
.hass=${this.hass}
|
||||
.stateObj=${stateObj}
|
||||
.stateObj=${this.cameraConfig?.camera_entity
|
||||
? this.hass.states[this.cameraConfig.camera_entity]
|
||||
: undefined}
|
||||
.controls=${this.controls}
|
||||
.muted=${true}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user