Rendering Error in layout Message/Item: array_keys(): Argument #1 ($array) must be of type array, null given. Please enable debug mode for more information.
It's better to use INDI Python client than to use scripts like these. At any rate, you should check the state of CCD_EXPOSURE, once it turns from BUSY to OK, then you can download the image. Never make any assumptions solely on timing.