Uncertain initial value when I use system.tag.configure!

hello

i’m using system.tag.confgure to enable and disable alarms by scripting, when executing it for the first time the quality of the tag changes to 'uncertain initial value.

def overrideAlarmConfig(tagPath, alarmName, alarmProperty, value):
	config = system.tag.getConfiguration(tagPath)[0]
	for alarm in config['alarms']:
		if alarm['name'] == alarmName:
			alarm[alarmProperty] = value
			break
	basePath = tagPath.rsplit('/',1)[0]
	system.tag.configure(basePath, config, 'm')

overrideAlarmConfig("[default]D33/BO01/PIT_1001/PR2/MINS", "High", "enabled", 'true')```

'''

thanks you

Unfortunately, setting some properties at the top level of a tag with system.tag.configure, even to what should be their current value, causes weird side effects. I bumped into this with the tag quality. The simplest solution I’ve found is to pass only the bare minimum config back into system.tag.configure when using “merge” mode.
Try this:

def overrideAlarmConfig(tagPath, alarmName, alarmProperty, value):
	tagName = tagPath.split('/')[-1]
	basePath = tagPath.rsplit('/',1)[0]
	config = [ { 'name':tagName, 'alarms':[ { 'name':alarmName, alarmProperty:value } ] } ]
	system.tag.configure(basePath, config, 'm')

overrideAlarmConfig("[default]D33/BO01/PIT_1001/PR2/MINS", "High", "enabled", 'true')```


its working, but clears the other properties

Which version of Ignition are you running? I’ve used almost this exact method to enable/disable alarms without modifying any other properties of the tag or the alarm in 8.0.12 and newer.

Oh! Maybe the “true” value you are passing in should be a native Python True instead of a string. (I didn’t even notice that on my first read through…)

1 Like

It doesn’t work, I have tried putting True instead of true.
behaves like an ‘overwrite’ instead of merge

Did you use True without the quotes?

I have tried to use it without quotes and with quotes, I attach the screenshots from before and after executing the code.


the code:

def overrideAlarmConfig(tagPath, alarmName, alarmProperty, value):
	tagName = tagPath.split('/')[-1]
	basePath = tagPath.rsplit('/',1)[0]
	config = [ { 'name':tagName, 'alarms':[ { 'name':alarmName, alarmProperty:value } ] } ]
	system.tag.configure(basePath, config, 'm')

overrideAlarmConfig("[BB2]D45/BO01/PIT_1002/PR2/MINS", "High", "enabled", False)

Doesn’t tagPath have to be a list of tags even if its just one tag?

tagPath has more tags, but I just want to change the alarm property on a tag.
aa

I’m fairly certain it is being caused by the tag being part of a UDT instance and you are attempting to override it and not just change the value of enabled.
I am not familiar enough with version 8 yet to say how to override and not just change a tags enabled property.

yes, it looks like it’s doing an overwrite instead of merging. is there a more correct way to change the properties of an alarm?