@@ -329,36 +329,34 @@ class SankeyChart extends SubscribeMixin(LitElement) {
329329 . sort ( ( a , b ) => ( a . area . name === 'No area' ? 1 : b . area . name === 'No area' ? - 1 : 0 ) ) ;
330330
331331 const floors = await fetchFloorRegistry ( this . hass ) ;
332- if ( this . config . autoconfig ! . group_by_floor !== false ) {
333- const orphanAreas = areas . filter ( a => ! a . area . floor_id ) ;
334- if ( orphanAreas . length !== areas . length ) {
335- totalNode . children = [
336- ...totalNode . children ,
337- ...floors . map ( f => f . floor_id ) ,
338- ...( this . config . autoconfig ! . group_by_area === false
339- ? orphanAreas . map ( a => a . entities ) . flat ( )
340- : orphanAreas . map ( a => a . area . area_id ) ) ,
341- ] ;
342- sections . push ( {
343- entities : [
344- ...floors . map (
345- ( f ) : EntityConfigInternal => ( {
346- entity_id : f . floor_id ,
347- type : 'remaining_child_state' ,
348- name : f . name ,
349- children :
350- this . config . autoconfig ! . group_by_area === false
351- ? areas
352- . filter ( a => a . area . floor_id === f . floor_id )
353- . map ( a => a . entities )
354- . flat ( )
355- : areas . filter ( a => a . area . floor_id === f . floor_id ) . map ( a => a . area . area_id ) ,
356- } ) ,
357- ) ,
358- ] ,
359- sort_by : 'state' ,
360- } ) ;
361- }
332+ const orphanAreas = areas . filter ( a => ! a . area . floor_id ) ;
333+ if ( this . config . autoconfig ! . group_by_floor !== false && orphanAreas . length !== areas . length ) {
334+ totalNode . children = [
335+ ...totalNode . children ,
336+ ...floors . map ( f => f . floor_id ) ,
337+ ...( this . config . autoconfig ! . group_by_area === false
338+ ? orphanAreas . map ( a => a . entities ) . flat ( )
339+ : orphanAreas . map ( a => a . area . area_id ) ) ,
340+ ] ;
341+ sections . push ( {
342+ entities : [
343+ ...floors . map (
344+ ( f ) : EntityConfigInternal => ( {
345+ entity_id : f . floor_id ,
346+ type : 'remaining_child_state' ,
347+ name : f . name ,
348+ children :
349+ this . config . autoconfig ! . group_by_area === false
350+ ? areas
351+ . filter ( a => a . area . floor_id === f . floor_id )
352+ . map ( a => a . entities )
353+ . flat ( )
354+ : areas . filter ( a => a . area . floor_id === f . floor_id ) . map ( a => a . area . area_id ) ,
355+ } ) ,
356+ ) ,
357+ ] ,
358+ sort_by : 'state' ,
359+ } ) ;
362360 } else {
363361 totalNode . children = [ ...totalNode . children , ...areas . map ( a => a . area . area_id ) ] ;
364362 }
0 commit comments