Skip to content

Commit cf917cc

Browse files
committed
fix: fix for missing entities
1 parent 8912542 commit cf917cc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/chart.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ export class Chart extends LitElement {
415415
}
416416

417417
let entity = this.states[getEntityId(entityConf)];
418+
if (!entity) {
419+
throw new Error('Entity not found ' + getEntityId(entityConf));
420+
}
418421

419422
if (entityConf.type === 'passthrough') {
420423
const connections = this.connectionsByChild.get(entityConf);

src/ha-sankey-chart.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export class SankeyChart extends SubscribeMixin(LitElement) {
7373
const stats = await getStatistics(this.hass, data, this.entityIds);
7474
const states: HassEntities = {};
7575
Object.keys(stats).forEach(id => {
76-
states[id] = {...this.hass.states[id], state: String(stats[id])};
76+
if (this.hass.states[id]) {
77+
states[id] = {...this.hass.states[id], state: String(stats[id])};
78+
}
7779
});
7880
this.states = states;
7981
// this.requestUpdate();

0 commit comments

Comments
 (0)