Im trying to create a folder full of expression tags tags with the scripting console. each tag should have a different expression in it, one per hour 0-23. Chat GPT generated this for me, but it generates memory tags, not expression tags. Can someone see what I am doing wrong? Thanks.
# Define the folder where the tags will be created
tagFolder = "[default]Line 4 dashboard/ProductionCounters" # Update with your actual tag path
# List to hold tag configurations
tags = []
for hour in range(24):
tagName = "its_" + str(hour) # Tag names: its_0, its_1, ..., its_23
expression = "getHour(now()) = {}".format(hour) # Expression logic
tagConfig = {
"name": tagName,
"tagType": "AtomicTag", # ✅ Must be "AtomicTag" for expression tags
"dataType": "Boolean",
"expression": expression, # ✅ Correct placement for expressions
"parameters": {
"Expression": expression # ✅ This ensures the tag evaluates dynamically
},
"enabled": True
}
tags.append(tagConfig)
# Create the tags in Ignition
results = system.tag.configure(tagFolder, tags, "o") # "o" to overwrite existing tags if they exist
print("Tag creation results:", results)