Skip to content

Commit

Permalink
Minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
benct committed Jun 9, 2020
1 parent 0fca179 commit 4d68ab0
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions multiple-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const html = LitElement.prototype.html;
const css = LitElement.prototype.css;

const UNAVAILABLE = "unavailable";
const UNKNOWN = "unknown";
const UNAVAILABLE = 'unavailable';
const UNKNOWN = 'unknown';

class MultipleEntityRow extends LitElement {

Expand Down Expand Up @@ -117,7 +117,7 @@
}

renderTimestamp(value, format) {
return !['unknown', 'unavailable'].includes(value.toLowerCase())
return ![UNKNOWN, UNAVAILABLE].includes(value.toLowerCase())
? html`<hui-timestamp-display .ts=${new Date(value)} .format=${format} .hass=${this._hass}></hui-timestamp-display>`
: html`${value}`;
}
Expand Down Expand Up @@ -242,7 +242,7 @@
return `${stateObj.state} ${unit || stateObj.attributes.unit_of_measurement}`;
}

const domain = stateObj.entity_id.substr(0, stateObj.entity_id.indexOf("."));
const domain = stateObj.entity_id.substr(0, stateObj.entity_id.indexOf('.'));

if (domain === 'zwave') {
return ['initializing', 'dead'].includes(stateObj.state)
Expand All @@ -251,15 +251,10 @@
}

return (
// Return device class translation
(stateObj.attributes.device_class &&
this._hass.localize(
`component.${domain}.state.${stateObj.attributes.device_class}.${stateObj.state}`
)) ||
// Return default translation
this._hass.localize(`component.${domain}.state._.${stateObj.state}`) ||
// We don't know! Return the raw state.
stateObj.state
(stateObj.attributes.device_class
&& this._hass.localize(`component.${domain}.state.${stateObj.attributes.device_class}.${stateObj.state}`))
|| this._hass.localize(`component.${domain}.state._.${stateObj.state}`)
|| stateObj.state
);
}

Expand Down

0 comments on commit 4d68ab0

Please sign in to comment.