From 1632af7425d835a0dbfab7e417858c4482a5542e Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Fri, 9 Feb 2024 18:39:18 +1030 Subject: [PATCH 1/2] add: state sum to see sum of available points --- src/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 43f806d..28295ae 100644 --- a/src/main.js +++ b/src/main.js @@ -276,7 +276,9 @@ class MiniGraphCard extends LitElement { getEntityState(id) { const entityConfig = this.config.entities[id]; - if (this.config.show.state === 'last') { + if (this.config.show.state === 'sum') { + return this.points[id].reduce((sum, point) => sum + point[V], 0) + } else if (this.config.show.state === 'last') { return this.points[id][this.points[id].length - 1][V]; } else if (entityConfig.attribute) { return this.getObjectAttr(this.entity[id].attributes, entityConfig.attribute); From 2e2ee9ec3e8bb73301e1e648deaaf7889b98c07b Mon Sep 17 00:00:00 2001 From: Jason Lewis Date: Fri, 9 Feb 2024 18:42:40 +1030 Subject: [PATCH 2/2] fix: missing semi colon --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 28295ae..85bb78c 100644 --- a/src/main.js +++ b/src/main.js @@ -277,7 +277,7 @@ class MiniGraphCard extends LitElement { getEntityState(id) { const entityConfig = this.config.entities[id]; if (this.config.show.state === 'sum') { - return this.points[id].reduce((sum, point) => sum + point[V], 0) + return this.points[id].reduce((sum, point) => sum + point[V], 0); } else if (this.config.show.state === 'last') { return this.points[id][this.points[id].length - 1][V]; } else if (entityConfig.attribute) {