File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,5 +5,24 @@ lovelace:
55 type : module
66
77default_config :
8-
9- demo:
8+
9+ demo :
10+
11+ sensor :
12+ - platform : template
13+ sensors :
14+ pressure :
15+ friendly_name : " Pressure"
16+ unit_of_measurement : " hPa"
17+ value_template : " {{ state_attr('weather.home', 'pressure') }}"
18+ device_class : pressure
19+ temperature :
20+ friendly_name : " Temperature"
21+ unit_of_measurement : " °C"
22+ value_template : " {{ state_attr('weather.home', 'temperature') }}"
23+ device_class : temperature
24+ humidity :
25+ friendly_name : " Humidity"
26+ unit_of_measurement : " %"
27+ value_template : " {{ state_attr('weather.home', 'humidity') }}"
28+ device_class : humidity
Original file line number Diff line number Diff line change 33 cards :
44 - type : custom:mini-graph-card
55 entities :
6- - sensor.outside_humidity
6+ - sensor.humidity
7+ - type : custom:mini-graph-card
8+ entities :
9+ - sensor.temperature
10+ - type : custom:mini-graph-card
11+ entities :
12+ - sensor.pressure
13+ show :
14+ extrema : true
15+ # decimals: 10
Original file line number Diff line number Diff line change @@ -667,11 +667,26 @@ class MiniGraphCard extends LitElement {
667667 const dec = this . config . decimals ;
668668 const value_factor = 10 ** this . config . value_factor ;
669669
670- if ( dec === undefined || Number . isNaN ( dec ) || Number . isNaN ( state ) )
671- return Math . round ( state * value_factor * 100 ) / 100 ;
670+ if ( dec === undefined || Number . isNaN ( dec ) || Number . isNaN ( state ) ) {
671+ return this . numberFormat ( Math . round ( state * value_factor * 100 ) / 100 , this . _hass . language ) ;
672+ }
672673
673674 const x = 10 ** dec ;
674- return ( Math . round ( state * value_factor * x ) / x ) . toFixed ( dec ) ;
675+ return this . numberFormat (
676+ ( Math . round ( state * value_factor * x ) / x ) . toFixed ( dec ) ,
677+ this . _hass . language , dec ,
678+ ) ;
679+ }
680+
681+ numberFormat ( num , language , dec ) {
682+ if ( ! Number . isNaN ( Number ( num ) ) && Intl ) {
683+ if ( dec === undefined || Number . isNaN ( dec ) ) {
684+ return new Intl . NumberFormat ( language ) . format ( Number ( num ) ) ;
685+ } else {
686+ return new Intl . NumberFormat ( language , { minimumFractionDigits : dec } ) . format ( Number ( num ) ) ;
687+ }
688+ }
689+ return num . toString ( ) ;
675690 }
676691
677692 updateOnInterval ( ) {
You can’t perform that action at this time.
0 commit comments