Skip to content

Commit

Permalink
ha - vent fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Jul 1, 2024
1 parent a33f005 commit 608a7de
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ph4ha/apps/vent.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,20 @@ def on_humidity(self, humidity):
if float(humidity) > self.humidity_threshold_value:
if self.flip_history and current_time - self.flip_history[-1] < timedelta(seconds=3 * 60 + 15):
self.log(f"Not venting, previous is still in progress {current_time - self.flip_history[-1]}")
if (
len(self.flip_history) < 3
and current_time >= self.next_possible_flip_time
and self.segment_flip_count < self.segment_max_flips
):

elif len(self.flip_history) >= 10:
self.next_possible_flip_time = current_time + timedelta(minutes=10)
self.log("Flip limit reached. Next possible flip time set.")

elif current_time >= self.next_possible_flip_time and self.segment_flip_count < self.segment_max_flips:
self.log(f"High humidity detected at {humidity}%! Venting.")
self.turn_on(self.vent_switch)
self.flip_history.append(current_time)
self.segment_flip_count += 1

if len(self.flip_history) >= 10:
self.next_possible_flip_time = current_time + timedelta(minutes=10)
self.log("Flip limit reached. Next possible flip time set.")

elif current_time < self.next_possible_flip_time:
self.log("Flip delayed: Cooling off period active.")
elif self.segment_flip_count >= self.segment_max_flips:
self.log("Maximum segment flips reached, no more flipping allowed.")
else:
self.log("Flip limit reached. No more flipping allowed.")

0 comments on commit 608a7de

Please sign in to comment.