Skip to content

Commit

Permalink
Tidy debug output, don't include standing charge in p/kWh figures (#1585
Browse files Browse the repository at this point in the history
)

* 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>
  • Loading branch information
springfall2008 and pre-commit-ci-lite[bot] authored Nov 3, 2024
1 parent 9ac2b02 commit f8acc45
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions .cspell/custom-dictionary-workspace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ nocharge
nodischarge
nord
Nordpool
nosc
nrgheat
octoplus
octopoints
Expand Down
1 change: 0 additions & 1 deletion apps/predbat/futurerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion apps/predbat/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions apps/predbat/inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -1840,24 +1840,24 @@ 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]

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
Expand All @@ -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))
Expand Down
11 changes: 8 additions & 3 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit f8acc45

Please sign in to comment.