From e2003234f0b5a620c60a4a3e197c3b9577fd51ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Wiedemann?= Date: Tue, 9 Mar 2021 11:08:12 +0000 Subject: [PATCH] fix: graph might be wrong when using `attributes` if value was 0 --- src/graphEntry.ts | 6 ++---- src/types.ts | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/graphEntry.ts b/src/graphEntry.ts index 0d9cdb7..47e285d 100644 --- a/src/graphEntry.ts +++ b/src/graphEntry.ts @@ -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; diff --git a/src/types.ts b/src/types.ts index cf7ab78..c5dbb07 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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 {