diff --git a/src/panels/lovelace/cards/hui-camera-preview-card.js b/src/panels/lovelace/cards/hui-camera-preview-card.js index 75c0908b62..eb2262306c 100644 --- a/src/panels/lovelace/cards/hui-camera-preview-card.js +++ b/src/panels/lovelace/cards/hui-camera-preview-card.js @@ -2,8 +2,6 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import '../../../cards/ha-camera-card.js'; -import createCardElement from '../common/create-card-element.js'; -import createErrorCardConfig from '../common/create-error-card-config.js'; import validateEntityConfig from '../common/validate-entity-config.js'; class HuiCameraPreviewCard extends PolymerElement { @@ -13,10 +11,6 @@ class HuiCameraPreviewCard extends PolymerElement { type: Object, observer: '_hassChanged' }, - config: { - type: Object, - observer: '_configChanged' - } }; } @@ -24,20 +18,18 @@ class HuiCameraPreviewCard extends PolymerElement { return 4; } - _configChanged(config) { + setConfig(config) { + if (!validateEntityConfig(config, 'camera')) { + throw new Error('Error in card configuration.'); + } + + this._config = config; this._entityId = null; if (this.lastChild) { this.removeChild(this.lastChild); } - if (!validateEntityConfig(config, 'camera')) { - const error = 'Error in card configuration.'; - const element = createCardElement(createErrorCardConfig(error, config)); - this.appendChild(element); - return; - } - const entityId = config.entity; if (!(entityId in this.hass.states)) { return; @@ -56,8 +48,6 @@ class HuiCameraPreviewCard extends PolymerElement { const element = this.lastChild; element.stateObj = hass.states[entityId]; element.hass = hass; - } else { - this._configChanged(this.config); } } } diff --git a/src/panels/lovelace/cards/hui-column-card.js b/src/panels/lovelace/cards/hui-column-card.js index 499d4ada17..247bb34e25 100644 --- a/src/panels/lovelace/cards/hui-column-card.js +++ b/src/panels/lovelace/cards/hui-column-card.js @@ -3,7 +3,6 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import computeCardSize from '../common/compute-card-size.js'; import createCardElement from '../common/create-card-element.js'; -import createErrorConfig from '../common/create-error-card-config.js'; class HuiColumnCard extends PolymerElement { static get template() { @@ -29,10 +28,6 @@ class HuiColumnCard extends PolymerElement { type: Object, observer: '_hassChanged' }, - config: { - type: Object, - observer: '_configChanged' - } }; } @@ -41,6 +36,11 @@ class HuiColumnCard extends PolymerElement { this._elements = []; } + ready() { + super.ready(); + if (this._config) this._buildConfig(); + } + getCardSize() { let totalSize = 0; this._elements.forEach((element) => { @@ -49,7 +49,18 @@ class HuiColumnCard extends PolymerElement { return totalSize; } - _configChanged(config) { + setConfig(config) { + if (!config || !config.cards || !Array.isArray(config.cards)) { + throw new Error('Card config incorrect'); + } + + this._config = config; + if (this.$) this._buildConfig(); + } + + _buildConfig() { + const config = this._config; + this._elements = []; const root = this.$.root; @@ -57,13 +68,6 @@ class HuiColumnCard extends PolymerElement { root.removeChild(root.lastChild); } - if (!config || !config.cards || !Array.isArray(config.cards)) { - const error = 'Card config incorrect.'; - const element = createCardElement(createErrorConfig(error, config)); - root.appendChild(element); - return; - } - const elements = []; config.cards.forEach((card) => { const element = createCardElement(card); diff --git a/src/panels/lovelace/cards/hui-entities-card.js b/src/panels/lovelace/cards/hui-entities-card.js index 84811652f3..6edc11993d 100644 --- a/src/panels/lovelace/cards/hui-entities-card.js +++ b/src/panels/lovelace/cards/hui-entities-card.js @@ -50,9 +50,9 @@ class HuiEntitiesCard extends EventsMixin(PolymerElement) {
-
[[_computeTitle(config)]]
-