Skip to content

Commit

Permalink
fixing get lastState (#1)
Browse files Browse the repository at this point in the history
* fixing get lastState

when using a data_generator, the current state is incorrecty reflected by always using the last historical value instead of the current state of the entity

Co-authored-by: bart.gerald <[email protected]>
  • Loading branch information
TheBrain8791 and bart.gerald authored Jan 15, 2023
1 parent 0518d3c commit 0bca7b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class GraphEntry {
}

get lastState(): number | null {
return this.history.length > 0 ? this.history[this.history.length - 1][1] : null;
return (this._entityState != undefined && this._entityState.state != undefined) ? Number(this._entityState.state) : null;
}

public nowValue(now: number, before: boolean): number | null {
Expand Down

0 comments on commit 0bca7b9

Please sign in to comment.