Is it possible to access associated alarm data from alarm objects return by the system.alarm.queryStatus() function?
Finally found a solution and share that here in case it is useful to anyone else.
Basically the activeData object of each alarm in the list returned form system.alarm.queryStatus() has a bunch of properties within that include any associated(Custom) properties, by iterating though all the activeData properties and building a Python Dict, I could then test the Dict keys to see if my associated data was present, I guess there is better way but it works.
alarms = system.alarm.queryStatus( priority = ['Low', 'Medium', 'High', 'Critical'],
state = ["ActiveUnacked", "ActiveAcked"]
)
for alarm in alarms:
props={}
for item in alarm.activeData:
props[str(item.getProperty())]=item.getValue()
if 'associatedDataName ' in props.keys():
Process the property here
3 Likes
How do you process the property. I have associated data named group and can print the prop that shows the he prop data including yhe group but i can figure out how to test if that group equals something do something else
if 'associatedDataName' in props.keys():
#processing associated data example:
associatedDataValue = props['associatedDataName']
print associatedDataValue #do something with this value
This works nicely. My Associated Data name is Alarm Description
.
eventID = [("EventId","=","255600b2-fa1c-4182-9660-a405ee11e572")]
results = system.alarm.queryStatus(all_properties=eventID)
result = results[0]
print("result property Alarm Description = " + str(result.get("Alarm Description")))