Filter out alarm

I am filtering alarms based on a folder partial name lets say CB2 using the display path filter CB2.

The problem is there are inhib alarms ending in INHIB that i do not want to show.

I have tried a script

Def filterAlarm(self, alarmevent):
       name = alarmevent.get("name")
       If name != "%INHIB%":
              Return True
       Return False

Thus doesnt seem to do anything. I dint have any errors in the console log but the inhib alarms still show in the alarm table.

Any help would be appreciated.

And yes there are astericks on both sides of CB2.

Python doesn't have LIKE operator, and supplying % to a python comparison doesn't magically make it work that way. What python does have is the in operator, which will return true if a string is anywhere within another string.

(Please fix your post to apply code formatting using the "preformatted text" button in the forum editor. So I can copy and paste from your code to make an example.)

sorry about that i haven't ever posted code before.

I think i got it with

Def filterAlarm(self, alarmevent):
       name = alarmevent.get("name")
       If "INHIB"  not in name
              Return True
       Return False

Given Python's case sensitive key words, I would be surprised if that snippet ran. There are several words capitalized that shouldn't be.

I didn't test, but this should be logically equivalent to the snippet above (with improved capitalization).

def filterAlarm(self, alarmevent):
    name = alarmevent.get("name")
    return "INHIB"  not in name
3 Likes