# OH3: NullPointerException on Button-Click

**URL:** <https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390>\
**Category:** Items & Sitemaps\
**Tags:** zigbee, button, deconz\
**Created:** [April 25, 2021, 10:55pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390 "2021-04-25T22:55:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lrifri](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@Lrifri](https://community.openhab.org/u/Lrifri)\
**Post date:** [April 25, 2021, 10:55pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/1 "2021-04-25T22:55:20Z")

</div>

Hi,

currently in the process of migrating my OH2 setup to OH3.  
In the browser-ui all the items, etc. are looking and behaving good/as expected.  
But according to the logs I’m running into NullPointerExceptions.

The entries are created/displayed **everytime** a (physical) button/bwitch is being pressed  
(got some Xiaomi switch-buttons and one Ikea on/off-switch, all connected via deCONZ-binding,  
but none of their items are linked to any of my rules).

Currently on openHAB 3.1.0.M3, hoped switching to milestone would solve the problem, but it didn’t.  
(Already reinstalled all my bindings at first and even OH as well.)

Log-Entry:

```auto
2021-04-26 00:09:39.262 [ERROR] [internal.events.ThreadedEventHandler] - Error on event handling.
java.lang.NullPointerException: null

```

Thing:

```auto
   switch Swtch_Onff_Ikea_01_Plrm "Swtch_Onff_Ikea_01_Plrm" [id="65"] //

```

Items:

```auto
    Group G_Swtch_Onff_Ikea_01_Plrm "Ikea-Button" <wallswitch> (G_Lctn_Plrm)                                    
    Number Onff_Ikea_01_Plrm_Button "Button" <wallswitch> (G_Swtch_Onff_Ikea_01_Plrm) {channel="deconz:switch:phoscon:Swtch_Onff_Ikea_01_Plrm:button"}
    DateTime Onff_Ikea_01_Plrm_Last_Updated "Last updated" <time> (G_Swtch_Onff_Ikea_01_Plrm) {channel="deconz:switch:phoscon:Swtch_Onff_Ikea_01_Plrm:last_updated"}
    Number Onff_Ikea_01_Plrm_Battery_Level "Battery level" <battery> (G_Swtch_Onff_Ikea_01_Plrm) {channel="deconz:switch:phoscon:Swtch_Onff_Ikea_01_Plrm:battery_level"}
    Switch Onff_Ikea_01_Plrm_Battery_Low "Low battery" <battery> (G_Swtch_Onff_Ikea_01_Plrm) {channel="deconz:switch:phoscon:Swtch_Onff_Ikea_01_Plrm:battery_low"}
    DateTime Onff_Ikea_01_Plrm_Last_Seen "Last seen" <time> (G_Swtch_Onff_Ikea_01_Plrm)

```

Have been looking all over the forums & google for hints of what i could do,  
but didnt find any. Would really appreciate any of your ideas/solutions.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [April 25, 2021, 11:45pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/2 "2021-04-25T23:45:45Z")

</div>

Did you make a new Thing, or re-use the OH2 one?

---

<div class="post-metadata">

**Author:** ![Lrifri](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@Lrifri](https://community.openhab.org/u/Lrifri)\
**Post date:** [April 25, 2021, 11:51pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/3 "2021-04-25T23:51:11Z")

</div>

I recreated everything from scratch.

---

<div class="post-metadata">

**Author:** ![Lrifri](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@Lrifri](https://community.openhab.org/u/Lrifri)\
**Post date:** [April 28, 2021, 12:11am UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/4 "2021-04-28T00:11:35Z")

</div>

Can I provide anymore information, or details for you? Really wondering if the messages / their cause is gamebreaking, or kinda acceptable for now. Thank you again!

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [April 28, 2021, 12:31am UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/5 "2021-04-28T00:31:45Z")

</div>

You might try DEBUG logging on the binding, it may reveal which Item update or trigger event is connected to the message.

Or temporarily remove one of your text Things and see what gets discovered instead.

---

<div class="post-metadata">

**Author:** ![Lrifri](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@Lrifri](https://community.openhab.org/u/Lrifri)\
**Post date:** [April 28, 2021, 5:58pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/6 "2021-04-28T17:58:23Z")

</div>

Thanks for your response.

Getting the same error for every ‘switch thing’ - even when deleted and added via the GUI.

I’m not getting any conclusions out of the logs, despite there’s one additional value called **windowopen** that is =‘null’ instead of =null - could this be a pointer?

**OH2:**

```auto
2021-04-28 19:41:51.334 [TRACE] [nternal.netutils.WebSocketConnection] - Raw data received by websocket: {"e":"changed","id":"60","r":"sensors","state":{"buttonevent":1000,"lastupdated":"2021-04-28T17:41:51.331"},"t":"event","uniqueid":"00:15:8d:00:04:07:54:3e-01-0006"}
2021-04-28 19:41:51.335 [TRACE] [ernal.handler.SensorBaseThingHandler] - deconz:switch:Phoscon-GW:mi_switch_02 received SensorMessage{type='', config=null, state=SensorState{dark=null, daylight=null, lightlevel=null, lux=null, temperature=null, humidity=null, open=null, fire=null, water=null, alarm=null, tampered=null, vibration=null, carbonmonoxide=null, pressure=null, presence=null, power=null, battery=null, consumption=null, voltage=null, current=null, status=null, buttonevent=1000, gesture=null, valve=null, lastupdated='2021-04-28T17:41:51.331', xy=null}, e='changed', r='sensors', t='event', id='60', manufacturername='', modelid='', name='', swversion='', ep='', lastseen='null', uniqueid='00:15:8d:00:04:07:54:3e-01-0006'}

```

**OH3:**

```auto
2021-04-28 19:45:27.067 [TRACE] [nternal.netutils.WebSocketConnection] - Websocket$1619260450738-1 received raw data: {"e":"changed","id":"60","r":"sensors","state":{"buttonevent":1000,"lastupdated":"2021-04-28T17:45:27.064"},"t":"event","uniqueid":"00:15:8d:00:04:07:54:3e-01-0006"}
2021-04-28 19:45:27.068 [TRACE] [ernal.handler.SensorBaseThingHandler] - deconz:switch:phoscon:Swtch_Bttn_Mi_02_Lvngrm received SensorMessage{type='', config=null, state=SensorState{dark=null, daylight=null, lightlevel=null, lux=null, temperature=null, humidity=null, open=null, fire=null, water=null, alarm=null, tampered=null, vibration=null, carbonmonoxide=null, pressure=null, presence=null, power=null, battery=null, consumption=null, voltage=null, current=null, status=null, buttonevent=1000, gesture=null, valve=null, windowopen='null', lastupdated='2021-04-28T17:45:27.064', xy=null}, e='changed', r='SENSORS', t='event', id='60', manufacturername='', modelid='', name='', swversion='', ep='', lastseen='null', uniqueid='00:15:8d:00:04:07:54:3e-01-0006'}
2021-04-28 19:45:27.069 [ERROR] [internal.events.ThreadedEventHandler] - Error on event handling.
java.lang.NullPointerException: null

```

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [April 28, 2021, 7:56pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/7 "2021-04-28T19:56:45Z")

</div>

So far as I can see, `windowopen` is supported and is a string type.

> <https://github.com/openhab/openhab-addons/issues/9233>
>
> I'm using the Danfoss Ally Thermostats in openHAB and would love to use a channe…l with the information about the "Open Window Detection". @J-N-K Is it possible to enhance the binding?

---

<div class="post-metadata">

**Author:** ![Confectrician](https://community.openhab.org/user_avatar/community.openhab.org/confectrician/32/105046_2.png) [@Confectrician](https://community.openhab.org/u/Confectrician)\
**Post date:** [April 28, 2021, 8:16pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/8 "2021-04-28T20:16:52Z")

</div>

Could be related to:

> <https://github.com/openhab/openhab-core/issues/2231>
>
> Hi together,
> 
> I am facing some strange NPEs in ThreadedEventHandler for quite …a while now.
> 
> The NPE occurs when i receive trigger events from my hue dimmer switch.
> I use rules to catch those events and do some light scene stuff.
> The NPE also occurs when my complete rule is disabled and not handled.
> 
> Error log from my productive environment 
> \- Ubuntu Server 20.04 VM 
> \- running a manual openhabian installation
> \- openjdk 11.0.10 2021-01-19 LTS
> \- OpenJDK Runtime Environment Zulu11.45+27-CA (build 11.0.10+9-LTS)
> \- OpenJDK 64-Bit Server VM Zulu11.45+27-CA (build 11.0.10+9-LTS, mixed mode)
> 
> \`\`\`
> 17:53:58.613 \[ERROR\] \[.internal.events.ThreadedEventHandler\] - Error on event handling.
> java.lang.NullPointerException: null
> at java.lang.String.contains(String.java:2036) ~\[?:?\]
> at org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler.apply(ChannelEventTriggerHandler.java:91) ~\[?:?\]
> at org.openhab.core.internal.events.EventHandler.dispatchEvent(EventHandler.java:143) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:111) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:84) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) \[bundleFile:?\]
> at java.lang.Thread.run(Thread.java:834) \[?:?\]
> 17:53:59.134 \[ERROR\] \[.internal.events.ThreadedEventHandler\] - Error on event handling.
> java.lang.NullPointerException: null
> at java.lang.String.contains(String.java:2036) ~\[?:?\]
> at org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler.apply(ChannelEventTriggerHandler.java:91) ~\[?:?\]
> at org.openhab.core.internal.events.EventHandler.dispatchEvent(EventHandler.java:143) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:111) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:84) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) \[bundleFile:?\]
> at java.lang.Thread.run(Thread.java:834) \[?:?\]
> \`\`\`
> 
> Error in my test environment i have setup to exclude my setup as failure source:
> 
> \- debian-10.8.0-i386 VM 
> \- running a manual openhabian installation
> \- openjdk 11.0.10 2021-01-19 LTS
> \- OpenJDK Runtime Environment Zulu11.45+27-CA (build 11.0.10+9-LTS)
> \- OpenJDK Server VM Zulu11.45+27-CA (build 11.0.10+9-LTS, mixed mode)
> 
> Fresh install with a cli restored backup of my productive environment.
> 
> \`\`\`
> 
> 17:51:00.708 \[ERROR\] \[.internal.events.ThreadedEventHandler\] - Error on event handling.
> java.lang.NullPointerException: null
> at java.lang.String.contains(Unknown Source) ~\[?:?\]
> at org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler.apply(ChannelEventTriggerHandler.java:91) ~\[?:?\]
> at org.openhab.core.internal.events.EventHandler.dispatchEvent(EventHandler.java:143) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:111) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:84) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) \[bundleFile:?\]
> at java.lang.Thread.run(Unknown Source) \[?:?\]
> 17:51:01.239 \[ERROR\] \[.internal.events.ThreadedEventHandler\] - Error on event handling.
> java.lang.NullPointerException: null
> at java.lang.String.contains(Unknown Source) ~\[?:?\]
> at org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler.apply(ChannelEventTriggerHandler.java:91) ~\[?:?\]
> at org.openhab.core.internal.events.EventHandler.dispatchEvent(EventHandler.java:143) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:111) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:84) ~\[bundleFile:?\]
> at org.openhab.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) \[bundleFile:?\]
> at java.lang.Thread.run(Unknown Source) \[?:?\]
> \`\`\`
> 
> 
> I first though of a malformed installation on my productive system, but since the error is occuring on a fresh install now too i wanted to document the behavior here.

I am facing NPE’s in ThreadedEventHandler while using HUE switches.  
Are the switch buttons configured with a trigger channel? I don’t know how the deconz binding works.

---

<div class="post-metadata">

**Author:** ![Lrifri](https://community.openhab.org/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@Lrifri](https://community.openhab.org/u/Lrifri)\
**Post date:** [April 28, 2021, 9:19pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/9 "2021-04-28T21:19:37Z")

</div>

Indeed seeming pretty similar to me, thank you for mentioning.

Yes, the binding is providing a buttonevent for the switches via a trigger-channel,  
whose value in passed to a “last pressed” number-channel.

Just had a look on a HUE-Dimmer-Switch, also giving a NPE in the end.

```auto
2021-04-28 23:06:00.218 [TRACE] [nternal.netutils.WebSocketConnection] - Websocket$1619260450738-1 received raw data: {"e":"changed","id":"32","r":"sensors","state":{"buttonevent":1000,"eventduration":0,"lastupdated":"2021-04-28T21:06:00.216"},"t":"event","uniqueid":"00:17:88:01:02:e2:c5:8d-02-fc00"}
2021-04-28 23:06:00.218 [DEBUG] [nternal.netutils.WebSocketConnection] - Couldn't find listener for id 32 with resource type SENSORS. Either no thing for this id has been defined or this is a bug.
2021-04-28 23:06:00.251 [ERROR] [internal.events.ThreadedEventHandler] - Error on event handling.
java.lang.NullPointerException: null
	at java.lang.String.contains(String.java:2036) ~[?:?]
	at org.openhab.core.automation.internal.module.handler.ChannelEventTriggerHandler.apply(ChannelEventTriggerHandler.java:91) ~[?:?]
	at org.openhab.core.internal.events.EventHandler.dispatchEvent(EventHandler.java:143) ~[bundleFile:?]
	at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:111) ~[bundleFile:?]
	at org.openhab.core.internal.events.EventHandler.handleEvent(EventHandler.java:84) ~[bundleFile:?]
	at org.openhab.core.internal.events.ThreadedEventHandler.lambda$0(ThreadedEventHandler.java:67) [bundleFile:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]

```

---

<div class="post-metadata">

**Author:** ![Confectrician](https://community.openhab.org/user_avatar/community.openhab.org/confectrician/32/105046_2.png) [@Confectrician](https://community.openhab.org/u/Confectrician)\
**Post date:** [April 30, 2021, 12:58pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/10 "2021-04-30T12:58:15Z")

</div>

Would be neat if you add your findings (binding, config, logs) to the linke issue, so we collect all relevant information over there too for someone who may be able to reproduce this.

---

<div class="post-metadata">

**Author:** ![Jacco\_Jurg](https://community.openhab.org/user_avatar/community.openhab.org/jacco_jurg/32/77289_2.png) [@Jacco\_Jurg](https://community.openhab.org/u/Jacco_Jurg)\
**Post date:** [May 3, 2021, 8:06am UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/11 "2021-05-03T08:06:23Z")

</div>

I had an exactly similar issue in the log with Deconz buttons. I found I had created a rule in the UI rule editor to test the new engine that was not complete. When I removed/disabled the rule the error disappeared. Maybe a longshot but check if there isn’t another rule causing this.

---

<div class="post-metadata">

**Author:** ![Confectrician](https://community.openhab.org/user_avatar/community.openhab.org/confectrician/32/105046_2.png) [@Confectrician](https://community.openhab.org/u/Confectrician)\
**Post date:** [May 3, 2021, 6:44pm UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/12 "2021-05-03T18:44:01Z")

</div>

Thanks for sharing your findings.

That could be the reason for my environment too, since i have testing rules “lying around” nearly all of the time…  
I will check my installation for such a case too.

---

<div class="post-metadata">

**Author:** ![J-N-K](https://community.openhab.org/user_avatar/community.openhab.org/j-n-k/32/19276_2.png) [@J-N-K](https://community.openhab.org/u/J-N-K)\
**Post date:** [February 16, 2022, 8:21am UTC](https://community.openhab.org/t/oh3-nullpointerexception-on-button-click/121390/13 "2022-02-16T08:21:45Z")

</div>

I know it’s a very long time, but do you remember what was “incomplete” in the rule?
