From 924c7804c99b097031e755c6733766fc5e953bef Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 19 Feb 2020 10:44:42 +0100 Subject: [PATCH] Update hui-media-control-card.ts (#4919) --- .../lovelace/cards/hui-media-control-card.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/panels/lovelace/cards/hui-media-control-card.ts b/src/panels/lovelace/cards/hui-media-control-card.ts index 236eb8517e..d596f0befe 100644 --- a/src/panels/lovelace/cards/hui-media-control-card.ts +++ b/src/panels/lovelace/cards/hui-media-control-card.ts @@ -213,10 +213,9 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { applyThemesOnElement(this, this.hass.themes, this._config.theme); } - const oldImage = oldHass - ? oldHass.states[this._config.entity].attributes.entity_picture - : undefined; - const newImage = this.hass.states[this._config.entity].attributes + const oldImage = + oldHass?.states[this._config.entity]?.attributes.entity_picture; + const newImage = this.hass.states[this._config.entity]?.attributes .entity_picture; if (!newImage || newImage === oldImage) { @@ -229,11 +228,13 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { return; } - fetchMediaPlayerThumbnailWithCache(this.hass, this._config.entity).then( - ({ content_type, content }) => { + fetchMediaPlayerThumbnailWithCache(this.hass, this._config.entity) + .then(({ content_type, content }) => { this._image = `data:${content_type};base64,${content}`; - } - ); + }) + .catch(() => { + this._image = undefined; + }); } private _computeSecondaryTitle(stateObj: HassEntity): string {