# Xiaomi Mi Smart Home Binding - Smart Plugs Error

**URL:** <https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429>\
**Category:** Bindings\
**Tags:** xiaomi, xiaomibinding\
**Created:** [December 18, 2017, 12:42pm UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429 "2017-12-18T12:42:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![swinsmore](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@swinsmore](https://community.openhab.org/u/swinsmore)\
**Post date:** [December 18, 2017, 12:42pm UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/1 "2017-12-18T12:42:47Z")

</div>

Hi - I have a Xiaomi gateway with a few zigbee smart sockets and temperature sensors. I can see all of the items (discovered via Paper UI) in the console as well as the updated values from power consumption and temperature.

However whenever I try and send a command to a device i.e. toggle power via a switch I receive a Null Pointer exception in openHAB. I don’t not have any other errors. I have provided the developer key to the gateway configuration.

Any ideas?

```javascript
2017-12-18 23:34:05.811 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred while calling handler: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:220)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:374)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:47)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[:1.8.0_151]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_151]
Caused by: java.lang.NullPointerException
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.toJsonValue(XiaomiBridgeHandler.java:319)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.sendCommandToBridge(XiaomiBridgeHandler.java:257)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.sendCommandToBridge(XiaomiBridgeHandler.java:239)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToDevice(XiaomiBridgeHandler.java:266)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiActorPlugHandler.execute(XiaomiActorPlugHandler.java:42)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:97)[185:org.openhab.binding.mihome:2.1.0]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:377)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:1)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)[98:org.eclipse.smarthome.core:0.9.0.b5]
	... 12 more

```

---

<div class="post-metadata">

**Author:** ![Simsal](https://community.openhab.org/user_avatar/community.openhab.org/simsal/32/18122_2.png) [@Simsal](https://community.openhab.org/u/Simsal)\
**Post date:** [December 18, 2017, 2:38pm UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/2 "2017-12-18T14:38:30Z")

</div>

Plz post your thing and item definitions and corresponding rules

---

<div class="post-metadata">

**Author:** ![swinsmore](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@swinsmore](https://community.openhab.org/u/swinsmore)\
**Post date:** [December 20, 2017, 3:48am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/3 "2017-12-20T03:48:55Z")

</div>

Thanks Simon - I installed the binding and discovered/created the items using Paper UI so I cant see the .items/.things in the usual openHAB/config location.

Should I delete them and try creating them manually?

Cheers

---

<div class="post-metadata">

**Author:** ![swinsmore](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@swinsmore](https://community.openhab.org/u/swinsmore)\
**Post date:** [January 8, 2018, 3:21am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/4 "2018-01-08T03:21:56Z")

</div>

Hi All, now that the holiday season is over I can add some more detail to this post. It looks to me that the toggle command (ON/OFF) is sent successfully, but the logs show that as soon as the command is sent in the event log the Null Point error occurs on the server - see 14:10:24.449 .

Any ideas of how or where to troubleshoot? Currently I can see the values for the Xiaomi devices i.e. status / power consumption with no issues in OpenHab, I even have persistence working to graph the consumption over time. The only sticky point is I cant send commands.

Below are the logs from my event and OpenHab files;

**Event Logs**

```auto
2018-01-08 14:10:24.449 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command OFF
2018-01-08 14:10:24.460 [ItemStateChangedEvent] - mihome_sensor_plug_158d0001debc5b_power changed from ON to OFF

2018-01-08 14:10:36.196 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:36.199 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:36.203 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:36.311 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:38.970 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:38.971 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:38.972 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:39.018 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:39.230 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:39.233 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:39.236 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:39.239 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:39.404 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:39.409 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:39.410 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:39.439 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:39.580 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:39.581 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:39.582 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:39.626 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:39.751 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:39.755 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:39.758 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:39.799 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:39.899 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:39.900 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:39.901 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:39.938 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:40.116 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:40.121 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:40.125 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:40.141 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:40.188 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:40.193 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:40.196 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:40.271 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:40.339 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:40.340 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:40.341 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:40.377 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH
2018-01-08 14:10:40.561 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_power' received command REFRESH
2018-01-08 14:10:40.566 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_inUse' received command REFRESH
2018-01-08 14:10:40.566 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_loadPower' received command REFRESH
2018-01-08 14:10:40.589 [ItemCommandEvent] - Item 'mihome_sensor_plug_158d0001debc5b_powerConsumed' received command REFRESH

```

**OpenHAB Log**

```auto
2018-01-08 14:10:24.459 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred while calling handler: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:220)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:374)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:47)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)[98:org.eclipse.smarthome.core:0.9.0.b5]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[:1.8.0_151]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[:1.8.0_151]
	at java.lang.Thread.run(Unknown Source)[:1.8.0_151]
Caused by: java.lang.NullPointerException
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.toJsonValue(XiaomiBridgeHandler.java:319)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.sendCommandToBridge(XiaomiBridgeHandler.java:257)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.sendCommandToBridge(XiaomiBridgeHandler.java:239)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToDevice(XiaomiBridgeHandler.java:266)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiActorPlugHandler.execute(XiaomiActorPlugHandler.java:42)[185:org.openhab.binding.mihome:2.1.0]
	at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:97)[185:org.openhab.binding.mihome:2.1.0]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:377)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.thing.internal.ThingManager$4.call(ThingManager.java:1)[105:org.eclipse.smarthome.core.thing:0.9.0.b5]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218)[98:org.eclipse.smarthome.core:0.9.0.b5]
	... 12 more

```

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![namraccr](https://community.openhab.org/user_avatar/community.openhab.org/namraccr/32/36484_2.png) [@namraccr](https://community.openhab.org/u/namraccr)\
**Post date:** [January 8, 2018, 3:28am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/5 "2018-01-08T03:28:38Z")

</div>

> [@swinsmore](#):
>
> Thanks Simon - I installed the binding and discovered/created the items using Paper UI so I cant see the .items/.things in the usual openHAB/config location.

You can also look at these definitions in the Karaf console, I believe.

---

<div class="post-metadata">

**Author:** ![swinsmore](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@swinsmore](https://community.openhab.org/u/swinsmore)\
**Post date:** [January 8, 2018, 5:17am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/6 "2018-01-08T05:17:33Z")

</div>

> [@namraccr](#):
>
> You can also look at these definitions in the Karaf console, I believe.

Thanks namraccr, are you familiar with the commands in Karaf to view these?

---

<div class="post-metadata">

**Author:** ![namraccr](https://community.openhab.org/user_avatar/community.openhab.org/namraccr/32/36484_2.png) [@namraccr](https://community.openhab.org/u/namraccr)\
**Post date:** [January 9, 2018, 5:20am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/7 "2018-01-09T05:20:46Z")

</div>

I believe they’re:

```auto
smarthome:items list
smarthome:things list

```

---

<div class="post-metadata">

**Author:** ![swinsmore](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@swinsmore](https://community.openhab.org/u/swinsmore)\
**Post date:** [January 15, 2018, 5:56am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/8 "2018-01-15T05:56:08Z")

</div>

Thanks namraccr, after some more testing this error only occurs when trying to send commands to the Xiaomi Smart Plugs. I can successfully send commands to the Xiamo Gateway i.e. turn on the light with no issues.

I would really appreciate some help on this one, as this is the last kind of significant functionally I am missing (cant get working) for my entire home automation solution.

Thank you

---

<div class="post-metadata">

**Author:** ![namraccr](https://community.openhab.org/user_avatar/community.openhab.org/namraccr/32/36484_2.png) [@namraccr](https://community.openhab.org/u/namraccr)\
**Post date:** [January 15, 2018, 6:47am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/9 "2018-01-15T06:47:12Z")

</div>

It’s not clear to me that there’s anything actually wrong here. Your items are getting the updates you expect, right?

You really should get a debug log and see if it sheds any light on which item is causing the error message.

---

<div class="post-metadata">

**Author:** ![swinsmore](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@swinsmore](https://community.openhab.org/u/swinsmore)\
**Post date:** [January 28, 2018, 7:58am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/10 "2018-01-28T07:58:03Z")

</div>

Hi All - just to round out this thread, a quick update that I was able to solve this problem by using the Zulu Java Platform instead of the standard Oracle JRE/JDK.

I got the idea for testing this theory in the installation overview of the openHAB docs; [https://docs.openhab.org/installation/](https://docs.openhab.org/installation/)

---

<div class="post-metadata">

**Author:** ![fandy](https://community.openhab.org/user_avatar/community.openhab.org/fandy/32/17358_2.png) [@fandy](https://community.openhab.org/u/fandy)\
**Post date:** [February 18, 2018, 11:04am UTC](https://community.openhab.org/t/xiaomi-mi-smart-home-binding-smart-plugs-error/37429/11 "2018-02-18T11:04:34Z")

</div>

Im using Rasberry Pi, do you have any idea how about to change to oracle JRE?
