From f8acc453daf654c500632233759790c41460c769 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Sun, 3 Nov 2024 10:24:02 +0000 Subject: [PATCH] Tidy debug output, don't include standing charge in p/kWh figures (#1585) * Tidy debug output, don't include standing charge in p/kWh figures * [pre-commit.ci lite] apply automatic fixes * Remove comment * [pre-commit.ci lite] apply automatic fixes * Update custom-dictionary-workspace.txt --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- .cspell/custom-dictionary-workspace.txt | 1 + apps/predbat/futurerate.py | 1 - apps/predbat/ha.py | 2 +- apps/predbat/inverter.py | 9 ++++----- apps/predbat/predbat.py | 11 ++++++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.cspell/custom-dictionary-workspace.txt b/.cspell/custom-dictionary-workspace.txt index 77718ca4..c36ea670 100644 --- a/.cspell/custom-dictionary-workspace.txt +++ b/.cspell/custom-dictionary-workspace.txt @@ -128,6 +128,7 @@ nocharge nodischarge nord Nordpool +nosc nrgheat octoplus octopoints diff --git a/apps/predbat/futurerate.py b/apps/predbat/futurerate.py index 3f03db15..ceef87d7 100644 --- a/apps/predbat/futurerate.py +++ b/apps/predbat/futurerate.py @@ -257,7 +257,6 @@ def futurerate_analysis_new(self, url_template, rate_import_real, rate_export_re adjust_import = self.get_arg("futurerate_adjust_import", False) adjust_export = self.get_arg("futurerate_adjust_export", False) - self.log("Info: Calibrating Nordpool data... adjust_import {} adjust_export {}".format(adjust_import, adjust_export)) mdata_import = self.futurerate_calibrate(rate_import_real if adjust_import else {}, mdata_import, is_import=True, peak_start_minutes=peak_start_minutes, peak_end_minutes=peak_end_minutes) mdata_export = self.futurerate_calibrate(rate_export_real if adjust_export else {}, mdata_export, is_import=False, peak_start_minutes=peak_start_minutes, peak_end_minutes=peak_end_minutes) diff --git a/apps/predbat/ha.py b/apps/predbat/ha.py index 72de40ab..9f75c2dd 100644 --- a/apps/predbat/ha.py +++ b/apps/predbat/ha.py @@ -126,7 +126,7 @@ async def async_call_service_websocket_command(self, domain, service, service_da """ url = "{}/api/websocket".format(self.ha_url) response = None - self.log("Info: Web socket service {}/{} socket for url {}".format(domain, service, url)) + # self.log("Info: Web socket service {}/{} socket for url {}".format(domain, service, url)) return_response = service_data.get("return_response", False) if "return_response" in service_data: diff --git a/apps/predbat/inverter.py b/apps/predbat/inverter.py index d2014f89..0ad5972a 100644 --- a/apps/predbat/inverter.py +++ b/apps/predbat/inverter.py @@ -425,7 +425,7 @@ def find_charge_curve(self, discharge): charge_rate_sensor = self.base.get_arg("discharge_rate", indirect=False, index=self.id) else: charge_rate_sensor = self.base.get_arg("charge_rate", indirect=False, index=self.id) - predbat_status_sensor = "predbat.status" + predbat_status_sensor = self.base.prefix + ".status" battery_power_sensor = self.base.get_arg("battery_power", indirect=False, index=self.id) final_curve = {} final_curve_count = {} @@ -1840,16 +1840,17 @@ def call_service_template(self, service, data, domain="charge"): if not service_list: return False - hash_index = domain + str(self.id) + hash_index = domain last_service_hash = self.base.last_service_hash.get(hash_index, "") this_service_hash = hash(str(service) + "_" + str(data)) if last_service_hash == this_service_hash: - self.log("Inverter {} Skipping service {} with data {} as already called".format(self.id, service, data)) + self.log("Inverter {} Skipping service {} domain {} with data {} as already called".format(self.id, service, domain, data)) return True else: # Record the last service called self.base.last_service_hash[hash_index] = this_service_hash + self.log("Inverter {} Calling service {} domain {} with data {}".format(self.id, service, domain, data)) if not isinstance(service_list, list): service_list = [service_list] @@ -1857,7 +1858,6 @@ def call_service_template(self, service, data, domain="charge"): for service_template in service_list: service_data = {} service_name = "" - self.log("Inverter {} Call service template {} = {}".format(self.id, service, service_template)) if isinstance(service_template, str): service_name = service_template @@ -1874,7 +1874,6 @@ def call_service_template(self, service, data, domain="charge"): if service_name: service_name = service_name.replace(".", "/") - self.log("Inverter {} Call service {} with data {}".format(self.id, service_name, service_data)) self.base.call_service_wrapper(service_name, **service_data) else: self.log("Warn: Inverter {} unable to find service name for {}".format(self.id, service)) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index aa42874a..ff449567 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -32,7 +32,7 @@ import asyncio import json -THIS_VERSION = "v8.5.5" +THIS_VERSION = "v8.5.6" PREDBAT_FILES = ["predbat.py", "config.py", "prediction.py", "utils.py", "inverter.py", "ha.py", "download.py", "unit_test.py", "web.py", "predheat.py", "futurerate.py"] from download import predbat_update_move, predbat_update_download, check_install @@ -4516,6 +4516,8 @@ def today_cost(self, import_today, export_today, car_today): day_cost = 0 day_cost_import = 0 day_cost_export = 0 + day_cost_nosc = 0 + day_cost_nosc_import = 0 day_import = 0 day_export = 0 day_car = 0 @@ -4557,11 +4559,14 @@ def today_cost(self, import_today, export_today, car_today): if self.rate_import: day_cost += self.rate_import[minute] * energy day_cost_import += self.rate_import[minute] * energy + day_cost_nosc += self.rate_import[minute] * energy + day_cost_nosc_import += self.rate_import[minute] * energy day_cost_car += self.rate_import[minute] * car_energy day_export += energy_export if self.rate_export: day_cost -= self.rate_export[minute] * energy_export + day_cost_nosc -= self.rate_export[minute] * energy_export day_cost_export -= self.rate_export[minute] * energy_export if self.carbon_enable: @@ -4582,11 +4587,11 @@ def today_cost(self, import_today, export_today, car_today): day_import_pkwh = 0 day_export_pkwh = 0 if day_energy_total > 0: - day_pkwh = day_cost / day_energy_total + day_pkwh = day_cost_nosc / day_energy_total if day_car > 0: day_car_pkwh = day_cost_car / day_car if day_import > 0: - day_import_pkwh = day_cost_import / day_import + day_import_pkwh = day_cost_nosc_import / day_import if day_export > 0: day_export_pkwh = day_cost_export / day_export