editAlarmConfig replacement for alarm deletion after upgrading to 8.1

Hey everyone,

Just wanted to add this here as it bit me after we upgraded from 7.9 to 8.1.

On 7.9 we could run the following script to remove an alarm from a tag

tagPath = 'Path/To/Tag/MyTag'
alarmName = 'Alarm'
system.tag.editAlarmConfig([tagPath], {alarmName: None})	

On 8.1 the code runs without error, but doesn't delete the alarm. I rewrote the script using system.tag.configure to achieve a similar result. Not as pretty, but it works

basePath = 'Path/To/Tag'
tagName = 'MyTag'
alarmName = 'Alarm'

alarms = [config for config in system.tag.getConfiguration(tagPath, True)[0]['alarms'] if config['name'] != alarmName]
system.tag.configure(basePath, [{'name': tagName, 'alarms': alarms}], 'o')

I tried for a bit to see if i could delete it without grabbing all alarms and excluding the one we don't want but gave up and went with this approch as I didn't want to spend too much time on it.

Hope this helps anyone in the future :slight_smile:

Hmm, that's surprising. We went to some significant pains to ensure backwards compatibility for all the legacy tag functions; it might just be that the None case wasn't one we knew about. Hyrum's law in action yet again.

Out of curiosity, does it work if you explicitly call system.tag.editAlarmConfig([tagPath], alarmConfig={alarmName: None})?

Lol yep! Even after months of testing there was still some stuff I missed.

No luck unfortunately