From 38e96b4a9ad2f06642210f984cefadb863c4fbe0 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sat, 18 May 2024 14:59:13 +0100 Subject: [PATCH] Fix pounds calculation for savings (#1114) * Fix pounds calculation for savings * [pre-commit.ci lite] apply automatic fixes * Update example_chart.yml * Update predbat.py * Update example_chart.yml --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- apps/predbat/predbat.py | 12 +++++++----- templates/example_chart.yml | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index a834b52b..35e4e8de 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -28,7 +28,7 @@ if not "PRED_GLOBAL" in globals(): PRED_GLOBAL = {} -THIS_VERSION = "v7.19.2" +THIS_VERSION = "v7.19.3" PREDBAT_FILES = ["predbat.py"] TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z" @@ -13714,11 +13714,12 @@ def update_pred(self, scheduled=True): self.dashboard_item( self.prefix + ".savings_total_predbat", - state=self.dp2(savings_total_predbat / 100.0), + state=self.dp2(savings_total_predbat), attributes={ "friendly_name": "Total Predbat savings", "state_class": "measurement", - "unit_of_measurement": "£", + "unit_of_measurement": "p", + "pounds": self.dp2(savings_total_predbat / 100.0), "icon": "mdi:cash-multiple", }, ) @@ -13734,11 +13735,12 @@ def update_pred(self, scheduled=True): ) self.dashboard_item( self.prefix + ".savings_total_pvbat", - state=self.dp2(savings_total_pvbat / 100.0), + state=self.dp2(savings_total_pvbat), attributes={ "friendly_name": "Total Savings vs no PV/Battery system", "state_class": "measurement", - "unit_of_measurement": "£", + "unit_of_measurement": "p", + "pounds": self.dp2(savings_total_pvbat / 100.0), "icon": "mdi:cash-multiple", }, ) diff --git a/templates/example_chart.yml b/templates/example_chart.yml index 97889568..7b555bda 100644 --- a/templates/example_chart.yml +++ b/templates/example_chart.yml @@ -656,12 +656,12 @@ series: color: darkred ############################################### -# Cost saving chart +# Daily cost saving chart ############################################### type: custom:apexcharts-card header: show: true - title: Cost Savings + title: Daily Cost Savings show_states: true colorize_states: true graph_span: 7days @@ -692,3 +692,32 @@ series: group_by: func: last duration: 1day + +############################################### +# Total cost saving chart +############################################### +type: custom:apexcharts-card +header: + show: true + title: Total Cost Saving + show_states: true + colorize_states: true +graph_span: 30days +span: + start: day + offset: '-29days' +now: + show: true +series: + - entity: predbat.savings_total_predbat + stroke_width: 1 + curve: smooth + name: Predbat saving + attribute: pounds + unit: £ + - entity: predbat.savings_total_pvbat + stroke_width: 1 + curve: smooth + name: PV/Battery saving + attribute: pounds + unit: £