Skip to content

Commit

Permalink
fix: graph might be wrong when using attributes if value was 0
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Mar 9, 2021
1 parent 0492fe1 commit e200323
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,8 @@ export default class GraphEntry {
const newStateHistory: EntityCachePoints = newHistory[0].map((item) => {
let currentState: unknown = null;
if (this._config.attribute) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (item.attributes && item.attributes![this._config.attribute]) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
currentState = item.attributes![this._config.attribute];
if (item.attributes && item.attributes[this._config.attribute] !== undefined) {
currentState = item.attributes[this._config.attribute];
}
} else {
currentState = item.state;
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export interface HassHistoryEntry {
last_updated: string;
state: string;
last_changed: string;
attributes?: never;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
attributes?: any;
}

export interface HistoryBucket {
Expand Down

0 comments on commit e200323

Please sign in to comment.