receivedEvent.getEvent() is not member of

Hi,

I want to implement a rule to do device monitoring. From my point of view code should be fine.

rule "Monitor Shellys Alarms"
when
	Channel "shelly:shelly2-relay:559f55:device#alarm" triggered or      // 6.81
	Channel "shelly:shellydevice:25a73e:device#alarm" triggered or       // 6.85
	Channel "shelly:shelly25-roller:e59e36:device#alarm" triggered or    // 6.83
	Channel "shelly:shelly1pm:8caab505fcf4:device#alarm" triggered or    // 6.70
	Channel "shelly:shelly25-relay:6933fc:device#alarm" triggered or     // 6.71
	Channel "shelly:shelly25-relay:686ec1:device#alarm" triggered or     // 6.72
	Channel "shelly:shelly25-relay:68fcfb:device#alarm" triggered        // 6.73
then
	logInfo("Shelly", "Shelly Alarm event received")
	val event = receivedEvent.getEvent()
	val channel = receivedEvent.getChannel().asString
	val item = ""
        if  (triggeringItem.label !== null) item = triggeringItem.label else item = triggeringItem.name
	val message = "Alarm for device " + item + ": " + event + " (channel=" + channel + ")"
	logInfo("Shelly", message)

	val telegram = getActions("telegram","telegram:telegramBot:87bf68ae")
	telegram.sendTelegram(message)
	switch (event) {
		case 'OVERTEMP',
		case 'OVERPOWER',
		case 'OVERLOAD',
		case 'LOAD_ERROR',
		case 'RESTARTED',
		case 'LOW_BATTERY':
			telegram.sendTelegram(message)
	}
end

Whatever I try I get errors that the item is not found (triggeringItem) or getEvent() and getChannel() are not a member of receivedItem. I did some search in the forum found an issue indicating that was a problem in 2.5M1, but acc. to GitHub the issue has been solved.

Any hint? It drives we crazy :frowning:

There is never a triggeringItem, because your rule is only ever triggered by channel events. No Item is involved.

thx, makes sense, but receivedEvent.getEvent() and .getChannel even don’t work

is it possible to get the name of the linked item through the channel?

where to find doc for receivedEvent()?

May we see the whole error message.
May we know what OH version you actually run.

It does seem to be a problem that affects some people, and it is not yet clear what is unusual about their systems

There is probably a way to search links using REST API to find any Item(s) linked to a given channel.
But if these channels are linked to Items … why don’t you trigger from Item update or change?

I do see some errors.

val channel = receivedEvent.getChannel().toString()

not asString.

There will be no triggeringItem as rossko57 indicates. Anything having to do with triggeringItem needs to be removed.

VSCode, error when the .rules file is loaded, or when the Rule runs?

Log out receivedEvent all by itself without calling the methods to get the event and channel. Let’s see what it actually is and that it’s not null.