Skip to content

Commit 325abfc

Browse files
committed
feat(#303): reuse energy dashboard colors for device nodes in autoconfig
1 parent 03c6b60 commit 325abfc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ha-sankey-chart.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ console.info(
4646

4747
const ENERGY_DATA_TIMEOUT = 10000;
4848

49-
type DeviceNode = { id: string; name?: string; parent?: string };
49+
type DeviceNode = { id: string; name?: string; parent?: string; color?: string };
5050

5151
@customElement('sankey-chart')
5252
class SankeyChart extends SubscribeMixin(LitElement) {
@@ -245,6 +245,7 @@ class SankeyChart extends SubscribeMixin(LitElement) {
245245
id: device.stat_consumption,
246246
name: device.name,
247247
parent: device.included_in_stat,
248+
color: `var(--color-${(idx % 54) + 1})`,
248249
};
249250
if (node.parent) {
250251
parentLinks[node.id] = node.parent;
@@ -433,6 +434,7 @@ class SankeyChart extends SubscribeMixin(LitElement) {
433434
section: currentSection,
434435
type: 'entity',
435436
name: d.name || '',
437+
color: d.color,
436438
});
437439
const children = deviceSections[i + 1]?.filter(c => c.parent === d.id);
438440
children?.forEach(c => {

0 commit comments

Comments
 (0)