Skip to content

Commit f4da92d

Browse files
committed
Minor code improvements and formatting
1 parent 9ad40b6 commit f4da92d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/entity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const entityStateDisplay = (hass, stateObj, config) => {
6767
} else if (config.format === 'celsius_to_fahrenheit') {
6868
value = formatNumber(value * 1.8 + 32, hass.locale, { maximumFractionDigits: 0 });
6969
} else if (config.format === 'fahrenheit_to_celsius') {
70-
value = formatNumber((value - 32) * 5 / 9, hass.locale, { maximumFractionDigits: 1 });
70+
value = formatNumber(((value - 32) * 5) / 9, hass.locale, { maximumFractionDigits: 1 });
7171
}
7272
return `${value}${unit ? ` ${unit}` : ''}`;
7373
}

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ class MultipleEntityRow extends LitElement {
134134
></ha-relative-time>`;
135135
}
136136
if (config.format && TIMESTAMP_FORMATS.includes(config.format)) {
137-
const value = config.attribute ? stateObj.attributes[config.attribute] : stateObj.state;
137+
const value = config.attribute
138+
? stateObj.attributes[config.attribute] ?? stateObj[config.attribute]
139+
: stateObj.state;
138140
const timestamp = new Date(value);
139141
if (!(timestamp instanceof Date) || isNaN(timestamp.getTime())) {
140142
return value;

0 commit comments

Comments
 (0)