Hello community fellows!
In my jython scripts, I will need to find out what item caused the rule to trigger in case i have multiple triggers for the rule that involves several items.
After experimenting for a while I came up with the following solution.
def execute(self, module, inputs):
# Get the item state as state
triggerItemState = inputs['event'].getItemState()
# Get the event type as string
triggerType = inputs['event'].getType()
if triggerType == 'ItemStateEvent':
# Get the item that triggered
item = ir.getItem(inputs['event'].getItemName())
self.logger.info('item: ' + item.name + ' has a new state: ' + str(triggerItemState))
It might happen there is a better way to do it. If you happen to know one, please feel free to suggest it here.
Cheers!