Xiaomi smart home sensor no any events

Hello, help me make my xiaomi smart home sensor working


Bridge mihome:bridge:7811xxx “Xiaomi Bridge” @ “Xiaomi” [ serialNumber=“xxx”, ipAddress=“”, port=9898, key=“xxx”, pollingInterval=1000 ]
gateway xxx “Xiaomi Mi Smart Home Gateway” @ “Xiaomi” [itemId=“xxx”]
sensor_motion1 xxx “Xiaomi Motion sensor 1” @ “Xiaomi” [itemId=“xxx”]
sensor_motion2 xxx “Xiaomi Motion sensor 2” @ “Xiaomi” [itemId=“xxx”]
sensor_magnet1 xxx “Xiaomi Magnet sensor 1” @ “Xiaomi” [itemId=“xxx”]
sensor_magnet2 xxx “Xiaomi Magnet sensor 3” @ “Xiaomi” [itemId=“xxx”]
sensor_magnet3 xxx “Xiaomi Magnet sensor 4” @ “Xiaomi” [itemId=“xxx”]
sensor_magnet4 xxx “Xiaomi Magnet sensor 4” @ “Xiaomi” [itemId=“xxx”]
sensor_switch1 xxx “Xiaomi Magnet switch 1” @ “Xiaomi” [itemId=“xxx”]

in Paper.IU it’s OK
but only for 2 things. All other sensor in inbox!? but why?

if i linking any of sensor, i se no any information in thing

You need to use the correct channel names in your things config.
sensor_magnet1 needs to be sensor_magnet, or if you are using the Aquara version it’s sensor_magnet_aq2
Check the docs:

10x, all sensors now in things
but still no any events

try to ON light on gateway - nothing


14:54:00.802 [DEBUG] [ihome.handler.XiaomiDeviceBaseHandler] - Device 7811dce1ab5c on channel mihome:gateway:7811dce1ab5c:7811dce1ab5c:brightness received command ON
14:54:00.824 [INFO ] [smarthome.event.ItemStateChangedEvent] - mihome_gateway_7811dce1ab5c_7811dce1ab5c_brightness changed from 0 to 100
14:54:00.850 [WARN ] [ng.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.
14:54:00.892 [DEBUG] [ng.mihome.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:7811dce1ab5c: {“cmd”: “write”, “model”: “gateway”, “sid”: “7811dce1ab5c”, “short_id”: “0”, “data”: “{“rgb”: 1694468489, “key”: “”}”}
14:54:00.921 [TRACE] [g.mihome.internal.socket.XiaomiSocket] - Sending message: {“cmd”: “write”, “model”: “gateway”, “sid”: “7811dce1ab5c”, “short_id”: “0”, “data”: “{“rgb”: 1694468489, “key”: “”}”} to /
14:54:00.945 [DEBUG] [ome.handler.XiaomiActorGatewayHandler] - Update ON for channel mihome:gateway:7811dce1ab5c:7811dce1ab5c:brightness received
14:54:00.946 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from on Port 9898
14:54:00.969 [TRACE] [ng.mihome.handler.XiaomiBridgeHandler] - Received message {“cmd”:“write_ack”,“sid”:“7811dce1ab5c”,“data”:"{“error”:“Invalid key len”}"}
14:54:00.981 [TRACE] [ng.mihome.handler.XiaomiBridgeHandler] - Updated “last time seen” for device 7811dce1ab5c
14:54:00.995 [DEBUG] [ng.mihome.handler.XiaomiBridgeHandler] - Device 7811dce1ab5c honored write request
14:54:01.005 [DEBUG] [ihome.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“write_ack”,“sid”:“7811dce1ab5c”,“data”:"{“error”:“Invalid key len”}"}
14:54:01.042 [TRACE] [g.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
14:54:01.050 [TRACE] [g.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-231,5,main] waiting for data on port 9898

wrong key ?

I’m not using manual thing configuration so can’t help with that.
Autodiscovered gateway and sensors look like this, maybe you can adapt those to your manual things config:

Check the developer key in your app …:grinning:

Also check this posts:

chheck - it’s ok

some time it’s online, some time later

I have the impression that the specified port for binding 9898 is busy with something else

xiaomi home bridge does not appear in the inbox. if you manually add the xiaomi home bridge only then the sensors start to appear in the inbox, without xiaomi gateway. but after a while they become offline.

sudo nmap -sU -p9898 localhost

Starting Nmap 6.47 ( http://nmap.org ) at 2018-08-06 11:05 MSK
Nmap scan report for localhost (
Host is up (0.00011s latency).
Other addresses for localhost (not scanned):
9898/udp closed unknown

Nmap done: 1 IP address (1 host up) scanned in 0.54 seconds

how to understand what service occupies port 9898

Someone can give help, why things do not appear in the inbox

I do have the same issue, did you fix it?

I had same issue, actually the system was working and I change modem/router than I got “no token received …” error, the problem is about modem/router. And also I set Access Point my rpi3b+ but it did not work. The cheap access points and routers does not capable with openhab and xiaomi home smart things.

In my case the error “No token received from the gateway yet. Unable to encrypt the access key.” appeared after moving the OpenHab server to another part of my network. After some investigation it seems that the Xiaomi Gateway cannot be reached when ‘IGMP Snooping’ is turned on on your routers/switches. After turning this off everything worked fine again.