Errors operating Xiaomi Gateway

I have followed the tutorial to configure Xiaomi Bridge with Gateway. My things configuration looks like this:

Bridge mihome:bridge:34ce00fbxxxx "Xiaomi Bridge" @ "Ground Floor"[ serialNumber="34ce00fbxxxx", ipAddress="172.17.xx.xx", port=9898, key="xxx", pollingInterval=300 ] {
        Things:
                gateway 34ce00fbxxxx    "Xiaomi Gateway"        @       "Ground Floor"  [itemId="34ce00fbxxxx"]

                sensor_weather_v1       158d0001b9xxxx  "Xiaomi Temperature Sensor"     @       "Ground Floor"  [itemId="158d0001b9xxxx"]
}

Please note, I had to modify the things file as compared to the tutorial, because in OpenHAB 2.2.0 I was getting an error:

Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>

And now comes my problem. The gateway, bridge and temperature sensor are all visible and online in PaperUI. However, when I try to change any parameter in Control in PaperUI, in opehab.log I get:

2017-12-23 23:27:23.667 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler@64c4e834': null
java.lang.NullPointerException: null
	at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:291) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:277) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:273) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:188) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:184) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:80) [220:org.openhab.binding.mihome:2.2.0]
	at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:104) [220:org.openhab.binding.mihome:2.2.0]
	at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at com.sun.proxy.$Proxy145.handleCommand(Unknown Source) [220:org.openhab.binding.mihome:2.2.0]
	at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:72) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
	at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
	at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

Can you help me to solve it?

I’m just now also working through my new Xiaomi gadgets! :wink:

I avoid declaring anything via PaperUI (the old-fashioned file-based guy as I am). So, I do have this setup:

xiaomi.things

Bridge mihome:bridge:rossbuehel "Xiaomi Gateway" [ serialNumber="34cexxxxxx", ipAddress="192.168.xx.xx", port=9898, key="xx", pollingInterval=5 ] 
{
	Things:
		gateway			34cexxxxxx	"Xiaomi Mi Smart Home Gateway" 	@ "Rossbuehel"		[itemId="34cexxxxxx"]
		sensor_weather_v1	158d0001xxxxxx	"Xiaomi Temperature Sensor" 	@ "Rossbuehel OG"	[itemId="158d0001xxxxxx"]
		sensor_motion_aq2	158d0001xxxxxx 	"Xiaomi Motion Sensor" 		@ "Rossbuehel Eingang"	[itemId="158d0001xxxxxx"]
		sensor_switch		158d0001xxxxxx 	"Xiaomi Mi Wireless Switch" 	@ "Rossbuehel Eingang"	[itemId="158d0001xxxxxx"]
		smoke			158d0001xxxxxx 	"Xiaomi Smoke Detector" 	@ "Rossbuehel OG"	[itemID="158d0001xxxxxx"]
}

xiaomi.items


// Xiaomi Gateway
Switch MiGateway_LightSwitch 		"Gateway Licht"				<light> 		(xiaomi) 		{ channel="mihome:gateway:rossbuehel:brightness" }
Dimmer MiGateway_Brightness 		"Gateway Licht Dimmer [%d %%]" 		<dimmablelight> 	(xiaomi)		{ channel="mihome:gateway:rossbuehel:brightness" }
Color  Gateway_Color 			"Gateway Licht Farbe"			<rgb> 			(xiaomi)		{ channel="mihome:gateway:rossbuehel:color" }
Dimmer Gateway_ColorTemperature	 	"Gateway Licht Farbtemeratur"		<heating> 		(xiaomi)		{ channel="mihome:gateway:rossbuehel:colorTemperature" }
Number Gateway_AmbientLight 		"Gateway Licht Ambient [%.1f]"		<sun> 			(xiaomi)		{ channel="mihome:gateway:rossbuehel:illumination" }
Number Gateway_Sound 			"Gateway Sound Lautstärke [%.1f]"	<soundvolume-0> 	(xiaomi)		{ channel="mihome:gateway:rossbuehel:sound" }
Switch Gateway_SoundSwitch 		"Gateway Sound"				<soundvolume_mute> 	(xiaomi)		{ channel="mihome:gateway:rossbuehel:enableSound" }
Dimmer Gateway_SoundVolume 		"Gateway Sound Volume"			<soundvolume> 		(xiaomi)		{ channel="mihome:gateway:rossbuehel:volume" }

