[SOLVED] 'getEvent' is not a member error since OH 2.4

Hi,
I’ve been having an issue with rules for Xiaomi button and cube events since upgrading to OH 2.4. It worked fine with test releases (Milestones 1,3, 7 and 8) but since the final release I’ve been getting

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Xiaomi Cube’: ‘getEvent’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 166, column 22, length 24

The same goes for button events

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Xiaomi Switch Button’: ‘getEvent’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 248, column 22, length 24

The rules have been running fine up until then so I don’t think it’s the rules.

rule “Xiaomi Switch Button”
when
Channel ‘mihome:sensor_switch_aq2:xxx:xxx:button’ triggered
then
var actionName = receivedEvent.getEvent()
//logInfo(“Xiaomi Button”, actionName)
switch(actionName)
{
case “SHORT_PRESSED”: {
logInfo(“Xiaomi Button”, actionName)
}
case “DOUBLE_PRESSED”: {
logInfo(“Xiaomi Button”, actionName)
if (Light_Bedroom_Sw.state!=ON) // item OFF or uninitialized
Light_Bedroom_Sw.sendCommand(ON)
else
Light_Bedroom_Sw.sendCommand(OFF)
}
}
end

Try using switch(receivedEvent.getEvent()) no variable.

Example:

rule “Xiaomi Switch Button”
when
Channel ‘mihome:sensor_switch_aq2:xxx:xxx:button’ triggered
then
//logInfo(“Xiaomi Button”, actionName)
switch(receivedEvent.getEvent()) 
{
case “SHORT_PRESSED”: {
logInfo(“Xiaomi Button”, actionName)
}
case “DOUBLE_PRESSED”: {
logInfo(“Xiaomi Button”, actionName)
if (Light_Bedroom_Sw.state!=ON) // item OFF or uninitialized
Light_Bedroom_Sw.sendCommand(ON)
else
Light_Bedroom_Sw.sendCommand(OFF)
}
}
end

Tried that and still got the same error message

2018-12-30 17:20:23.653 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Xiaomi Switch Button’: ‘getEvent’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 250, column 12, length 24

You may need to clean the cache and reboot, especially if you haven’t done this since updating to 2.4

sudo systemctl stop openhab

sudo openhab-cli clean-cache

sudo reboot

Tried that too. Still getting the same error. I have a feeling that if I downgrade to Milestone 3 or 7 or 8 it will work as I remember having to do that previously from one of the other milestones (I think it was Mileston 4 and I downgraded to 3). I’m not sure what could have changed since the Milestones but it seems to break something in the way the Xiaomi binding and/or rules work.

The switch(receivedEvent.getEvent()) like @H102 proposed works for me too without any errors:

rule "Hue Tap Remote"
when
	Channel "hue:0830:0017882e7a2d:5:tap_switch_event" triggered
then
	logInfo("EXTRA", "HUE Tap Remote switch event {}", receivedEvent)
	switch(receivedEvent.getEvent()) {
		case "34.0": {
		logInfo("EXTRA","HUE: Button 1 triggered")
			//do other stuff
		}		
		case "16.0": {
		logInfo("EXTRA","HUE: Button 2 triggered")
			//do other stuff
		}
		case "17.0": {
		logInfo("EXTRA","HUE: Button 3 triggered")
			//do other stuff
		}	
		case "18.0": {
		logInfo("EXTRA","HUE: Button 4 triggered")
			//do other stuff
		}
	}
end

Log:

30-Dez-2018 22:02:43.512 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE Tap Remote switch event hue:0830:0017882e7a2d:5:tap_switch_event triggered 16.0
30-Dez-2018 22:02:43.535 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE: Button 2 triggered
30-Dez-2018 22:02:46.609 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE Tap Remote switch event hue:0830:0017882e7a2d:5:tap_switch_event triggered 17.0
30-Dez-2018 22:02:46.630 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE: Button 3 triggered
30-Dez-2018 22:02:49.170 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE Tap Remote switch event hue:0830:0017882e7a2d:5:tap_switch_event triggered 18.0
30-Dez-2018 22:02:49.191 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE: Button 4 triggered
30-Dez-2018 22:02:50.993 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE Tap Remote switch event hue:0830:0017882e7a2d:5:tap_switch_event triggered 34.0
30-Dez-2018 22:02:51.014 [INFO ] [org.eclipse.smarthome.model.script.EXTRA          ] - HUE: Button 1 triggered
1 Like

