Xiaomi MiHome Gateway not responding (Solved)

you create a file xiaomi.items:

// Xiaomi Gateway
Switch Gateway_LightSwitch <light> { channel="mihome:gateway:<ID>:brightness" }
Dimmer Gateway_Brightness <dimmablelight> { channel="mihome:gateway:<ID>:brightness" }
Color Gateway_Color <rgb> { channel="mihome:gateway:<ID>:color" }
Dimmer Gateway_ColorTemperature <heating> { channel="mihome:gateway:<ID>:colorTemperature" }
Number Gateway_AmbientLight <sun> { channel="mihome:gateway:<ID>:illumination" }
Number Gateway_Sound <soundvolume-0> { channel="mihome:gateway:<ID>:sound" }
Switch Gateway_SoundSwitch <soundvolume_mute> { channel="mihome:gateway:<ID>:enableSound" }
Dimmer Gateway_SoundVolume <soundvolume> { channel="mihome:gateway:<ID>:volume" }

// Xiaomi Temperature and Humidity Sensor
Number HT_Temperature <temperature> { channel="mihome:sensor_ht:<ID>:temperature" }
Number HT_Humidity <humidity> { channel="mihome:sensor_ht:<ID>:humidity" }
Number HT_Battery <battery> { channel="mihome:sensor_ht:<ID>:batteryLevel" }
Switch HT_BatteryLow <energy> { channel="mihome:sensor_ht:<ID>:lowBattery" }

try, it will not be worse;)
do not forget to replace with real IDs

didn’t work. Now everything double and no data as well. I don’t think it’s the items as everything is showing correct in PaperUI, just no updates on the temperature sensor (only after restarting the system) and absolutely no data from the gateway but I can see all functions and things and items (channels) are all good.
BTW, where do you get the ID from for the gateway (I use the mac address from the gateway info in the app)?

I have checked the log files and found this error message:

2017-10-14 12:18:59.499 [ERROR] [ternal.profiles.DefaultMasterProfile] - 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) ~[?:?]

Caused by: java.lang.NullPointerException
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:69) ~[?:?]
at org.openhab.binding.mihome.internal.EncryptionHelper.encrypt(EncryptionHelper.java:42) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.getEncryptedKey(XiaomiBridgeHandler.java:291) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.createDataJsonString(XiaomiBridgeHandler.java:277) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:273) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:188) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.writeBridgeLightColor(XiaomiActorGatewayHandler.java:184) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler.execute(XiaomiActorGatewayHandler.java:73) ~[?:?]
at org.openhab.binding.mihome.handler.XiaomiDeviceBaseHandler.handleCommand(XiaomiDeviceBaseHandler.java:104) ~[?:?]
at org.eclipse.smarthome.core.thing.internal.profiles.DefaultMasterProfile$1.call(DefaultMasterProfile.java:54) ~[?:?]
at org.eclipse.smarthome.core.thing.internal.profiles.DefaultMasterProfile$1.call(DefaultMasterProfile.java:1) ~[?:?]
at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218) ~[?:?]
… 27 more

Perhaps this might be the cause of the problems I have. Would be really nice if one of the xiaomi binding devs could jump in here.

Thank you!

If you get values but cant control send commands to your things, it might be a developer key problem.

Thank you Brian for your response - greatly appreciated. I also think it could be a token problem but how can I solve that? I don’t think that i can influence the token in openHAB.
Anyway, I have a bigger problem now as I get error 503: Service unavailable. I have opened another post for that but sadly no response. I think I have to wait until openHAB is really stable.

This works on the latest version. I think you did something wrong.
Have you read this thread?

third screen, MiHome device ID

Yes, I have read the thread (not everything, too long :-). Your print screens looks the same as mine, except I have a different MiHome device ID (of course). I got the ID from the Mi Home app in about, gateway information and from there the “mac” ID. The gateway hasn’t shown up in the inbox so I had to add the gateway manually (thing) and enter the ID. BTW, my gateway is version lumi_gateway.v3.

es, I have the same!
firmware 1.4.1_150.0143

do you have a gateway and an OpenHAB in one subnet?
I think in the manual gateway to add it is not correct, it is necessary to achieve its appearance in the inbox

The gateway has it’s own ip address which I added to the Xiaomi Bridge (thing) but everything is in the same wifi network. I don’t really understand the subnet question.
The gateway definitely doesn’t appear in the inbox. The temperature and humidity sensor does (weard?).

as I did (from memory):

  1. Tied the gateway to the Wi-Fi.
  2. Set the binding
  3. In the incoming appeared 2 devices
    above figure 3 and this:

  1. registered a developer key (optional for a temperature sensor)
  2. in the application on the phone added devices (temperature, motion, buttons, etc.), they immediately appeared in the inbox.
    I did not create a file of things, only items

