Skip to content

Commit

Permalink
redo nextwaterboost to datetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Dec 6, 2023
1 parent 1b333a5 commit 7929781
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@
def get_demand(temp) -> Demand:
if temp is None:
return Demand.NoDemand
if 0 < temp < 100:
if temp >= 40:
return Demand.NoDemand
if temp > 35:
return Demand.LowDemand
if temp >= 25:
return Demand.MediumDemand
if temp < 25:
return Demand.HighDemand
if temp > 70 or temp == 0:
return Demand.ErrorDemand
if temp >= 40:
return Demand.NoDemand
if temp > 35:
return Demand.LowDemand
if temp >= 25:
return Demand.MediumDemand
if temp < 25:
return Demand.HighDemand
return Demand.ErrorDemand

from dataclasses import dataclass, field
from datetime import datetime, timedelta

@dataclass
class NextWaterBoostModel:
Expand Down Expand Up @@ -89,7 +92,7 @@ def cold_limit(self) -> datetime:
hourdiff = (self.current_temp - self.target_temp) / -self.temp_trend
except ZeroDivisionError:
hourdiff = DELAY_LIMIT
return self.now_dt + timedelta(hours=hourdiff)
return max(self.now_dt + timedelta(hours=hourdiff), self._now_dt)

@property
def is_cold(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def find_lowest_2hr_combination(self, start_index: datetime, end_index: datetime
min_sum = float('inf')
min_start_index = None
current: datetime = start_index
print(start_index, end_index)
while current < end_index:
try:
current_sum = self.model.price_dict[current] + self.model.price_dict[current + timedelta(hours=1)]
Expand Down

0 comments on commit 7929781

Please sign in to comment.