system.alarm.queryStatus source as list

When using a list in the source, from my tests it looks like no matter what I have in the 2nd index (and on) that the source will evaluate true. For example,

state = ["ActiveUnacked", "ActiveAcked"]
source = '*MyFolder*', '*Does not matter what goes here*'
alarms = system.alarm.queryStatus(source=source, path=path, state=state)
print alarms

Can anyone explain how multiple items in a list for the source is supposed to evaluate? If I use source and path separately it works, but if I ever want to use 3 items in a list I don't think that would be an option.

https://docs.inductiveautomation.com/display/DOC81/system.alarm.queryStatus

The way it's defined currently, I believe source is actually a tuple not a list. Could you try wrapping the value of source in square brackets? So it would then be source = ['*MyFolder*', '*Does not matter what goes here*']

Sorry, I should have mentioned that, I tried that in the beginning. It doesn't seem to need the brackets, but regardless, I tried with and without.

Seems to be working for me.
What do you mean by "will evaluate true" ?

Will return alarms

Are you just seeing alarms returned that match the first source?

Yes, it will follow what I have in the first index, but doesn't seem to honor what I have in the second index
Using 8.1.22

Can you swap the order to make sure it isn't something to do with that second source?

Doesn't seem to make a difference for the order. I am running this test from the script console. Maybe I will try a good ole restart just for giggles.

The results should be a list of alarm events that match any of the source paths. What are the results you're expecting? Are you looking for the resulting alarm events to match both source paths?

I'm testing in the script console on 8.1.22 as well and the results I'm seeing are what I would expect.

Do you mean you get the same list independently of the order, or that the second source, no matter which one it is, always returns something that looks wrong ?

What's the output of

state = ["ActiveUnacked", "ActiveAcked"]
source = '*source1*', '*source2*'
alarms1 = set(al.source for al in system.alarm.queryStatus(source=source, state=state))

source = '*source2*', '*source1*'
alarms2 = set(al.source for al in system.alarm.queryStatus(source=source, state=state))

print alarms1 ^ alarms2

It should be an empty set.

PS: Don't use source AND path. They do the same thing, so just pick one. Maybe using both at the same time somehow messes things up ?

Ahh, any, not all. I guess that was my confusion, I thought it was all.

1 Like