From 4d68ab0f499e84d70c0d89d67e168f9d4743235a Mon Sep 17 00:00:00 2001 From: benct Date: Tue, 9 Jun 2020 15:19:17 +0200 Subject: [PATCH] Minor formatting changes --- multiple-entity-row.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/multiple-entity-row.js b/multiple-entity-row.js index 9191e59..541e9f4 100644 --- a/multiple-entity-row.js +++ b/multiple-entity-row.js @@ -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 { @@ -117,7 +117,7 @@ } renderTimestamp(value, format) { - return !['unknown', 'unavailable'].includes(value.toLowerCase()) + return ![UNKNOWN, UNAVAILABLE].includes(value.toLowerCase()) ? html`` : html`${value}`; } @@ -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) @@ -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 ); }