# Tag Even Change Based on Time of Running Timer Tag

**URL:** <https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999>\
**Category:** Ignition\
**Created:** [October 5, 2018, 5:43pm UTC](https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999 "2018-10-05T17:43:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim.Canan](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@Tim.Canan](https://forum.inductiveautomation.com/u/Tim.Canan)\
**Post date:** [October 5, 2018, 5:43pm UTC](https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999/1 "2018-10-05T17:43:14Z")

</div>

Can someone help me figure out how to get the below script working? It works for the first specified execution and tag path (WC216), but doesn’t work for the next two tag paths. Is this because the time is no longer what it needs to be to run the script? If so, how can I overcome this? I’d really appreciate any help. Thanks!

```auto
def wcStatusOff(tagPath):
	
		dsKey = 6057
                workcenterKey = system.tag.read(tagPath + '/Workcenter/Workcenter_Key').value
		paramters = {"Workcenter_Key": workcenterKey}
		result = system.cumulus.ds.exec(webServiceId,dsKey,paramters)

		if 'resultSet' in result.keys():

			for row in result['resultSet']:

						if len(row['Logged_Operators']) == 0:

										webServiceId = system.tag.read(tagPath + '/Web_Service_ID').value
										plcName = system.tag.read(tagPath + '/Workcenter/PLC_Name').value
										status = system.cumulus.request.Production.updateStatus(webServiceId,'6065',plcName,'Off','')							   

										if status['outputParameters']['Result_Error'] == 'True':

														print 'Error'

										else:

														print 'Success'
														system.tag.write(tagPath + '/Workcenter/Workcenter_Status','Off')
														
	                                                                                               
	
wcStatusOff('HMI_Lite/PLCs/WC216')
wcStatusOff('HMI_Lite/PLCs/WC216')	
wcStatusOff('HMI_Lite/PLCs/WC216')

```

---

<div class="post-metadata">

**Author:** ![Tim.Canan](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@Tim.Canan](https://forum.inductiveautomation.com/u/Tim.Canan)\
**Post date:** [October 5, 2018, 6:52pm UTC](https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999/2 "2018-10-05T18:52:33Z")

</div>

My mistake, I didn’t paste the first line in. Please see below.

if ‘07:03:00’ in str(currentValue) or ‘13:18:00’ in str(currentValue) or ‘15:33:00’ in str(currentValue) or ‘20:03:00’ in str(currentValue) or ‘22:15:00’ in str(currentValue) or ‘01:33:00’ in str(currentValue):

def wcStatusOff(tagPath):

```
	dsKey = 6057
            workcenterKey = system.tag.read(tagPath + '/Workcenter/Workcenter_Key').value
	paramters = {"Workcenter_Key": workcenterKey}
	result = system.cumulus.ds.exec(webServiceId,dsKey,paramters)

	if 'resultSet' in result.keys():

		for row in result['resultSet']:

					if len(row['Logged_Operators']) == 0:

									webServiceId = system.tag.read(tagPath + '/Web_Service_ID').value
									plcName = system.tag.read(tagPath + '/Workcenter/PLC_Name').value
									status = system.cumulus.request.Production.updateStatus(webServiceId,'6065',plcName,'Off','')							   

									if status['outputParameters']['Result_Error'] == 'True':

													print 'Error'

									else:

													print 'Success'
													system.tag.write(tagPath + '/Workcenter/Workcenter_Status','Off')

```

wcStatusOff(‘HMI\_Lite/PLCs/WC216’)  
wcStatusOff(‘HMI\_Lite/PLCs/WC216’)   
wcStatusOff(‘HMI\_Lite/PLCs/WC216’)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 5, 2018, 7:07pm UTC](https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999/3 "2018-10-05T19:07:37Z")

</div>

I didn’t look close, because your indentation is messed up. You can’t mixed indenting by spaces with tabs. And really, with tabs, just use one for each level.

---

<div class="post-metadata">

**Author:** ![Tim.Canan](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@Tim.Canan](https://forum.inductiveautomation.com/u/Tim.Canan)\
**Post date:** [October 5, 2018, 7:22pm UTC](https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999/4 "2018-10-05T19:22:25Z")

</div>

Thanks for the reply. In my actual script, the indentation is correct. I copied and pasted from a notepad file and somehow the indentation got messed up.

---

<div class="post-metadata">

**Author:** ![jhuff](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jhuff](https://forum.inductiveautomation.com/u/jhuff)\
**Post date:** [January 11, 2019, 3:04pm UTC](https://forum.inductiveautomation.com/t/tag-even-change-based-on-time-of-running-timer-tag/19999/5 "2019-01-11T15:04:58Z")

</div>

Tim, did you ever get this resolved? You probably have, but more importantly I noticed you are using the Cumulus module. Is that to PLEX. My company is doing a bunch of development in this area and I was excited to see someone else who is doing it too. Are you using PLEX?
