File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ export interface EnergySource {
7373// eslint-disable-next-line @typescript-eslint/no-empty-interface
7474export interface DeviceConsumptionEnergyPreference {
7575 stat_consumption : string ;
76+ name ?: string ;
7677}
7778
7879export interface EnergyPreferences {
Original file line number Diff line number Diff line change @@ -197,15 +197,19 @@ class SankeyChart extends SubscribeMixin(LitElement) {
197197 }
198198 return 1 ;
199199 } ) ;
200+ const names : Record < string , string > = { } ;
200201 const deviceIds = ( collection . prefs ?. device_consumption || [ ] )
201- . map ( d => d . stat_consumption )
202- . filter ( id => {
203- if ( ! this . hass . states [ id ] ) {
204- console . warn ( 'Ignoring missing entity ' + id ) ;
202+ . filter ( d => {
203+ if ( ! this . hass . states [ d . stat_consumption ] ) {
204+ console . warn ( 'Ignoring missing entity ' + d . stat_consumption ) ;
205205 return false ;
206206 }
207+ if ( d . name ) {
208+ names [ d . stat_consumption ] = d . name ;
209+ }
207210 return true ;
208- } ) ;
211+ } )
212+ . map ( d => d . stat_consumption ) ;
209213 const areasResult = await getEntitiesByArea ( this . hass , deviceIds ) ;
210214 const areas = Object . values ( areasResult )
211215 // put 'No area' last
@@ -260,6 +264,7 @@ class SankeyChart extends SubscribeMixin(LitElement) {
260264 entities : orderedDeviceIds . map ( id => ( {
261265 entity_id : id ,
262266 type : 'entity' ,
267+ name : names [ id ] ,
263268 children : [ ] ,
264269 } ) ) ,
265270 } ,
You can’t perform that action at this time.
0 commit comments