I have been having trouble with using the filterAlarm script configuration on the alarm status table. I have multiple things I want to filter but even the simplist form is not working. I am using print in the console to ensure that the item are being check and are the same I search for but still not working.
Here is my code:
def filterAlarm(self, alarmEvent):
source = alarmEvent.get("source")
system.perspective.print(source)
if source == "prov:default:/tag:pilot/Alarm/genProblem:/alm:supProblem":
system.perspective.print("in the if")
return True
else:
system.perspective.print("in else")
return False
this is my table:
And when the script is applied everything is return False
Any help would be amazing!
alarmEvent.get("source")
isn't returning a string, it's returning a QualifiedPath object that happens to convert to the string you specified when asked to do so, such as by system.perspective.print
(You can confirm this by system.perspective.print
ing type(source)
).
So you can either
- compare strings to strings:
if str(source) == "prov:default:/tag:pilot/Alarm/genProblem:/alm:supProblem":
- compare qualified paths to qualified paths:
from com.inductiveautomation.ignition.common import QualifiedPath
path = QualifiedPath.parse("prov:default:/tag:pilot/Alarm/genProblem:/alm:supProblem")
if source == path
- Extract the parts you care about from the qualified path:
tag = "pilot/Alarm/genProblem"
alarm = "supProblem"
if source.getPathComponent("tag") == tag && source.getPathComponent("alarm") == alarm:
1 Like
Thank you so much I thought it would be something small that I was missing.
I also had another question about filter and that was if you would be able to filter the table to grab a specific on-call roster and the people in it?
Tags are globally scoped objects with no 'attachment' to users. You certainly could retrieve a roster in the script, but how are you going to correlate it with a particular tag? A tag can have any number of alarm pipelines, and those pipelines can have any number of notification blocks, and those notification blocks can have dynamic rosters associated with them, so it would be very fragile to tie things together.
1 Like
I have set alarm tags that do not need to be visible to some session users so based on my session props I wanted to have those alarms only be visible to the employees that need to see them so that it is not overwhelming. When designing this I have certain alarms for certain station and therefor supervisors of only their station need to see those alarms and not other supervisors.
I was planning on using either system.alarm.getRosters() based on tag name to compare with the session props. Or system.roster.getRoster() also based on tag name then call getUsers() to get compare to session props.
If you can guarantee (or at least assume) that something like alarm/tag names indicates strongly who needs to 'care' about certain alarms, then yes, it's definitely doable.
1 Like
Perfect! Just wanted to make sure that I wasn't thinking of something totally out of left field.