// Xiaomi Temperature and Humidity Sensor
Number MiWeather_Temperature 		"Temperatursensor [%.1f C]"		<temperature> 		(xiaomi)		{ channel="mihome:sensor_weather_v1:rossbuehel:158d0001xxxxxx:temperature" }
Number MiWeather_Humidity 		"Feuchtigkeit [%.1f %]"			<humidity> 		(xiaomi)		{ channel="mihome:sensor_weather_v1:rossbuehel:158d0001xxxxxx:humidity" }
Number MiWeather_Pressure 		"Luftdruck [%.1f] hP"			<pressure> 		(xiaomi)		{ channel="mihome:sensor_weather_v1:rossbuehel:158d0001xxxxxx:pressure" }
Number MiWeather_Battery 		"Temperatursensor Batterie [%.0 %]"	<battery> 		(xiaomi)		{ channel="mihome:sensor_weather_v1:rossbuehel:158d0001xxxxxx:batteryLevel" }
Switch MiWeather_BatteryLow 		"Temperatursensor Batt leer"		<energy> 		(xiaomi)		{ channel="mihome:sensor_weather_v1:rossbuehel:158d0001xxxxxx:lowBattery" }

// Xiaomi Motion Sensor
Switch MiMotionSensor_MotionStatus 	"Bewegung"				<motion>  		(xiaomi)		{ channel="mihome:sensor_motion_aq2:rossbuehel:158d0001xxxxxx:motion" }
Number MiMotionsSensor_Illumination	 "Bewegung Beleuchtung [%.1f]"		<sun>			(xiaomi)		{ channel="mihome:sensor_motion_aq2:rossbuehel:158d0001xxxxxx:illumination" }
// minimum 5 seconds - remember that the sensor only triggers every minute to save energy
Number MiMotionSensor_MotionTimer 	"Bewegung Timer [%.1f s]"		<clock> 		(xiaomi)		{ channel="mihome:sensor_motion_aq2:rossbuehel:158d0001xxxxxx:motionOffTimer" }
DateTime MiMotionSensor_LastMotion	"letzte Bewegung [%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> 	(xiaomi)		{ channel="mihome:sensor_motion_aq2:rossbuehel:158d0001xxxxxx:lastMotion" }
Number MiMotionSensor_Battery 		"Bewegungssensor Batterie [%.1f %]"	<battery> 		(xiaomi)		{ channel="mihome:sensor_motion_aq2:rossbuehel:158d0001xxxxxx:batteryLevel" }
Switch NiMotionSensor_BatteryLow 	"Bewegungssensor Batterie leer"		<energy> 		(xiaomi)		{ channel="mihome:sensor_motion_aq2:rossbuehel:158d0001xxxxxx:lowBattery" }

// Xiaomi Firedetector
Number MiSmokeDetector_Density		"Luftdichte [%.1f]"			<sun>			(xiaomi)		{ channel="mihome:smoke:rossbuehel:158d0001xxxxxx:density" }
Switch MiSmokeDetector_Alarmihome	"FEUERALARM"				<fire>			(xiaomi)		{ channel="mihome:smoke:rossbuehel:158d0001xxxxxx:alarm" }
String MiSmokeDetector_Status		"Rauchmelder Status [%s]"		<fire>			(xiaomi)		{ channel="mihome:smoke:rossbuehel:158d0001xxxxxx:status" }
Number MiSmokeDetector_Battery 		"Rauchmelder Batterie [%.1f %]"		<battery> 		(xiaomi)		{ channel="mihome:smoke:rossbuehel:158d0001xxxxxx:batteryLevel" }
Switch MiSmokeDetector_BatteryLow 	"Rauchmelder Batterie leer"		<energy> 		(xiaomi)		{ channel="mihome:smoke:rossbuehel:158d0001xxxxxx:lowBattery" }

// Xiaomi Switch - see "xiaomi.rules" for action triggers
Number MiSwitch_Battery 		"Button Batterie [%.1f %]"		<battery> 		(xiaomi)		{ channel="mihome:sensor_switch:rossbuehel:158d0001xxxxxx:batteryLevel" }
Switch MiSwitch_BatteryLow 		"Button Batterie leer"			<battery> 		(xiaomi)		{ channel="mihome:sensor_switch:rossbuehel:158d0001xxxxxx:lowBattery" }

Hope that helps…

At the moment I get information from the weather_v1 sensor and I got the switch and the motion sensor running in my test environment. I didn’t manage the smoke detector. On my designated live environment I managed (with the same configuration) to get the weather sensor live. But I guess, it’s Hardware related, because that one is (for now) on a Pi1, and I guess that one simply isn’t strong enough (ist at 100% CPU since I installed the binding).

A question: What’s “pollingInterval” stand for? seconds or milliseconds?

Looks like you are having the same issue as reported here:

https://github.com/openhab/openhab2-addons/issues/3577