From f25dbd4dee117ab9928b3d424fb4ce92ddcf29b0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 21 May 2020 12:41:01 +0000 Subject: [PATCH] Fix attempt for 0.110 --- src/decluttering-card.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/decluttering-card.ts b/src/decluttering-card.ts index fcc171a..b3d1ebb 100644 --- a/src/decluttering-card.ts +++ b/src/decluttering-card.ts @@ -26,7 +26,17 @@ class DeclutteringCard extends LitElement { private _hass?: HomeAssistant; + private _type?: 'element' | 'card'; + set hass(hass: HomeAssistant) { + if (!hass) return; + if (!this._hass && hass) { + this._createCard(this._config!, this._type!).then(card => { + this._card = card; + this._card && this._ro?.observe(this._card); + return this._card; + }); + } this._hass = hass; if (this._card) { this._card.hass = hass; @@ -75,12 +85,7 @@ class DeclutteringCard extends LitElement { this._displayHidden(); }); this._config = deepReplace(config.variables, templateConfig); - const type = templateConfig.card ? 'card' : 'element'; - this._createCard(this._config, type).then(card => { - this._card = card; - this._ro?.observe(this._card); - return this._card; - }); + this._type = templateConfig.card ? 'card' : 'element'; } protected render(): TemplateResult | void {