diff --git a/README.md b/README.md index d843315..3ef349f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PV Opt: Home Assistant Solar/Battery Optimiser v3.8.8 +# PV Opt: Home Assistant Solar/Battery Optimiser v3.8.9 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/config/config.yaml b/apps/pv_opt/config/config.yaml index 7387ab0..ac093c1 100644 --- a/apps/pv_opt/config/config.yaml +++ b/apps/pv_opt/config/config.yaml @@ -81,10 +81,10 @@ pv_opt: # Octopus account parameters # ======================================== - # octopus_auto: False # Read tariffs from the Octopus Energy integration. If successful this over-rides the following parameters + octopus_auto: False # Read tariffs from the Octopus Energy integration. If successful this over-rides the following parameters - # octopus_account: !secret octopus_account - # octopus_api_key: !secret octopus_api_key + octopus_account: !secret octopus_account + octopus_api_key: !secret octopus_api_key # The following Can be omitted if either of the above options is working correctly: diff --git a/apps/pv_opt/pv_opt.py b/apps/pv_opt/pv_opt.py index 1a41ef6..313e2a6 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.8" +VERSION = "3.8.9" DEBUG = False DATE_TIME_FORMAT_LONG = "%Y-%m-%d %H:%M:%S%z" @@ -30,7 +30,7 @@ REDACT_REGEX = [ "[0-9]{2}m[0-9]{7}_[0-9]{13}", # Serial_MPAN "[0-9]{2}m[0-9]{7}", # Serial - "[0-9]{3}00[0-9]{8}", # MPAN + "^$|\d{13}$", # MPAN "a_[0-f]{8}", # Account Number "A-[0-f]{8}", # Account Number "sk_live_[a-zA-Z0-9]{24}", # API @@ -599,12 +599,8 @@ def _load_contract(self): for entity in entities[imp_exp]: tariff_code = self.get_state( entity, attribute="all" - )["attributes"][BOTTLECAP_DAVE["tariff_code"]] - average_rate = self.get_state( - entity, attribute="all" - )["attributes"]["average_rate"] - - + )["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" ) @@ -613,14 +609,10 @@ def _load_contract(self): for imp_exp in IMPEXP: if len(entities[imp_exp]) > 0: tariff_code = self.get_state( - entities[imp_exp][0], attribute="all" - )["attributes"][BOTTLECAP_DAVE["tariff_code"]] - - average_rate = self.get_state( entity, attribute="all" - )["attributes"]["average_rate"] + )["attributes"].get(BOTTLECAP_DAVE["tariff_code"], None) - if average_rate > 0: + if tariff_code is not None: tariffs[imp_exp] = pv.Tariff( tariff_code, export=(imp_exp == "export"), host=self )