diff --git a/README.md b/README.md index 3ef349f..9d2c299 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/apps/pv_opt/pv_opt.py b/apps/pv_opt/pv_opt.py index 313e2a6..a79a2ae 100644 --- a/apps/pv_opt/pv_opt.py +++ b/apps/pv_opt/pv_opt.py @@ -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" @@ -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", @@ -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)