Skip to content

Commit 2d643e3

Browse files
Add Fahrenheit to Celsius and Celsius to Fahrenheit formatter
1 parent e2d2508 commit 2d643e3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/entity.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export const entityStateDisplay = (hass, stateObj, config) => {
5858
value = formatNumber(value - value * 2, hass.locale);
5959
} else if (config.format === 'position') {
6060
value = formatNumber(100 - value, hass.locale);
61+
} else if (config.format === 'celsius_to_fahrenheit') {
62+
value = formatNumber(value * 1.8 + 32, hass.locale, { maximumFractionDigits: 0 });
63+
} else if (config.format === 'fahrenheit_to_celsius') {
64+
value = formatNumber((value - 32) * 5 / 9, hass.locale, { maximumFractionDigits: 1 });
6165
}
6266
return `${value}${unit ? ` ${unit}` : ''}`;
6367
}

0 commit comments

Comments
 (0)