@thecrater if your still having the issue then remove the binding, clean the cache, reinstall the binding and see what happens.

I have seen where several items in a file would cause some items to not respond and the solution was to move the trouble items to a separate file. You could try renaming the rules file or create a new file and move the two rules.

Hi all,
I haven’t been able to uninstall and reinstall the binding, however, I edited the things file to comment out the two items (cube and switch) and restarted openhab then uncommented the thing entries and restarted again and it seemed to fix the issue. I hope this helps someone if they ever have the same issue.

@thecrater That would have the same effect as moving them to a different file.:smile: Sometimes cleaning the cache is needed but a simple restart can work as well.

Good to see it’s working and thanks for replying back to let us know. If you would please click the square box on the post that provided the solution and edit the title to start with [Solved]. This will help others with a similar issue find a quick solution.

Thanks

Same with me. I completely deleted not only the Cache, but all configurations in /srv/openhab2-userdata & co. After a reboot and building my OH2 from scratch again (I use config files only) - it worked.
After a while I needed to add some experimental binding (not Xiaomi related) and since then, I again get this ERRORs:

2019-02-04 11:12:32.371 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Aqara Smart Vibration Sensor': 'getEvent' is not a member of 'org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent'; line 5, column 29, length 24

in Event.log it Looks good:

2019-02-04 11:12:32.347 [vent.ChannelTriggeredEvent] - mihome:sensor_vibration:mihome_briefkasten:action triggered VIBRATE
2019-02-04 11:12:32.381 [vent.ItemStateChangedEvent] - PL12VibrationLetterbox_LastAction changed from 2019-02-03T21:16:41.814+0100 to 2019-02-04T11:12:32.352+0100

Do I have to rebuild OH2 again after changes within PaperUI to avoid this ERROR? and ist this a bug in OH2-Core?

I’m running O2.4 stable on my Raspberry Pi within openHABian 1.4 current builds.

Hi Thomas,

I have the slight feeling that we are facing a bug. I see a similar message in my productive environment. It runs on OH 2.5.0 M1. In a second test environment I do not see those messages even when I am using the same rule on both systems. The test system runs on OH 2.5.0 M1 too. That is the funny part. Clearing the cache like recommended above did not help. Maybe we should file an issue in GitHub.

One thing I observed is that it works when I define an event in the rule trigger - maybe others can confirm that:

rule "Seems to work"
when
    Channel "xxx:xxx:whatever:event" triggered EVENT
then
    val event = receivedEvent.getEvent()
    ...
rule "Does not work"
when
    Channel "xxx:xxx:whatever:event" triggered
then
    val event = receivedEvent.getEvent()
    ...

Hi there, I can confirm this behavior.

Works as it should be:

rule "Lamp2"
when
     Channel 'homematic:HMIP-WRC2:XXX:XXX:1#BUTTON'	triggered LONG_PRESSED
then
    var trigger = receivedEvent.getEvent()
    logInfo("hue_rules ","Lamp2 trigger event: " + trigger)

2019-04-07 10:45:20.108 [INFO ] [smarthome.model.script.hue_rules ] - Lamp2 trigger event: LONG_PRESSED

However if I change it to the following, it does not work:

rule "Lamp2"
when
     Channel 'homematic:HMIP-WRC2:XXX:XXX:1#BUTTON'	triggered 
then
    var trigger = receivedEvent.getEvent()
    logInfo("hue_rules ","Lamp2 trigger event: " + trigger)

2019-04-06 17:28:19.811 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Lamp2’: ‘getEvent’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 46, column 20, length 24


Now this is odd
Your suggested workaround worked for me:

