Skip to content

Commit

Permalink
Merge pull request #263 from FragMenthor/patch-1
Browse files Browse the repository at this point in the history
Format floating point hours as time duration: Update entity.js
  • Loading branch information
benct authored May 30, 2023
2 parents c0dbcfe + abaf243 commit 0cfc0a3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ export const entityStateDisplay = (hass, stateObj, config) => {
} else if (config.format === 'brightness') {
value = Math.round((value / 255) * 100);
unit = '%';
} else if (config.format.startsWith('duration')) {
value = secondsToDuration(config.format === 'duration-m' ? value / 1000 : value);
} else if (config.format === 'duration') {
value = secondsToDuration(value);
unit = undefined;
} else if (config.format === 'duration-m') {
value = secondsToDuration(value / 1000);
unit = undefined;
} else if (config.format === 'duration-h') {
value = secondsToDuration(value * 3600);
unit = undefined;
} else if (config.format.startsWith('precision')) {
const precision = parseInt(config.format.slice(-1), 10);
Expand Down

0 comments on commit 0cfc0a3

Please sign in to comment.