Skip to content

Commit df63b1f

Browse files
committed
fix(#60): fix for grid export in autoconfig
1 parent f498714 commit df63b1f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/ha-sankey-chart.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,17 @@ export class SankeyChart extends SubscribeMixin(LitElement) {
260260
const grid = sources.find(s => s.type === 'grid');
261261
if (grid && grid?.flow_to?.length) {
262262
// grid export
263-
sections[1].entities.unshift({
264-
entity_id: grid.flow_to[0].stat_energy_to,
265-
substract_entities: (grid.flow_from || []).map(e => e.stat_energy_from),
266-
type: 'entity',
267-
color: getEnergySourceColor(grid.type),
268-
children: [],
269-
});
270-
sections[0].entities.forEach(entity => {
271-
entity.children.unshift(grid.stat_energy_to!);
263+
grid?.flow_to.forEach(({stat_energy_to}) => {
264+
sections[1].entities.unshift({
265+
entity_id: stat_energy_to,
266+
substract_entities: (grid.flow_from || []).map(e => e.stat_energy_from),
267+
type: 'entity',
268+
color: getEnergySourceColor(grid.type),
269+
children: [],
270+
});
271+
sections[0].entities.forEach(entity => {
272+
entity.children.unshift(stat_energy_to);
273+
});
272274
});
273275
}
274276

0 commit comments

Comments
 (0)