Problem with witch(receivedEvent.getEvent()) in Rule after Migration to OH3

Hi Everyone,

after migrating my OH2.5 instance to OH3 (Running as Proxmox Container on Debian & Openhabian / OH 3.3) everything is working fine, exept the rules for my remotes. I have spent some time trying to find a solution on Google and in the forum, but I am not able to pinpoint a solution. Probably I just don’t understand the explanations, as I am no developer.

Here is the code in question:

//Shelly Button 2 WoZi
rule "HM ShellyButton2"
	Channel "shelly:shellybutton1:98cdac2c26cb:status#button" triggered
	switch(receivedEvent.getChannel().toString()) {
		case "SHORT_PRESSED": {
		SteckdoseWoZiSuedOst.sendCommand (ON)
		case "LONG_PRESSED": {
		SteckdoseWoZiSuedOst.sendCommand (OFF)
		case "DOUBLE_PRESSED": {
		LichtEssen.sendCommand (ON)
		case "TRIPLE_PRESSED": {
		LichtEssen.sendCommand (OFF)

VC throws this error:

	"resource": "/Volumes/openHAB-conf/rules/remotes.rules",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "org.eclipse.xtext.diagnostics.Diagnostic.Linking",
	"severity": 8,
	"message": "The method getChannel() is undefined for the type String",
	"startLineNumber": 7,
	"startColumn": 23,
	"endLineNumber": 7,
	"endColumn": 33

I understand that there have been changes with “inherent variables”, yet I cannot figure out what a correct syntax needs to be. Maybe some of you can help me out here please?

Thanks a lot



instead of

as also done in the example docs

Hi Wolfgang, thanks for your reply.

I am sorry, posted the wrong version.

Testet 3 versions:

switch(receivedEvent.getEvent) - this one worked in OH2.5
switch(receivedEvent.getChannel().toString() - the one that i posted, no success
switch(receivedEvent) - testet that one first (the one you mentioned), no success as well

Edit: Cleaned the cache as well…still no success

And which error message do you get in this case:

No message from the VC, hence it looked correct to me in the first place. Still, when clicking the remote, the event itself is seen in the logs, but the rule does nothing and there is no line in the log as well.

Got it. Thanks for your input, helped me to understand that the problem was somewhere else to be found. So it works with “receivedEvent”, it was just that the syntax of the item had changed from OH2.5 to OH3 and I did not realize that. After updating the items in the rules, everything works fine now .

Again thanks for your input and have a great sunday!

1 Like