can you try to delete the files of things and items, delete the binding, stop the OpenHAB service, clear the temp and cache, restart the computer, set the binding and look into the incoming?

maybe I do not know if you need to find out if port 9898 is open. Who is open? can this port use anyone else? I’m not a Linux expert, I do not know how to do this, unfortunately :frowning:

Thanks a lot Sergey for your patience - really appreciated.
I just installed everything from scratch (openHAB) with the same result.
When I install the binding (addons) nothing happens. Only when I also manually add Xiaomi Mi Smart Home Bridge as a thing the temperature sensor shows up in the inbox but no gateway.
I checked the subnet and everything is in the same subnet. port 9898 is open as per netstat but only udp6 but no state, no tcp.

tomorrow, if there is time, I will try to reinstall the gateway and write as I did, but I do not promise, I’m sick, I can not come to work at
write how the port was checked, I will do it at myself, I will show the result

Thank you Sergey. First get healthy again, that’s much more important. Perhaps there is somebody else who knows a bit more about ports than we do. I now belief it’s the port 9898 which causes the problem.
Wish you good recovery.

write down what commands you did, to check the port, I’ll try it myself and show how it looks to me

new (clean) installation of OpenHAB

add a gateway to the android application
add sensors in the android application
I press +

here, too, I click

here, too, I click

automatically appear sensors, added in the application android

I did not enter the developer key, it is needed for the gateway itself, for example it is possible without it

well, then we add things, create a file of items as written in the first posts, now there is no time, if necessary, tomorrow I’ll finish it, but I think you do not even have to work here

1 Like

Thanks a lot olymp for the print screens.
In my case the Xiaomi Gateway (Xiaomi Mi Smart Home Bridge) isn’t being detected. I have to install manually (+ button) and then the Temperature & Humidity Sensor are in the inbox but not the Xiaomi Mi Smart Home Gateway. The temp. & hum. sensor shows all information but never gets updated when temp/hum changes.
I have installed Home Assistant just to check whether I will have same problems. After installing HA the gateway is detected and I just have to add the key, mac, and ip address in the config file. Temperature & Humidity are shown but never updated. Gateway I cannot turn on light.
So the situation is that HA detects the gateway whereas openHAB doesn’t (needs to be manually installed). But the result is In both cases the same: temperature. & humidity is shown but not updated and the gateway isn’t responsive.
Conclusion is that there must be something wrong with the gateway (but app is working fine) or the router.
I read here and in HA forum that a few people were successful with resetting the gateway. I have tried this once with the same result and I don’t wanna do that again as I had great difficulties to get the gateway connected again (app).
Unfortunately my adventure into home automation hasn’t had a good start. I will wait and perhaps there will be a firmware update for the gateway in the near future (has been mentioned in a forum somewhere).
Thanks again for the help - really appreciated.
BTW: testing connection with sudo nmap -sU -p9898 192.168.x.xxx showed everything okay.
Starting Nmap 7.01 ( https://nmap.org ) at 2017-10-20 14:03 JST
Nmap scan report for 192.168.x.xxx
Host is up (0.090s latency).
9898/udp open unknown
MAC Address: xx:xx:xx:xx:xx:xx (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 0.58 seconds

Update: finally I got it working - just before I wanted to give up. It was the firewall (ubuntu). I turned it off and the gateway popped up in the inbox. Now I have created a rule in the firewall and all is good. Firewall and openHAB are living peacefully together now.
Thanks for all the help!

PS. Perhaps somebody could make a hint to check firewall in the installation guide.

1 Like

мои поздравления! Напишите, что добавили в бранмауэр?

Thank you! Firewall has to be disabled for the gateway to appear in the inbox. After that adding a rule to the firewall is enough (see attached print screen). To add the rule go to Report, find port 9898 and highlight it, then press the plus button at the bottom to add a new rule. This is for ubuntu 16.04.

1 Like

Thank you so much for this! :star_struck:

I had my firewalls turned off and assumed this wouldn’t/couldn’t be the issue, but the moment I created a rule for port 9898 incoming and deleted the manually created xiaomi things, the Gateway Bridge showed up through regular thing discovery in the Inbox, followed by my other Xiaomi devices after adding it.

The heartbeat is being logged every 10 sec on the debug/trace logs (set via log:set DEBUG org.openhab.binding.mihome and log:set TRACE org.openhab.binding.mihome under the Karaf console via PuTTY) :grinning:

Devices can also be controlled, including Xiaomi Plug and Gateway, and interactions by Switch and Door/Window sensor are also being recorded and acted on :nerd_face: