Skip to content

Commit e8f8540

Browse files
committed
add condition to starting light
1 parent 188ef1c commit e8f8540

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

PyPortal_Wakeup_Light/wake_up_light.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def subtract30min(day): # subtract 30 min
190190
refresh_time = None
191191

192192
while True:
193+
time_now = time.localtime()
193194
# only query the online time once per hour (and on first run)
194195
if (not refresh_time) or (time.monotonic() - refresh_time) > 3600:
195196
try:
@@ -208,8 +209,9 @@ def subtract30min(day): # subtract 30 min
208209
backLight()
209210
# start the light 30 min before wake up time
210211
start_light_time = subtract30min(wake_up_day)
211-
# If wake up time - 30 minutes equals current time, start the light
212-
if time_str_text == start_light_time:
212+
# If current day is wake up day and
213+
# wake up time - 30 minutes equals current time, start the light
214+
if wake_up_day == time_now[6] and time_str_text == start_light_time:
213215
print("Starting wake up light")
214216
# turn on backlight
215217
pyportal.set_backlight(backlight_on)

0 commit comments

Comments
 (0)