I've successfully figured out how to bulk import alarms into existing ignition tags, but I'm struggling with bulk deletion of alarms. I have these two functions below which i call with the following command:
alarms.delete.deleteSiteAlarms("SITE1")
# Function to delete alarms for a given tag path
def deleteAlarms(tagPath):
# Get the tag configuration
tagConfig = system.tag.getConfiguration(tagPath, True)
# Check if the tag has alarm configurations
if 'alarms' in tagConfig[0]:
# Print the alarms that will be deleted
print "Deleting alarms for tag: " + tagPath
for alarm in tagConfig[0]['alarms']:
print " Alarm: " + alarm['name']
# Remove all alarms from the tag configuration
#tagConfig[0].pop('alarms',None)
tagConfig[0]['alarms'] = []
print tagConfig
# Write the updated configuration back to the tag
system.tag.configure(tagPath, tagConfig, 'o')
# Function to delete all alarms for a given site ID
def deleteSiteAlarms(siteId):
# Define the path to the tag folder
tagFolderPath = "[default]Edge Nodes/TAGS01/"+ siteId + "/tags/"
# Get the list of tags under the specified folder
tags = system.tag.browse(tagFolderPath, {'tagType':'AtomicTag','recursive':True})
# Iterate through each tag in the folder
for tag in tags.getResults():
# Get the full tag path
fullTagPath = tag['fullPath']
# Check if the tag is an AtomicTag and has alarms
if 'attributes' in tag and 'alarm' in tag['attributes']:
deleteAlarms(str(fullTagPath))
However, no matter what I do the, the system.tag.configure function does not seem to be removing the alarm configuration from the existing tags. The script runs with no errors and no errors in the output console.
I've tried both fully removing the 'alarms' key from the json and leaving the 'alarms' key in but empty. Neither seems to work.
Any help here is greatly appreciated.