@@ -762,8 +762,13 @@ class BarCard extends HTMLElement {
762
762
const maxValue = this . _valueEntityCheck ( this . _maxCheck ( entity , hass , index ) , hass )
763
763
const barElement = this . shadowRoot . getElementById ( 'bar_' + id )
764
764
765
- barElement . style . setProperty ( '--bar-percent' , `${ this . _translatePercent ( entityState , minValue , maxValue , index , entity ) } %` )
766
- barElement . style . setProperty ( '--bar-charge-percent' , `${ this . _translatePercent ( entityState , minValue , maxValue , index , entity ) } %` )
765
+ if ( ! isNaN ( entityState ) ) {
766
+ barElement . style . setProperty ( '--bar-percent' , `${ this . _translatePercent ( entityState , minValue , maxValue , index , entity ) } %` )
767
+ barElement . style . setProperty ( '--bar-charge-percent' , `${ this . _translatePercent ( entityState , minValue , maxValue , index , entity ) } %` )
768
+ } else {
769
+ barElement . style . setProperty ( '--bar-percent' , `100%` )
770
+ barElement . style . setProperty ( '--bar-charge-percent' , `100%` )
771
+ }
767
772
}
768
773
769
774
// Create animation
@@ -1052,14 +1057,16 @@ class BarCard extends HTMLElement {
1052
1057
if ( entityState !== this . _entityState [ id ] ) {
1053
1058
const barColor = this . _calculateBarColor ( config , entityState , hass )
1054
1059
1055
- if ( config . visibility !== false ) {
1056
- if ( entityState == 'N/A' || config . visibility == true ) {
1057
- root . getElementById ( 'card_' + id ) . style . setProperty ( '--card-display' , 'visible' )
1058
- } else {
1059
- if ( eval ( entityState + " " + config . visibility ) ) {
1060
+ if ( ! isNaN ( entityState ) ) {
1061
+ if ( config . visibility !== false ) {
1062
+ if ( entityState == 'N/A' || config . visibility == true ) {
1060
1063
root . getElementById ( 'card_' + id ) . style . setProperty ( '--card-display' , 'visible' )
1061
1064
} else {
1062
- root . getElementById ( 'card_' + id ) . style . setProperty ( '--card-display' , 'none' )
1065
+ if ( eval ( entityState + " " + config . visibility ) ) {
1066
+ root . getElementById ( 'card_' + id ) . style . setProperty ( '--card-display' , 'visible' )
1067
+ } else {
1068
+ root . getElementById ( 'card_' + id ) . style . setProperty ( '--card-display' , 'none' )
1069
+ }
1063
1070
}
1064
1071
}
1065
1072
}
@@ -1190,7 +1197,7 @@ class BarCard extends HTMLElement {
1190
1197
customElements . define ( 'bar-card' , BarCard )
1191
1198
1192
1199
console . info (
1193
- `%cBAR-CARD\n%cVersion: 1.5.2 ` ,
1200
+ `%cBAR-CARD\n%cVersion: 1.5.4 ` ,
1194
1201
"color: green; font-weight: bold;" ,
1195
1202
""
1196
1203
) ;
0 commit comments