Skip to content

Commit

Permalink
Fix bug in nordpool data wrapping issue (#742)
Browse files Browse the repository at this point in the history
* Fix bug in nordpool data wrapping issue

#730

* [pre-commit.ci lite] apply automatic fixes

---------

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 Feb 9, 2024
1 parent 68c3f18 commit 6f3ab8c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/predbat/predbat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3343,13 +3343,14 @@ def futurerate_analysis(self):
if "Name" in row:
rstart = row.get("StartTime", "") + now_offset
rend = row.get("EndTime", "") + now_offset
rname = row.get("Name", "")
if "Columns" in row:
for column in row["Columns"]:
cname = column.get("Name", "")
cvalue = column.get("Value", "")
date_start, time_start = rstart.split("T")
date_end, time_end = rend.split("T")
if "-" in cname and "," in cvalue and cname:
if "-" in rname and "-" in cname and "," in cvalue and cname:
date_start = cname
date_end = cname
cvalue = cvalue.replace(",", ".")
Expand All @@ -3359,6 +3360,8 @@ def futurerate_analysis(self):
TIME_FORMAT_NORD = "%d-%m-%YT%H:%M:%S%z"
time_date_start = datetime.strptime(rstart, TIME_FORMAT_NORD)
time_date_end = datetime.strptime(rend, TIME_FORMAT_NORD)
if time_date_end < time_date_start:
time_date_end += timedelta(days=1)
delta_start = time_date_start - self.midnight_utc
delta_end = time_date_end - self.midnight_utc

Expand All @@ -3382,10 +3385,12 @@ def futurerate_analysis(self):
item["to"] = time_date_end.strftime(TIME_FORMAT)
item["rate_import"] = self.dp2(rate_import)
item["rate_export"] = self.dp2(rate_export)
extracted_data[time_date_start] = item

if time_date_start not in extracted_keys:
extracted_keys.append(time_date_start)
extracted_data[time_date_start] = item
else:
self.log("WARN: Duplicate key {} in extracted_keys".format(time_date_start))

if extracted_keys:
extracted_keys.sort()
Expand Down

0 comments on commit 6f3ab8c

Please sign in to comment.