PyATEMMax
                                
                                 PyATEMMax copied to clipboard
                                
                                    PyATEMMax copied to clipboard
                            
                            
                            
                        Very unreliable connections to ATEM M2 Constellation
Hi,
I've got a simple python script that switches the preview source but I'm finding that it often takes multiple attempts to connect to the ATEM on the same physical network (both devices on the same switch). Am I using this API incorrectly (apologize, I am a Python novice).
def connect_to_atem():
    """Establish connection to ATEM with retry logic"""
    switcher = PyATEMMax.ATEMMax()
    max_attempts = 5
    
    try:
        logger.info(f"Attempting to connect to ATEM at {ATEM_IP}")
        switcher.connect(ATEM_IP)
        
        for attempt in range(max_attempts):
            logger.info(f"Connection attempt {attempt + 1} of {max_attempts}")
            if switcher.waitForConnection(timeout=10.0):
                logger.info("Connected to ATEM")
                return switcher
            else:
                logger.warning(f"Attempt {attempt + 1} failed")
                if attempt < max_attempts - 1:
                    time.sleep(1)
                    switcher.disconnect()
                    time.sleep(0.5)
                    switcher.connect(ATEM_IP)
        
        return None
            
    except Exception as e:
        logger.error(f"Error connecting to ATEM: {e}")
        return None