Skip to content

Commit

Permalink
Fix custom state for sensor instead of last changed
Browse files Browse the repository at this point in the history
  • Loading branch information
DBuit committed Jul 31, 2020
1 parent f6513b4 commit 319aaa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions dist/homekit-panel-card.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/homekit-panel-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class HomeKitCard extends LitElement {
<span class=" ${offStates.includes(stateObj.state) ? 'value': 'value on'}">${this._renderStateValue(ent, stateObj, type)}</span>
`;
}
} else if((type == "sensor" || type == "binary_sensor") && stateObj.last_changed) {
} else if((type == "sensor" || type == "binary_sensor") && (stateObj.last_changed || ent.state)) {
if(this.statePositionTop) {
return this._renderCircleState(ent, stateObj, type);
} else {
Expand Down Expand Up @@ -241,8 +241,10 @@ class HomeKitCard extends LitElement {
${ent.state ? html`${computeStateDisplay(this.hass.localize, this.hass.states[ent.state], this.hass.language)}` : html``}
`;
} else if(type == "sensor" || type == "binary_sensor") {

return html`
${stateObj.last_changed ? html`${ this._calculateTime(stateObj.last_changed) }`:html``}
${stateObj.last_changed && !ent.state ? html`${ this._calculateTime(stateObj.last_changed) }` : html``}
${ent.state ? html`${computeStateDisplay(this.hass.localize, this.hass.states[ent.state], this.hass.language)}`:html``}
`;
} else if(type == "switch" || type =="input_boolean") {
return html`
Expand Down

0 comments on commit 319aaa6

Please sign in to comment.