Rule Mixing Items and Channel Triggers, triggeringItem handling

When mixing of channels and itms in the when clause I am not sure how handle the “triggeringItem”.
getName is throwing exception, though triggeringItem is not NULL.

Any ideas how to handle that gracefully?

rule "React on 1 press long (ArbeitszimmerRemote_1PRESSLONG) change/update"
when
	Channel "homematic:HM-PB-6-WM55:3014f711a0001f58a9924711:NEQ1004711:1#PRESS" triggered LONG or
	Item startupProxy changed to ON
then
    try{
		if (triggeringItem.getName == "startupProxy" ) return;
		
		if ( ArbeitszimmerLichtDecke_Dimmer.state == 0) {
			sendCommand(ArbeitszimmerLichtDecke_Dimmer, "1")
			sendCommand(ArbeitszimmerLichtDecke_AbsTemperature, "2500")
		}
		else
			{sendCommand(ArbeitszimmerLichtDecke_Dimmer, "0")}
  	} catch(Exception e) {sendCommand(ArbeitszimmerLichtDecke_Dimmer, "0")}
end

Instead of…

… you could use…

if (triggeringItem instanceof SwitchItem) return;

To get more specific, in case you had other switches in the triggers, you could add…

if (triggeringItem instanceof SwitchItem && triggeringItem.name == "startupProxy") return;
1 Like