I'm currently trying to retrieve a timeseries within certain time ranges. I'm passing datetime values as strings (YYYY-MM-DD HH:MM:SS), but keep getting errors.
def retrieve_pi_data(pi_tag, start_time, end_time):
    # Connect to PI System
    pisdk = Dispatch("PISDK.PISDK")
    server = pisdk.Servers.DefaultServer  
    # Retrieve PI Tag data
    try:
        point = server.PIPoints[pi_tag]
        print('point: ', point)
    except Exception as e:
        print(f"Error accessing PI point: {e}")
        return []
    # Retrieve recorded values
    try:
        recordset = point.Data.RecordedValues(start_time, end_time)
        print('recordset')
        values = [(event.TimeStamp.LocalDate, event.Value) for event in recordset]
    except Exception as e:
        print(f"Error retrieving recorded values: {e}")
        values = []
    return valuesIn it's current form above, I receive the error:
Error retrieving recorded values: The Python instance cannot be converted to a COM object
Which is stemming from the RecordedValues() method.
Any guidance would be appreciated!
 
    				 
		 
					