diff --git a/numberbox-card.js b/numberbox-card.js index 8020a15..0498940 100644 --- a/numberbox-card.js +++ b/numberbox-card.js @@ -1,6 +1,6 @@ ((LitElement) => { -console.info('NUMBERBOX_CARD 4.11'); +console.info('NUMBERBOX_CARD 4.12'); const html = LitElement.prototype.html; const css = LitElement.prototype.css; class NumberBox extends LitElement { @@ -84,11 +84,13 @@ secondaryInfo(){ while(j.length){ let t=j.shift(); if(t[0]=='%'){ + let f=NaN; t=t.substring(1).split(':'); let b=this._hass.states; for (let d=0; d1){t[d]=t[d].replace('-','_');} const id = t[d]; + if(id[0]=='~'){f=Number(id.substring(1));break;} if(b.hasOwnProperty(id)){ b=b[id]; if(!d){ @@ -107,7 +109,7 @@ secondaryInfo(){ } } } - ret += (typeof b !== 'object')? b : t; + ret += (typeof b !== 'object')? (isNaN(f)?b:b.toFixed(f)) : t; }else{ ret += t; }