Alarm event properties doesn't work in notification pipeline script

Hello,

With reference to Alarm Event properties, I try to access some properties in notification pipeline script block. (def handleAlarm(event))
https://docs.inductiveautomation.com/display/DOC80/Alarm+Event+Properties+Reference

But I always get this error:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 2, in handleAlarm TypeError: publish(): 3rd arg can't be coerced to byte

at org.python.core.Py.TypeError(Py.java:265)

at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:211)

at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:314)

at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:323)

at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:169)

I need to access these properties of current alarm to make my message packet.

def handleAlarm(event):
"""
Called for each alarm event that passes through the block. To cancel the
event, call "event.cancelNotification()". Note: The event received is
actually an "event instance", and properties set on it are only local to the
event while it is in the pipeline. To set properties that persist between
changes in state, use "event.setGlobal(name, value)".

Arguments:
event: The alarm event instance. Properties can be accessed, set, and
created using dictionary syntax.
"""
system.cirruslink.engine.publish('MyHome','Alert', event.EventValue ,1,0)

Try system.util.getLogger("debug").info(str(type(event.EventValue))) - I’m guessing the type will either be NoneType or some unexpected datatype, rather than the raw bytearray the cirruslink function is expecting.

Thanks. I try for example event.priority & event.displayPath but instead the correct value i get following:

<type 'com.inductiveautomation.ignition.common.alarming.AlarmPriority'>
<type 'com.inductiveautomation.ignition.common.StringPath'>

How can I get simple string value for those? for example 'low' for priority.

displayPath you can just call str() on. The same should work for priority, but just in case; AlarmPriority is an enum - event.priority.name() should return "Diagnostic", "Low", etc.

1 Like

Thanks I got it now that's my mistake. what about associated data? Can I use event.get(my associated data name) in pipeline script block?

I’m pretty sure that should work, yes.

1 Like