Skip to content

Commit d2c987d

Browse files
fix: connection_entity_id and add_entities/subtract_entities (#199)
* Fix connection_entity_id If a connection_entity_id was specified, it was not added to the list of entities for which to retrieve the state. It seems that connection_entity_id only happened to work if that entity_id was also used elsewhere. * Fix add_entities/subtract_entities normalization with unit conversion When converting energy units, all the conversions take place in energy.ts, and the results can be directly added together. However, when _getMemoizedState was adding the values of add_entities, it didn't realize that the entities to add were already the correct values, and it erroneously normalized them. Now, the same "this has already been converted" logic used for the main entity state is also used for the add_entity state. * PR comments
1 parent d5f9289 commit d2c987d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/chart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export class Chart extends LitElement {
241241
const { state } = normalizeStateValue(
242242
this.config.unit_prefix,
243243
Number(subEntity.state),
244-
subEntity.attributes.unit_of_measurement || unit_of_measurement,
244+
this._getUnitOfMeasurement(subEntity.attributes.unit_of_measurement || unit_of_measurement)
245245
);
246246
normalized.state += state;
247247
});
@@ -252,7 +252,7 @@ export class Chart extends LitElement {
252252
const { state } = normalizeStateValue(
253253
this.config.unit_prefix,
254254
Number(subEntity.state),
255-
subEntity.attributes.unit_of_measurement || unit_of_measurement,
255+
this._getUnitOfMeasurement(subEntity.attributes.unit_of_measurement || unit_of_measurement)
256256
);
257257
// stay positive
258258
normalized.state -= Math.min(state, normalized.state);

src/ha-sankey-chart.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ class SankeyChart extends SubscribeMixin(LitElement) {
154154
if (ent.type === 'entity') {
155155
this.entityIds.push(ent.entity_id);
156156
}
157+
ent.children.forEach(childConf => {
158+
if (typeof childConf === 'object' && childConf.connection_entity_id) {
159+
this.entityIds.push(childConf.connection_entity_id);
160+
}
161+
});
157162
if (ent.add_entities) {
158163
ent.add_entities.forEach(e => this.entityIds.push(e));
159164
}

0 commit comments

Comments
 (0)