Move from OH2 to 3, Rule no longer works

Hey Guys, I’ve been making the move to OH3 and I’m almost there.
I have a rule that doesn’t work anymore, I use this rule to switch inputs on an HDMI matrix that is connected via a usb to serial adapter.

I have the serial adapter working and I can send commands to the matrix so I can rule out issues with the serial binding, I only have issues when I try to send the command from this rule. I get the following error whenever I try to change sources:

2021-08-18 13:12:09.658 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Media-1' failed: cannot invoke method public abstract java.lang.String org.openhab.core.items.Item.getName() on null in Media

My Items:

String GofancoMatrix "HDMI Matrix" { channel="serial:serialBridge:interface:string" }
Number LivingSource_1 "Living Room Source"
Number FamilySource_2 "Family Room Source"
Number FPRSource_3 "Fireplace Room Source"
Number GarageSource_4 "Garage Source"

My Rules:

rule "Switch Inputs"
	Item LivingSource_1 received update or	 
	Item FamilySource_2 received update or
	Item FPRSource_3 received update or 
	Item GarageSource_4 received update
	val  num ="_").get(1)
	val transmitMsg = if(triggeringItem.state as Number == 0) num+"$." else triggeringItem.state.toString+"V"+num+"."

I’m unclear as to why I’m having this issue, I expected this to work after copying from my older OH2 setup. Any help is very much appreciated.


1 Like

Thanks Rossko, btw do you have any solution for grabbing a variable from a number item state?

here is an example:

rule "Office Remote Nuisance Detection 1"
	Item OfficeRemoteON changed from OFF to ON or
	Item OfficeRemoteFAN changed from OFF to ON or
	Item OfficeRemoteOFF changed from OFF to ON or
	Item OfficeRemoteRaise changed from OFF to ON or
	Item OfficeRemoteLower changed from OFF to ON 
		if (OfficeRemotePressTimer.state==OFF) OfficeRemotePressTimer.sendCommand(ON)
		var Number PressCount = OfficeRemotePressCount.state as DecimalType ////This Line Here
		PressCount = PressCount + 1
		if (PressCount == 5) OfficeRemoteEnable.sendCommand(OFF)

edit there is a second rule to this:

rule "Office Remote Nuisance Detection 2"
	Item OfficeRemotePressTimer received command OFF
	//var Number PressCount = 0

Nevermind I switched “as Decimal Type” to “as Number” everything great now.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.