Hello. I have a gateway script that fires at a given time. How can I make a given time tied to a tag? I need to change the execution time of a script by entering the time in a memory tag.
type or paste code here
```from time import localtime, strftime
curTime = strftime("%H:%M", localtime())
if curTime == "07:47":
PR_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value
tags = ['[default]TESTSTARTSTOP/Active power9']
values = [PR_value]
system.tag.writeAll(tags, values)
You need to make your memory tag a Date data type. Is that what you have?
Also, what are the settings you’ve configured on the gateway script? i.e. execution rate, etc. got a screenshot?
Thank`s. The script worked.
Is it possible to enter into the memory tag with the data type data not the whole date “Fri Jun 12 09:08:20 EEST 2020” ?.I need to enter only time HH:mm to memory tag.
You could use a string type and just enter that in. You would need to ensure that it’s entered in the correct format though. You could use the formatted input field with the right format mask expression (e.g. ##:##), if this is something you want to display on the screen for editing.
Then you would just use:
from time import localtime, strftime
curTime = system.date.format(system.date.now(), 'HH:mm')
setpointTime = system.tag.read("[default]StringTypeMemoryTag").value # assumes value in the format "HH:mm"
if curTime == setpointTime:
PR_value = system.tag.read('[default]TESTSTARTSTOP/09:00').value
tags = ['[default]TESTSTARTSTOP/Active power9']
values = [PR_value]
system.tag.writeAll(tags, values)
You could do some error checking in the script to check format if you wanted to