From c7642adfd7ad7d17a2eac4ed5ad0524763d28024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Kihlstr=C3=B6m?= Date: Sun, 8 May 2022 20:30:47 +0200 Subject: [PATCH] Ensure attributes are assigned before accessed --- src/model.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/model.ts b/src/model.ts index 28e3fb3..7501cd5 100644 --- a/src/model.ts +++ b/src/model.ts @@ -25,9 +25,9 @@ export default class MediaPlayerObject { this.config = config || {}; this.entity = entity || {}; this.state = entity.state; - this.idle = config.idle_view ? this.idleView : false; this._entityId = (entity && entity.entity_id) || this.config.entity; - this._attr = entity.attributes; + this._attr = entity.attributes || {}; + this.idle = config.idle_view ? this.idleView : false; this._active = this.isActive; }