Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
* Added `decimal` config option.
  • Loading branch information
Gluwc committed Aug 13, 2019
1 parent 22a4761 commit bcd4830
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Bar Card is a customizable animated card for the Home Assistant Lovelace front-e
| attribute | string | none | Attribute to be displayed.
| show_value | boolean | true | Hides value display when set to `false`.
| limit_value | boolean | false | Ensure the value is always within the minimum and maximum when set to `true`.
| show_minmax | boolean | false | Hides the minimum and maximum value when set to `false`.
| show_minmax | boolean | false | Shows the minimum and maximum value when set to `true`.
| decimal | number | false | The amount of decimals to be displayed for the value. Shows full number when set to `false`.
| unit_of_measurement | string | none | Unit of measurement to be displayed.
| color | string | var(--primary-color) | Color of the bar, can be any valid CSS color value or variable.
| title | string | friendly_name | Title displayed next to the bar.
Expand Down
5 changes: 5 additions & 0 deletions bar-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class BarCard extends HTMLElement {
if (!config.minmax_style) config.minmax_style = false
if (!config.background_style) config.background_style = false
if (!config.visibility) config.visibility = false
if (!config.decimal) config.decimal = false

// Check entity types
let updateArray
Expand Down Expand Up @@ -1010,6 +1011,10 @@ class BarCard extends HTMLElement {
entityState = Math.min(entityState, configMax)
entityState = Math.max(entityState, configMin)
}
entityState = Number(entityState)
if (config.decimal !== false) {
entityState.toFixed(config.decimal)
}
}

// Set measurement
Expand Down

0 comments on commit bcd4830

Please sign in to comment.