Fix console errors in LL when entities are unavailable. (#1734)

This commit is contained in:
Jerad Meisner 2018-10-04 00:44:01 -07:00 committed by Paulus Schoutsen
parent 0243632357
commit a76386b53b
5 changed files with 9 additions and 3 deletions

View File

@ -125,7 +125,7 @@ class HuiInputNumberEntityRow extends mixinBehaviors([IronResizableBehavior], Po
}
_hiddenState() {
if (!this.$ || this._stateObj.attributes.mode !== 'slider') return;
if (!this.$ || !this._stateObj || this._stateObj.attributes.mode !== 'slider') return;
const width = this.$.input_number_card.offsetWidth;
const stateEl = this.shadowRoot.querySelector('.state');
if (!stateEl) return;
@ -133,6 +133,8 @@ class HuiInputNumberEntityRow extends mixinBehaviors([IronResizableBehavior], Po
}
_stateObjChanged(stateObj, oldStateObj) {
if (!stateObj) return;
this.setProperties({
_min: Number(stateObj.attributes.min),
_max: Number(stateObj.attributes.max),

View File

@ -57,7 +57,7 @@ class HuiInputTextEntityRow extends PolymerElement {
}
_stateObjChanged(stateObj) {
this._value = stateObj.state;
this._value = stateObj && stateObj.state;
}
_selectedValueChanged() {

View File

@ -89,6 +89,8 @@ class HuiMediaPlayerEntityRow extends LocalizeMixin(PolymerElement) {
}
_computeControlIcon(stateObj) {
if (!stateObj) return null;
if (stateObj.state !== 'playing') {
return stateObj.attributes.supported_features & SUPPORTS_PLAY ? 'hass:play' : '';
}

View File

@ -64,7 +64,7 @@ class HuiTextEntityRow extends LocalizeMixin(PolymerElement) {
}
_computeState(stateObj) {
return computeStateDisplay(this.localize, stateObj);
return stateObj && computeStateDisplay(this.localize, stateObj);
}
}
customElements.define('hui-text-entity-row', HuiTextEntityRow);

View File

@ -73,6 +73,8 @@ class HuiTimerEntityRow extends PolymerElement {
}
_computeDisplay(stateObj, time) {
if (!stateObj) return null;
if (stateObj.state === 'idle' || time === 0) return stateObj.state;
let display = secondsToDuration(time);