rule "Lamp2"
when
     Channel 'homematic:HMIP-WRC2:XXX:XXX:1#BUTTON'	triggered //WORKAROUND
then
    var trigger = receivedEvent.getEvent()
    logInfo("hue_rules ","Lamp2 trigger event: " + trigger)

2019-04-07 13:22:36.655 [INFO ] [smarthome.model.script.hue_rules ] - Lamp2 trigger event: LONG_PRESSED

BUT after I updated the firmware on my CCU3 from ccu3-3.45.5 to ccu3-3.45.7 today, this workaround doesn’t work anymore. And I am not even confident that this error is somehow related to homematic… Very odd

2019-04-07 15:55:24.916 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Lamp2’: ‘getEvent’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 12, column 19, length 24

How can we unsolve this thread?

It would make much more sense to open an issue on GitHub as suggested above. May I ask you to do me that favor. Thanks.

Done :slight_smile:

Hi,
also run in this problem twice …
14 days ago, and than yesterday again.
clean-cache, restart oH not always help.
I minimize the addons.config, clean-cache, and replace the addons.config back to my original file.
After few restarts, clean-cache, Raspi reboot it’s working again, but … no real solution :frowning:

Has anyone news about the bug report, or any hint to prevent this issue with the cube?

Yes, indeed, the solution proposed does not work :frowning: so would be very helpful to unmark this thread as solved.

I guess I have found the issue report on GitHub. Unfortunately, nothing seems to happen there:


The same problem annoys me regularly at restarts of OH. In my setup my 4 Philips Hue dimmers suddenly don’t work anymore because the corresponding getEvent is no longer recognized. It regularly costs me a lot of time until it runs again. The bottom line is that there is no concrete way to do this. In the end there are countless restarts until everything runs again sometime.

My (simplified) code looks likes this:

rule "Dimmer Bed"
when
    Channel "hue:0820:<ID>:HueDimmer_Bed:dimmer_switch_event" triggered
then
	var String ButtonEvent = receivedEvent.getEvent() // often fails after OH restart
	var Number ButtonNumber = Integer.parseInt(ButtonEvent.substring(0,1)) as Number
	var Number ButtonState = Integer.parseInt(ButtonEvent.substring(3,4)) as Number
	// now react to different button numbers and states
	// ...
end

Did you ever find the solution? It’s driving me crazy :’(

Unfortunately not. I have also tried using openHAB 2.5M1 but still no effect. I was recently unable to get this working again (i.e. I am not able to get rid of this ‘getEvent’ is not a member error message anymore) and lots of openHAB restarts including cache clean-ups did not help either. Finally I gave up and decided to disable my code above in openHAB. Now I am using the Philips remote dimmer functionality programmed by the Philips Hue app which is not a solution at all.

Yes, me too. The worst thing is that the WAF of the whole home automation system sigificantly decreased because of me messing around with it for far too many times with no sustainable result. She rightly expects 24/7 working light switches and I am not able to explain plausibly why the system hangs again and again.

1 Like

Did anyone test it on the current snapshot build?

I too have tried this on stable, milestone1 and builds S1623 and currently S1641 (the current latest as of a few days ago).

I have managed to clear mine a few times by commenting out everything in all my rules files, clearing cache+tmp folder, restarting, then individually uncommenting rule files to bring the system up again. It doesn’t work everytime, but its the only way I have managed to get back up and running after getting this error.

I get both ‘channel’ and ‘getevent’ are not members of, where the receivedevent appears to be empty (null testing does not work, I simply can’t access .channel or .getevent as they are “not members of”).

Although no error appears on the logs during build, I have a feeling rules are loading/firing before items are properly initiated.

My setup currently is:
OH snapshot build 1641 running on PC with windows 10
Mqtt broker running on rasbpi
Grafana/influxdb running on rasbpi

My gut feeling is either rules are occuring before items load, or perhaps the restoration of item states from influxdb during OH boot is the issue. Admittedly I am hitting the channel trigger/receivedevent hard at times, so I may be stress testing or hitting this bug due to some limit I am unaware of.