import time print("main.py") state = False state_prev = True while True: dt = rtc.datetime() print("dt: ", dt) day = dt[3] print("day: ", day) config_day = config[day] print("config[day]: ", config_day) print("state: ", state) for p in [1, 2]: # On entry = config_day[p]["on"] if entry["h"] == dt[4] and entry["m"] == dt[5]: state = True # Off entry = config_day[p]["off"] if entry["h"] == dt[4] and entry["m"] == dt[5]: state = False if state != state_prev: state_prev = state if state: print("turn on", entry) pin_led.value(0) else: print("turn off", entry) pin_led.value(1) time.sleep(10)