mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Love: Fix stateObj not in states error (#1322)
* Love: Fix stateObj not in states error * Add () * Make it dynamic
This commit is contained in:
parent
d5266c1c56
commit
8d5c862908
@ -28,12 +28,15 @@ class HuiCameraPreviewCard extends PolymerElement {
|
||||
if (this.lastChild) {
|
||||
this.removeChild(this.lastChild);
|
||||
}
|
||||
const entityId = config && config.entity;
|
||||
if (entityId && !(entityId in this.hass.states)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let error = null;
|
||||
let cardConfig;
|
||||
let tag;
|
||||
|
||||
const entityId = config && config.entity;
|
||||
if (entityId) {
|
||||
if (computeDomain(entityId) === 'camera') {
|
||||
this._entityId = entityId;
|
||||
@ -62,11 +65,13 @@ class HuiCameraPreviewCard extends PolymerElement {
|
||||
}
|
||||
|
||||
_hassChanged(hass) {
|
||||
if (this.lastChild && this._entityId) {
|
||||
if (this.lastChild && this._entityId && this._entityId in hass.states) {
|
||||
const element = this.lastChild;
|
||||
const stateObj = hass.states[this._entityId];
|
||||
element.stateObj = stateObj;
|
||||
element.hass = hass;
|
||||
} else {
|
||||
this._configChanged(this.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ class HuiEntitiesCard extends EventsMixin(PolymerElement) {
|
||||
|
||||
for (let i = 0; i < config.entities.length; i++) {
|
||||
const entityId = config.entities[i];
|
||||
if (!(entityId in this.hass.states)) continue;
|
||||
const stateObj = this.hass.states[entityId];
|
||||
const tag = stateObj ? `state-card-${stateCardType(this.hass, stateObj)}` : 'state-card-display';
|
||||
const element = document.createElement(tag);
|
||||
|
@ -28,12 +28,15 @@ class HuiHistoryGraphCard extends PolymerElement {
|
||||
if (this.lastChild) {
|
||||
this.removeChild(this.lastChild);
|
||||
}
|
||||
const entityId = config && config.entity;
|
||||
if (entityId && !(entityId in this.hass.states)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let error = null;
|
||||
let cardConfig;
|
||||
let tag;
|
||||
|
||||
const entityId = config && config.entity;
|
||||
if (entityId) {
|
||||
if (computeDomain(entityId) === 'history_graph') {
|
||||
this._entityId = entityId;
|
||||
@ -62,11 +65,13 @@ class HuiHistoryGraphCard extends PolymerElement {
|
||||
}
|
||||
|
||||
_hassChanged(hass) {
|
||||
if (this.lastChild && this._entityId) {
|
||||
if (this.lastChild && this._entityId && this._entityId in hass.states) {
|
||||
const element = this.lastChild;
|
||||
const stateObj = hass.states[this._entityId];
|
||||
element.stateObj = stateObj;
|
||||
element.hass = hass;
|
||||
} else {
|
||||
this._configChanged(this.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,15 @@ class HuiMediaControlCard extends PolymerElement {
|
||||
if (this.lastChild) {
|
||||
this.removeChild(this.lastChild);
|
||||
}
|
||||
const entityId = config && config.entity;
|
||||
if (entityId && !(entityId in this.hass.states)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let error = null;
|
||||
let cardConfig;
|
||||
let tag;
|
||||
|
||||
const entityId = config && config.entity;
|
||||
if (entityId) {
|
||||
if (computeDomain(entityId) === 'media_player') {
|
||||
this._entityId = entityId;
|
||||
@ -62,11 +65,13 @@ class HuiMediaControlCard extends PolymerElement {
|
||||
}
|
||||
|
||||
_hassChanged(hass) {
|
||||
if (this.lastChild && this._entityId) {
|
||||
if (this.lastChild && this._entityId && this._entityId in hass.states) {
|
||||
const element = this.lastChild;
|
||||
const stateObj = hass.states[this._entityId];
|
||||
element.stateObj = stateObj;
|
||||
element.hass = hass;
|
||||
} else {
|
||||
this._configChanged(this.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,15 @@ class HuiPlantStatusCard extends PolymerElement {
|
||||
if (this.lastChild) {
|
||||
this.removeChild(this.lastChild);
|
||||
}
|
||||
const entityId = config && config.entity;
|
||||
if (entityId && !(entityId in this.hass.states)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let error = null;
|
||||
let cardConfig;
|
||||
let tag;
|
||||
|
||||
const entityId = config && config.entity;
|
||||
if (entityId) {
|
||||
if (computeDomain(entityId) === 'plant') {
|
||||
this._entityId = entityId;
|
||||
@ -62,11 +65,13 @@ class HuiPlantStatusCard extends PolymerElement {
|
||||
}
|
||||
|
||||
_hassChanged(hass) {
|
||||
if (this.lastChild && this._entityId) {
|
||||
if (this.lastChild && this._entityId && this._entityId in hass.states) {
|
||||
const element = this.lastChild;
|
||||
const stateObj = hass.states[this._entityId];
|
||||
element.stateObj = stateObj;
|
||||
element.hass = hass;
|
||||
} else {
|
||||
this._configChanged(this.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,15 @@ class HuiWeatherForecastCard extends PolymerElement {
|
||||
if (this.lastChild) {
|
||||
this.removeChild(this.lastChild);
|
||||
}
|
||||
const entityId = config && config.entity;
|
||||
if (entityId && !(entityId in this.hass.states)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let error = null;
|
||||
let cardConfig;
|
||||
let tag;
|
||||
|
||||
const entityId = config && config.entity;
|
||||
if (entityId) {
|
||||
if (computeDomain(entityId) === 'weather') {
|
||||
this._entityId = entityId;
|
||||
@ -62,11 +65,13 @@ class HuiWeatherForecastCard extends PolymerElement {
|
||||
}
|
||||
|
||||
_hassChanged(hass) {
|
||||
if (this.lastChild && this._entityId) {
|
||||
if (this.lastChild && this._entityId && this._entityId in hass.states) {
|
||||
const element = this.lastChild;
|
||||
const stateObj = hass.states[this._entityId];
|
||||
element.stateObj = stateObj;
|
||||
element.hass = hass;
|
||||
} else {
|
||||
this._configChanged(this.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user