triggeredChannel in a OH3 rule - how to implement

I’m running on OH 3.1M5 on Raspian and want to adapt the alarm rule from OH2 to OH3. The Shelly things have a trigger channel, which fire different types of events. Those will be catched by a rule to send an alarm by e-mail and Telegram. Mechanism works in general, but I’m not able to determine the triggering channel in the rule.

I saw that the implicit receivedEvent variable has been refined and is no a String returning the event, but no longer an Object, which also returns the triggering channel. I checked the documentation and noticed that only receivedEvent and triggeredItem, but not triggeredChannel are available as implicit variables for rules. How can I access this information.

The objective is to have one rule for all Shelly Things and all alarm types.

My rule:

rule "Monitor Shellys Alarms"
	Channel "shelly:shelly2-relay:XXXXXX:device#alarm" triggered or
	Channel "shelly:shelly2-relay:YYYYYY:device#alarm" triggered or
... more Shelly devices listed
	logInfo("Shelly", "Shelly Alarm event received: " + receivedEvent)
	var event = receivedEvent
	var channel = "" //triggeredChannel -> how to get this  one?
	var message = "An alarm condition was detected: "+event +", device: "+channel
	logInfo("Shelly", message)

	switch (event) {
		case 'OVERTEMP',
		case 'OVERPOWER',
		case 'OVERLOAD',
		case 'LOAD_ERROR',
		case 'LOW_BATTERY':
			reportAlarm.apply(houseId, mailTo, "openHAB Alarm", message, mailFooter)		
		case 'RESTARTED':
			logInfo("Shelly", "Device " + channel + " restarted!")

reportAlarm() handles alarm submission via e-mail and Telegram, that’s not the problem.


this works:

var channel = triggeringChannel

I like the rule and use it already! As my things have human readable names, I am wondering if there is any chance to add the name of the thing into the message even though the channel of the thing triggered the rule to fire?

Checking the page here tells me:

triggeringThing - implicitly available in every rule that has a thing-based trigger.

As the rule uses Channel based trigger, the error was expected:

 Script execution of rule with UID 'shelly_alarms-1' failed: The name 'triggeringThing' cannot be resolved to an item or type; line 46, column 17, length 15 in shelly_alarms

Any idea?

You mean, get a part of the channel UID string like " shelly:shelly2-relay"?