if now.hour >= 12: light_on() else: light_off() if (now.hour >= 11 and now.minute >= 50) or now.hour > 12: gas_on() else: gas_off() print("resume done.") def aquarium(): resume() print("Starting main instance of aquarium") schedule.every().day.at("12:00").do(light_on) schedule.every().day.at("00:00").do(light_off) schedule.every().day.at("11:50").do(gas_on) schedule.every().day.at("23:30").do(gas_off) print("Setup ok, entering into the main loop") try: while True: schedule.run_pending() time.sleep(1) except KeyboardInterrupt: print("Manuel exit requested") if __name__ == "__main__": r.test() aquarium()