Skip to content

Commit

Permalink
Merge pull request #21 from fsteccanella/fsteccanella-patch-1
Browse files Browse the repository at this point in the history
Cast to Number only if !isNaN
  • Loading branch information
Gluwc authored Aug 20, 2019
2 parents 1a9ffb1 + cd3c2ea commit 3847c56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bar-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -1011,11 +1011,16 @@ class BarCard extends HTMLElement {
} else {
entityState = entityObject.state
}
if (config.limit_value && !isNaN(entityState)) {

if(!isNaN(entityState)){
entityState = Number(entityState)
}

if (config.limit_value) {
entityState = Math.min(entityState, configMax)
entityState = Math.max(entityState, configMin)
}
entityState = Number(entityState)

if (config.decimal !== false) {
entityState.toFixed(config.decimal)
}
Expand Down

0 comments on commit 3847c56

Please sign in to comment.