Skip to content

Commit 969acb3

Browse files
committed
fix(#60): handle boolean autoconfig option
1 parent aca7599 commit 969acb3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/ha-sankey-chart.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ export class SankeyChart extends SubscribeMixin(LitElement) {
8484
}, ENERGY_DATA_TIMEOUT * 2);
8585
return [
8686
energyPromise.then(async collection => {
87-
if (typeof this.config.autoconfig === 'object' && !this.config.sections.length) {
87+
const isAutoconfig = this.config.autoconfig || typeof this.config.autoconfig === 'object';
88+
if (isAutoconfig && !this.config.sections.length) {
8889
await this.autoconfig(collection);
8990
}
9091
return collection.subscribe(async data => {
91-
if (typeof this.config.autoconfig === 'object' && !this.config.sections.length) {
92+
if (isAutoconfig && !this.config.sections.length) {
9293
await this.autoconfig(collection);
9394
}
9495
const stats = await getStatistics(this.hass, data, this.entityIds);

src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export function getChildConnections(parent: Box, children: Box[], connections?:
8888
export function normalizeConfig(conf: SankeyChartConfig): Config {
8989
let config = { sections: [], ...cloneObj(conf) };
9090

91-
if (typeof conf.autoconfig === 'object') {
91+
const { autoconfig } = conf;
92+
if (autoconfig || typeof autoconfig === 'object') {
9293
config = {
9394
energy_date_selection: true,
9495
unit_prefix: 'k',

0 commit comments

Comments
 (0)