Update hui-media-control-card.ts (#4919)

This commit is contained in:
Bram Kragten 2020-02-19 10:44:42 +01:00 committed by GitHub
parent 23f34fa7ae
commit 924c7804c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {