Skip to content

Commit

Permalink
fixed time logic
Browse files Browse the repository at this point in the history
  • Loading branch information
UbhiTS authored May 30, 2020
1 parent c75ff63 commit fa25862
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/auto_fan_speed/auto_fan_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ def configure(self, kwargs):

def temperature_change(self, entity, attribute, old, new, kwargs):

# if the room temp changes
# and if time is between start and end
# if the room temp changes and time is between start and end
# then calculate and change fan speed

time_okay = False
current_time = datetime.now().time()
time_okay = self.start <= current_time and current_time <= self.end

if (self.start < self.end):
time_okay = self.start <= current_time and current_time <= self.end
else:
time_okay = self.start <= current_time or current_time <= self.end

if time_okay:
room_temperature = float(new)
fan_speed = self.get_target_fan_speed(room_temperature)
Expand Down

0 comments on commit fa25862

Please sign in to comment.