Skip to content

Commit

Permalink
Fix pounds calculation for savings (#1114)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored May 18, 2024
1 parent 90115a7 commit 38e96b4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
12 changes: 7 additions & 5 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
)
Expand All @@ -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",
},
)
Expand Down
33 changes: 31 additions & 2 deletions templates/example_chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: £

0 comments on commit 38e96b4

Please sign in to comment.