Skip to content

Commit

Permalink
water heater fix
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Dec 16, 2023
1 parent ccfc684 commit e6b1702
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ def update(self, temp, temp_trend, target_temp, prices_today: list, prices_tomor
self.set_now_dt(now_dt)
new_price_dict = self._create_price_dict(prices_today + prices_tomorrow)
if new_price_dict != self.price_dict:
if all([
any([k for k in new_price_dict.keys() if k.date() != self.now_dt.date()]),
not any([k for k in self.price_dict.keys() if k.date() != self.now_dt.date()])
]):
self.latest_calculation = None
self.price_dict = new_price_dict
self.should_update = True
new_non_hours = self._set_hours(self.non_hours_raw, preset)
Expand Down
5 changes: 5 additions & 0 deletions custom_components/peaqhvac/test/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
1.81, 1.99, 2.19, 2.73, 2.73, 2.63, 2.11, 1.81, 1.62, 1.43, 1.41, 1.28]
P231215 =[1.28,1.24,1.2,1.15,1.13,1.2,1.42,1.57,1.78,1.72,1.61,1.51,1.39,1.31,1.28,1.3,1.42,1.37,1.26,1.19,1.15,1.14,0.93,1.05]
P231216 = [0.69,0.62,0.56,0.45,0.38,0.32,0.31,0.31,0.31,0.3,0.3,0.27,0.26,0.25,0.26,0.27,0.28,0.27,0.24,0.23,0.15,0.11,0.08,0.08]
P231217 = [0.06,0.06,0.06,0.06,0.07,0.08,0.08,0.08,0.1,0.11,0.11,0.13,0.11,0.13,0.11,0.14,0.16,0.24,0.27,0.27,0.25,0.24,0.17,0.16]

def test_offsets_cent_and_normal_match():
prices = P231213 + P231214
Expand All @@ -20,6 +21,10 @@ def test_offsets_cent_and_normal_match():
r2 = set_offset_dict([p*100 for p in prices], now_dt, 0, {})
assert r1 == r2

def test_assert_cheaper_hours_tomorrow_not_lower_offset_than_today():
"""error with 231217 last hours having another offset than the same price for 231216"""
pass

def test_offsets_correct_curve_over_night_cached_today():
_tolerance = 3
indoors_preset = HvacPresets.Normal
Expand Down

0 comments on commit e6b1702

Please sign in to comment.