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"
when
Channel "shelly:shelly2-relay:XXXXXX:device#alarm" triggered or
Channel "shelly:shelly2-relay:YYYYYY:device#alarm" triggered or
... more Shelly devices listed
then
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!")
}
end
reportAlarm() handles alarm submission via e-mail and Telegram, that’s not the problem.