From eef6b15ef8be84c0f61766cb3577ce8f0bbe0911 Mon Sep 17 00:00:00 2001 From: fboundy Date: Wed, 20 Mar 2024 08:52:12 +0000 Subject: [PATCH] Bug Fix for Solax v24.03.x --- README.md | 2 +- apps/pv_opt/config/config.yaml | 1 + apps/pv_opt/pv_opt.py | 2 +- apps/pv_opt/solis.py | 17 +++++++++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb8990b..f8e6be1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PV Opt: Home Assistant Solar/Battery Optimiser v3.11.0 +# PV Opt: Home Assistant Solar/Battery Optimiser v3.11.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 4c8fc0e..121f2b0 100644 --- a/apps/pv_opt/config/config.yaml +++ b/apps/pv_opt/config/config.yaml @@ -36,6 +36,7 @@ pv_opt: consumption_history_days: 7 read_only: false + debug: false # ======================================== # Plant parameters diff --git a/apps/pv_opt/pv_opt.py b/apps/pv_opt/pv_opt.py index bbf9703..ebe5c60 100644 --- a/apps/pv_opt/pv_opt.py +++ b/apps/pv_opt/pv_opt.py @@ -18,7 +18,7 @@ USE_TARIFF = True -VERSION = "3.11.0" +VERSION = "3.11.1" DEBUG = False DATE_TIME_FORMAT_LONG = "%Y-%m-%d %H:%M:%S%z" diff --git a/apps/pv_opt/solis.py b/apps/pv_opt/solis.py index eff4ea6..6c0a1cb 100644 --- a/apps/pv_opt/solis.py +++ b/apps/pv_opt/solis.py @@ -9,8 +9,9 @@ "Self-Use - No Grid Charging": 1, "Timed Charge/Discharge - No Grid Charging": 3, "Backup/Reserve - No Grid Charging": 17, - "Self-Use": 33, "SelfUse": 33, + "Self-Use - No Timed Charge/Discharge": 33, + "Self-Use": 35, "Timed Charge/Discharge": 35, "Off-Grid Mode": 37, "Battery Awaken": 41, @@ -426,10 +427,13 @@ def _solis_set_mode_switch(self, **kwargs): status = self._solis_core_mode_switch() switches = status["switches"] + if self.host.debug: + self.log(f">>> kwargs: {kwargs}") + self.log(">>> Solis switch status:") + for switch in switches: if switch in kwargs: if self.host.debug: - self.log("Solis switch status:") self.log(f">>> {switch}: {kwargs[switch]}") switches[switch] = kwargs[switch] @@ -443,6 +447,12 @@ def _solis_set_mode_switch(self, **kwargs): modes = {INVERTER_DEFS[self.type]["codes"].get(mode): mode for mode in entity_modes} # mode = INVERTER_DEFS[self.type]["modes"].get(code) mode = modes.get(code) + if self.host.debug: + self.log(f">>> Inverter Code: {code}") + self.log(f">>> Entity modes: {entity_modes}") + self.log(f">>> Modes: {modes}") + self.log(f">>> Inverter Mode: {mode}") + if mode is not None: if self.host.get_state(entity_id=entity_id) != mode: self.host.call_service("select/select_option", entity_id=entity_id, option=mode) @@ -459,6 +469,9 @@ def _solis_solax_solarman_mode_switch(self): else: modes = INVERTER_DEFS[self.type]["modes"] code = {modes[m]: m for m in modes}[inverter_mode] + if self.host.debug: + self.log(f">>> Inverter Mode: {inverter_mode}") + self.log(f">>> Inverter Code: {code}") bits = INVERTER_DEFS[self.type]["bits"] switches = {bit: (code & 2**i == 2**i) for i, bit in enumerate(bits)}