Skip to content

Commit

Permalink
Merge pull request #103 from htmltiger/htmltiger-patch-1
Browse files Browse the repository at this point in the history
display value math template
  • Loading branch information
htmltiger authored Oct 25, 2023
2 parents 4145129 + eb73b47 commit 64b9aff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ or added by clicking the "Add to lovelace" button on the HACS dashboard after in
| speed | number | `0` | long press speed in ms, `0` to disable
| refresh | number | `0` | `1` to disable debounce when change, may fix issues with updating
| secondary_info | string | | `last_changed` `last_updated` or any text/html,<br />you can also display states or other attributes of any entity for eg. <br /> `Light is %light.office_1:state` <br />`Room temp is %climate.heating:attributes:current_temperature:~1` (:~x digits after decimal) <br />`%switch.switch_2:last_updated`
| unit | string/bool | `unit_of_measurement` | Override unit string (set to `false` to hide) <br />`time` to display the number in hh:mm:ss<br />`timehm` to display the number in hh:mm
| unit | string/bool | `unit_of_measurement` | Override unit string (set to `false` to hide) <br />`time` to display the number in hh:mm:ss<br />`timehm` to display the number in hh:mm<br />to use javascript on state value use brackets to eval for eg. `(value*100)` to change the display value

#### Advanced Config for climate/fan/input_datetime etc

Expand Down
7 changes: 6 additions & 1 deletion numberbox-card.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
((LitElement) => {

console.info('NUMBERBOX_CARD 4.14');
console.info('NUMBERBOX_CARD 4.15');
const html = LitElement.prototype.html;
const css = LitElement.prototype.css;
class NumberBox extends LitElement {
Expand Down Expand Up @@ -253,6 +253,11 @@ niceNum(){
return html`${t}`;
}
if(isNaN(Number(fix))){return fix;}
if(typeof u == 'string' && u.startsWith('(')){
let value = fix; value = eval(u);
return html`${value}`;
}

const lang={language:this._hass.language, comma_decimal:['en-US','en'], decimal_comma:['de','es','it'], space_comma:['fr','sv','cs'], system:undefined};
let g=this._hass.locale.number_format || 'language';
if(g!='none'){
Expand Down

0 comments on commit 64b9aff

Please sign in to comment.