I was on my lunch break and about to type out pretty much exactly what you have there, so good stuff. For posterity, I’ll post it anyways:
Basically, yes.
The PyAlarmEvent
wrapper has some helper methods to allow you to retrieve properties by name alone. By going to the ‘sourceEvent’ object, you’re no longer able to use those helper methods.
There are a few options:
- Go through the
properties
list and find the one with the name you’re after:
def findProperty(propertyset, propertyname):
for prop in propertyset.properties:
if prop.name == propertyname:
return prop
activeData = event.sourceEvent.getActiveData()
prop = findProperty(activeData, "PropertyName")
if prop != None:
value = activeData.getOrDefault(prop)
- Find a reference to the property you’re looking for in the SDK. Depending on your version of Ignition, this might be easier or harder, but you could start with, e.g.
CommonAlarmProperties