Skip to content

Commit 0cfc0a3

Browse files
authored
Merge pull request #263 from FragMenthor/patch-1
Format floating point hours as time duration: Update entity.js
2 parents c0dbcfe + abaf243 commit 0cfc0a3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/entity.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@ export const entityStateDisplay = (hass, stateObj, config) => {
4343
} else if (config.format === 'brightness') {
4444
value = Math.round((value / 255) * 100);
4545
unit = '%';
46-
} else if (config.format.startsWith('duration')) {
47-
value = secondsToDuration(config.format === 'duration-m' ? value / 1000 : value);
46+
} else if (config.format === 'duration') {
47+
value = secondsToDuration(value);
48+
unit = undefined;
49+
} else if (config.format === 'duration-m') {
50+
value = secondsToDuration(value / 1000);
51+
unit = undefined;
52+
} else if (config.format === 'duration-h') {
53+
value = secondsToDuration(value * 3600);
4854
unit = undefined;
4955
} else if (config.format.startsWith('precision')) {
5056
const precision = parseInt(config.format.slice(-1), 10);

0 commit comments

Comments
 (0)