Skip to content

Commit

Permalink
Fix console errors in LL when entities are unavailable. (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeradM authored and balloob committed Oct 4, 2018
1 parent 0243632 commit a76386b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ 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;
stateEl.hidden = width <= 350;
}

_stateObjChanged(stateObj, oldStateObj) {
if (!stateObj) return;

this.setProperties({
_min: Number(stateObj.attributes.min),
_max: Number(stateObj.attributes.max),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HuiInputTextEntityRow extends PolymerElement {
}

_stateObjChanged(stateObj) {
this._value = stateObj.state;
this._value = stateObj && stateObj.state;
}

_selectedValueChanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/entity-rows/hui-text-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 2 additions & 0 deletions src/panels/lovelace/entity-rows/hui-timer-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a76386b

Please sign in to comment.