Print name of tag on Label when tag goes high

Hi,

I have a tag folder with a number of Bool tags. I want to create a label that is displaying the name of the tag in case any of the tags in the folder goes high. Scripting assistance would be much appreciated.

Cheers

If the folder isn’t too big, I’d just use an expression like this

if({path/to/tag1}, "tag 1",
if({path/to/tag2}, "tag 2",
if({path/to/tag3}, "tag 3",
   "All tags low"
)))

It’s a bit repetitive, but it would work fine. If you want to auto-detect what tags are in the folder, you can do it by browsing the tags, but it will end up way harder as you will probably need to set up your own polling.

That did work although I am looking to have more than 100 tags in the folder so ideally I'm looking for a script to navigate through the folder and print the name of any tag that is high. Thanks for your reply though.

As I do want to display a number of different tags on the same label, in case they go high the script above only worked when I named 1 tag. Carrying on with the rest that looks like the script below gives me error.

if({[default]Device1/AS-i/I1_Fault}=1, “I1_Fault”,
if({[default]Device1/AS-i/I2_Fault}=1, “I2_Fault”,
if({[default]Device1/AS-i/O1_Fault}=1, “O1_Fault”,
if({[default]Device1/AS-i/O2_Fault}=1, “O2_Fault”,
“All tags low”
)))

Scripting to browse and then check status of many tags like this will be a performance disaster in scripting. I recommend using a client tag change event script, listing all of the tags in the folder. Use a top-level object in a script module to maintain a list (or a set) of the tags that are true, adding and removing values as events are triggered. The end of the event script would deposit the base name or names of true tags into a string client tag for the label to use.

The key reason for this approach is that the tags will be subscribed, and changes delivered efficiently, instead of a script having to poll them all on an interval.

Would it be possible to contact you via email for a more detailed description?

Well, my policy is to only provide free advice/code/designs in public, and only as I have quiet time available.

But if you want to engage my professionals services, a PM to get started would be fine... (:

1 Like