Skip to content

Commit

Permalink
fix: When recorder was skipped, attributes were ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Jul 4, 2021
1 parent 7591aba commit 15e5372
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,18 @@ export default class GraphEntry {
this._updating = true;

if (this._config.ignore_history) {
let currentState: null | number | string = this._entityState.state;
let currentState: null | number | string = null;
if (this._config.attribute) {
currentState = this._entityState.attributes?.[this._config.attribute];
} else {
currentState = this._entityState.state;
}
if (this._config.transform) {
currentState = this._applyTransform(currentState, this._entityState);
}
this._computedHistory = [[new Date(this._entityState.last_updated).getTime(), Number(currentState)]];
let stateParsed: number | null = parseFloat(currentState as string);
stateParsed = !Number.isNaN(stateParsed) ? stateParsed : null;
this._computedHistory = [[new Date(this._entityState.last_updated).getTime(), stateParsed]];
this._updating = false;
return true;
}
Expand Down

0 comments on commit 15e5372

Please sign in to comment.