Skip to content

Commit

Permalink
Merge pull request #207 from fboundy/patch
Browse files Browse the repository at this point in the history
Patch
  • Loading branch information
fboundy authored Apr 12, 2024
2 parents 3f219d4 + 20f7980 commit 79d05ec
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 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.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.

Expand Down
5 changes: 4 additions & 1 deletion apps/pv_opt/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
# ===============================================================================================================
Expand Down
6 changes: 3 additions & 3 deletions apps/pv_opt/pv_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down Expand Up @@ -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",
Expand Down
30 changes: 20 additions & 10 deletions apps/pv_opt/pvpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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),
)
)

Expand Down

0 comments on commit 79d05ec

Please sign in to comment.