Skip to content

Commit

Permalink
Fix issue with manual api load_scaling crash (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
springfall2008 authored Dec 15, 2024
1 parent 39d16b3 commit f5a2600
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/predbat/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,8 @@ def basic_rates(self, info, rtype, prev=None, rate_replicate={}):
# Resolve any sensor links
if isinstance(rate, str) and rate[0].isalpha():
rate = self.resolve_arg("rate", rate, 0.0)
if isinstance(load_scaling, str) and load_scaling[0].isalpha():
load_scaling = self.resolve_arg("load_scaling", load_scaling, 1.0)

# Ensure the end result is a float
try:
Expand All @@ -1298,6 +1300,14 @@ def basic_rates(self, info, rtype, prev=None, rate_replicate={}):
self.record_status("Bad rate {} provided in energy rates".format(rate), had_errors=True)
continue

if load_scaling is not None:
try:
load_scaling = float(load_scaling)
except (ValueError, TypeError):
self.log("Warn: Bad load_scaling {} provided in energy rates".format(load_scaling))
self.record_status("Warn: Bad load_scaling {} provided in energy rates".format(load_scaling), had_errors=True)
continue

# Time in minutes
start_minutes = max(minutes_to_time(start, midnight), 0)
end_minutes = min(minutes_to_time(end, midnight), 24 * 60 - 1)
Expand Down

0 comments on commit f5a2600

Please sign in to comment.