diff --git a/README.md b/README.md index 2a59528..d2ca6ba 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PV Opt: Home Assistant Solar/Battery Optimiser v3.14.0 +# PV Opt: Home Assistant Solar/Battery Optimiser v3.14.1 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 b3090e4..c48e880 100644 --- a/apps/pv_opt/config/config.yaml +++ b/apps/pv_opt/config/config.yaml @@ -81,7 +81,7 @@ 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 @@ -98,6 +98,9 @@ pv_opt: # octopus_import_tariff_code: E-1R-FLUX-IMPORT-23-02-14-G # octopus_export_tariff_code: E-1R-FLUX-EXPORT-23-02-14-G + octopus_import_tariff_code: E-1R-GO-VAR-22-10-14-N + octopus_export_tariff_code: E-1R-OUTGOING-LITE-FIX-12M-23-09-12-N + # =============================================================================================================== # Brand / Integration Specific Config: SOLIS_SOLAX_MODBUS: https://github.com/wills106/homeassistant-solax-modbus # =============================================================================================================== diff --git a/apps/pv_opt/pv_opt.py b/apps/pv_opt/pv_opt.py index 3725a6b..95ba68e 100644 --- a/apps/pv_opt/pv_opt.py +++ b/apps/pv_opt/pv_opt.py @@ -12,7 +12,7 @@ from numpy import nan import re -VERSION = "3.14.0" +VERSION = "3.14.1" OCTOPUS_PRODUCT_URL = r"https://api.octopus.energy/v1/products/" @@ -217,8 +217,8 @@ "domain": "number", "attributes": { "min": 2000, - "max": 20000, - "step": 100, + "max": 30000, + "step": 500, "unit_of_measurement": "Wh", "device_class": "energy", "mode": "slider", diff --git a/apps/pv_opt/pvpy.py b/apps/pv_opt/pvpy.py index 79606bd..82a316a 100644 --- a/apps/pv_opt/pvpy.py +++ b/apps/pv_opt/pvpy.py @@ -624,6 +624,8 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg axis=1, ) base_cost = round(contract.net_cost(df).sum(), 1) + if log: + self.log(f"Base cost: {base_cost}") slots = [] @@ -742,19 +744,27 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg if round(cost_at_min_price, 1) < round(max_import_cost, 1): for slot, factor in zip(window, factors): + slot_power_required = max(round_trip_energy_required * 2000 * factor, 0) + slot_charger_power_available = max( + self.inverter.charger_power - x["forced"].loc[slot], 0 + ) + slot_available_capacity = max( + ((100 - x["soc_end"].loc[slot]) / 100 * self.battery.capacity) * 2 * factor, 0 + ) + min_power = min( + slot_power_required, slot_charger_power_available, slot_available_capacity + ) + if log: + str_log_x = ( + f">>> Slot: {slot.strftime(TIME_FORMAT)} Factor: {factor:0.3f} Forced: {x['forced'].loc[slot]:6.0f}W " + + f"End SOC: {x['soc_end'].loc[slot]:4.1f}% SPR: {slot_power_required:6.0f}W " + + f"SCPA: {slot_charger_power_available:6.0f}W SAC: {slot_available_capacity:6.0f}W Min Power: {min_power:6.0f}W" + ) + self.log(str_log_x) slots.append( ( slot, - round( - min( - round_trip_energy_required * 2000 * factor, - max(self.inverter.charger_power - x["forced"].loc[slot], 0), - ((100 - x["soc_end"].loc[slot]) / 100 * self.battery.capacity) - * 2 - * factor, - ), - 0, - ), + round(min_power, 0), ) )