Onkyo timeout when starting the receiver

I want to power on the receiver and at the same time send a command to switch source and volume. However, this is not working, because the receiver needs about 22 seconds to finally become online. Is there a way to make this work by increasing a timeout or “retry until it works”?