Skip to content

Commit

Permalink
Fixed bug in get_frequency
Browse files Browse the repository at this point in the history
Issue reported by mark
  • Loading branch information
UbhiTS committed Apr 12, 2020
1 parent 12bc1e5 commit 59b15a6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/alexa_talking_clock/alexa_talking_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def initialize(self):
self.frequency = self.get_frequency()
self.next_start = self.get_next_start()

self.log("INITIALIZE start:" + str(self.next_start) + ", frequency:" + str(self.frequency.interval) + ", times:" + str(self.frequency.announce_times))
if self.frequency.interval is None:
raise Exception("ERROR: No announce frequency defined. Please set at least one frequency interval")

if self.frequency.interval is not None:
self.run_every(self.time_announce, self.next_start, (60 * self.frequency.interval))
self.run_every(self.time_announce, self.next_start, (60 * self.frequency.interval))

self.log("INITIALIZED: Start " + str(self.next_start.strftime("%H:%M:%S")) + ", Frequency " + str(self.frequency.interval) + ", Times " + str(self.frequency.announce_times))


def get_frequency(self):
Expand Down Expand Up @@ -74,6 +76,7 @@ def get_next_start(self):
for min in self.frequency.announce_times:
if now.minute < min:
next_start_min = min
break

if next_start_min is None:
next = now.replace(minute = 0, second = 0) + datetime.timedelta(hours=1)
Expand Down

0 comments on commit 59b15a6

Please sign in to comment.