Skip to content

Commit

Permalink
Merge pull request #130 from fboundy/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
fboundy authored Feb 19, 2024
2 parents e16d50c + 1506c6e commit 0977f12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PV Opt: Home Assistant Solar/Battery Optimiser v3.8.9
# PV Opt: Home Assistant Solar/Battery Optimiser v3.8.10

Solar / Battery Charging Optimisation for Home Assistant. This appDaemon application attempts to optimise charging and discharging of a home solar/battery system to minimise cost electricity cost on a daily basis using freely available solar forecast data from SolCast. This is particularly beneficial for Octopus Agile but is also benefeficial for other time-of-use tariffs such as Octopus Flux or simple Economy 7.

Expand Down
34 changes: 19 additions & 15 deletions apps/pv_opt/pv_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
USE_TARIFF = True

VERSION = "3.8.9"
VERSION = "3.8.10"
DEBUG = False

DATE_TIME_FORMAT_LONG = "%Y-%m-%d %H:%M:%S%z"
Expand Down Expand Up @@ -602,22 +602,25 @@ def _load_contract(self):
)["attributes"].get(BOTTLECAP_DAVE["tariff_code"], None)

self.rlog(
f" Found {imp_exp} entity {entity}: Tariff code: {tariff_code} Average Rate: {average_rate} GBP/kWh"
f" Found {imp_exp} entity {entity}: Tariff code: {tariff_code}"
)

tariffs = {x: None for x in IMPEXP}
for imp_exp in IMPEXP:
self.log(f">>>{imp_exp}: {entities[imp_exp]}")
if len(entities[imp_exp]) > 0:
tariff_code = self.get_state(
entity, attribute="all"
)["attributes"].get(BOTTLECAP_DAVE["tariff_code"], None)

if tariff_code is not None:
tariffs[imp_exp] = pv.Tariff(
tariff_code, export=(imp_exp == "export"), host=self
)
if "AGILE" in tariff_code:
self.agile = True
for entity in entities[imp_exp]:
tariff_code = self.get_state(
entity, attribute="all"
)["attributes"].get(BOTTLECAP_DAVE["tariff_code"], None)
self.log(f">>> {tariff_code}")

if tariff_code is not None:
tariffs[imp_exp] = pv.Tariff(
tariff_code, export=(imp_exp == "export"), host=self
)
if "AGILE" in tariff_code:
self.agile = True

self.contract = pv.Contract(
"current",
Expand Down Expand Up @@ -1714,9 +1717,10 @@ def _create_windows(self):

self.windows = pd.concat([windows, self.windows]).sort_values("start")
tolerance = self.get_config("forced_power_group_tolerance")
self.windows["forced"] = (
(self.windows["forced"] / tolerance).round(0) * tolerance
).astype(int)
if tolerance > 0:
self.windows["forced"] = (
(self.windows["forced"] / tolerance).round(0) * tolerance
).astype(int)

self.windows["soc"] = self.windows["soc"].round(0).astype(int)
self.windows["soc_end"] = self.windows["soc_end"].round(0).astype(int)
Expand Down

0 comments on commit 0977f12

Please sign in to comment.