Timer Tag error whenever a new day begins

Hi,

I have done a logic in which timer tag (will extract the minute of the current time stamp) and it will trigger another boolean tag by setting it as one. Once the ‘value changed’ function in boolean tag is completed, it will be reset as false. This will be executed for every minute. Also i am capturing the time stamp in another tag (OEE Time) whenever the boolean tag is executed .It is working until the current time stamp is 12:00:00. After 12, it is not unchecking the boolean tag,

Timer tag (value changed):

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	if ( previousValue.value != currentValue.value ):
		logger = system.util.getLogger("OEE Timer Minute")
		system.tag.writeBlocking("[.]DBDataStoreTrigger", [1])
		logger.info("Minute Triggered")

DBDatastoreTrigger -boolean tag (value changed):

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	vCheck =system.tag.readBlocking("[.]DBDataStoreTrigger")[0].value	

	if (vCheck== 1 ):
		logger = system.util.getLogger("OEE history")
		
		vEndTime = system.date.now()
		
		system.tag.writeBlocking("[.]OEE_Time", vEndTime)
		
		vStartTime = system.tag.readBlocking("[.]../../Events/ShiftStarted")[0].value
		#system.date.addMinutes(vEndTime, -60)
		vEquipmentName = system.tag.readBlocking("[.]../../Equipment Name")[0].value
		
		# Tag Dictionary
		vTagPath_Actual_MachineSpeed = '[default]BASE/Buffering/'+ vEquipmentName + '/MES/Actual/Actual_MachineSpeed'
		vTagPath_Set_MachineSpeed	  = '[default]BASE/Buffering/'+ vEquipmentName + '/MES/Set/Set_MachineSpeed'
		vTagPath_MachineScheduled	  = '[default]BASE/Buffering/'+ vEquipmentName + '/MES/OEE/MachineScheduled'
		vTagPath_MachineRunning	  	  = '[default]BASE/Buffering/'+ vEquipmentName + '/MES/OEE/MachineRunning'	
	
		#vPaths = {vTagPath_Actual_MachineSpeed, vTagPath_Set_MachineSpeed}
	
		# dataSet = system.tag.queryTagHistory(paths=['[default]BASE/Buffering/'+ vEquipmentName + '/MES/Actual/Actual_MachineSpeed', '[default]BASE/Buffering/'+ vEquipmentName + '/MES/Set/Set_MachineSpeed'], startDate=vStartTime, endDate=vEndTime, returnSize=1, aggregationMode="SimpleAverage", returnFormat='Wide')
		dataSet = system.tag.queryTagHistory(paths=[vTagPath_Actual_MachineSpeed,vTagPath_Set_MachineSpeed,vTagPath_MachineScheduled,vTagPath_MachineRunning], startDate=vStartTime, endDate=vEndTime, returnSize=1, aggregationMode="SimpleAverage", returnFormat='Wide')
		
		system.tag.writeBlocking("[.]Historical DataSet", dataSet)
	
		# First convert the cities dataset to a PyDataset.
		pyData = system.dataset.toPyDataSet(dataSet)
		
		# The for loop pulls out the whole row, so typically the variable row is used.
		for row in pyData:
		    # Now that we have a single row, we can loop through the columns just like a list.
		    vt_stamp 			= row[0]
		    vActualSpeed 		= row[1]
		    vSetSpeed 			= row[2]
		    vMachineScheduled 	= row[3]
		    vMachineRunning  	= row[4]
		
		# cleanup for null
		#logger.info( "[[[[[[" + vEquipmentName + "]AS: " + str(vActualSpeed) + " ||SS: " + str(vSetSpeed))
		
		if vActualSpeed is None: vActualSpeed = 0 
		#if vSetSpeed is None or vSetSpeed == 0: vSetSpeed = vActualSpeed 
		#if vSetSpeed == 0: vSetSpeed = 1
		#if vSetSpeed == 0: vSetSpeed = vActualSpeed
		if vMachineScheduled is None: vMachineScheduled = 1
		if vMachineRunning is None: vMachineRunning = 0
		
		logger.info( "222[[[[[[" + vEquipmentName + "]AS: " + str(vActualSpeed) + " ||SS: " + str(vSetSpeed))
		
		if vActualSpeed ==0:
			vOEE_Performance = 0
		
		elif vSetSpeed > 0 and vActualSpeed>0 :
			vOEE_Performance  = (vActualSpeed / vSetSpeed) * 100.0
					
		else:
			vOEE_Performance = 0
			
		vOEE_Availability = (vMachineRunning / vMachineScheduled) * 100.0
		#NoPlan	
		#if vMachineScheduled ==1:
		
		#else:
			#vOEE_Availability=0
		logger.info( "[[[[[[" + vEquipmentName + "]P: " + str(vOEE_Performance) + " ||A: " + str(vOEE_Availability))
		
		system.tag.writeBlocking("[.]OEE_Performance", str(vOEE_Performance))
		system.tag.writeBlocking("[.]OEE_Availability", str(vOEE_Availability))
		logger.info("Trigger off")
		system.tag.writeBlocking("[.]DBDataStoreTrigger", [0])
		logger.info("Trigger off Completed")
		
		logger.info("######")

Kindly help in resolving the issue.
Thanks in advance

Could you format all the code in your question as code? Hit the 🖉 edit link and then select the whole block of code and press the </> button to format it. It will preserve indentation and apply syntax highlighting. Thanks.

Please check the code now.

If this is logging every minute, why not take the script in the DBDatastoreTrigger tag and run it in the Timer tag? Seems overly complex.