Checking if any tag in a folder is active

In my application i have some tags imported from kepware, i would like to check if any of the values within my alarms folder of the tags are active and to bind this to make a component visible.

(this is the method I’ve tried thinking by setting the tag path to the folder it would return the number of alarms active and could therefore say true unless 0. But it just always returns 2 for some reason.)


I don’t know if this is even possible, any advice would be greatly appreciated.

Could you send a summary bit (or int) from the origin point of the alarms? That would probably be the cleanest solution. If that’s not an option, the script below will get all the first level tags of a provided root folder. This isn’t an especially efficient solution, so you should be cautious about using it. If you need to get all the tags in child folders you’ll have to write a function for recursive browsing (several examples can be found in other forum posts.)

rootPath = '[default]machineCenter/machine/control/alarms'
tags = system.tag.browse(rootPath)
values = [i['value'].value for i in tags]
print any(values)
1 Like

Thank you zacht i took a little time to understand this concept but it has led me to the solution!

1 Like