Xiaomi Mi Smart Home Binding: Bridge goes offline in OH3 M2

Hello. Trying out OH3 M2 and have to say… I miss using text file!

regardless, I am trying to get the Xiaomi bridge setup along with my sensors. Everything seems fine until the bridge goes offline. I get this

16:49:50.327 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - dispose
16:49:50.340 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Interrupting receiver thread Thread[XiaomiSocketReceiveThread(9898, be88f9c4cd),5,]
16:49:50.349 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Closing socket java.net.MulticastSocket@1d1e85c
16:49:50.359 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Init socket on Port: 9898
16:49:50.366 [DEBUG] [me.internal.socket.XiaomiBridgeSocket] - Setup socket
16:49:50.375 [DEBUG] [me.internal.socket.XiaomiBridgeSocket] - Initialized socket to null:-1 on 0.0.0.0/0.0.0.0:9898
16:49:50.395 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing ‘mihome:bridge:be88f9c4cd’ has been updated.
16:49:51.383 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “get_id_list”}
16:49:51.396 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.409 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:bridge:be88f9c4cd’ changed from OFFLINE to ONLINE
16:49:51.418 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_magnet:be88f9c4cd:158d000183fe39’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
16:49:51.426 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_magnet_aq2:be88f9c4cd:158d0001e44c3f’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
16:49:51.434 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_magnet_aq2:be88f9c4cd:158d0001dbd1e9’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
16:49:51.448 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:gateway:be88f9c4cd:34ce00839810’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
16:49:51.478 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d000171a514”}
16:49:51.481 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_motion_aq2:be88f9c4cd:158d00016dafb1’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
16:49:51.490 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d0001225300”}
16:49:51.495 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_motion_aq2:be88f9c4cd:158d00016dafc8’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
16:49:51.504 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d000121b7b5”}
16:49:51.525 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d000183fe39”}
16:49:51.534 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d00016dafc8”}
16:49:51.549 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d00016dafb1”}
16:49:51.558 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d0001e44c3f”}
16:49:51.570 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d0001dbd1e9”}
16:49:51.581 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”, “sid”: “158d00044c344c”}
16:49:51.590 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:be88f9c4cd: {“cmd”: “read”}
16:49:51.597 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.608 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d000171a514 honored read request
16:49:51.616 [DEBUG] [.discovery.XiaomiItemDiscoveryService] - Discovered device - sid: 158d000171a514 model: plug
16:49:51.629 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.644 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d0001225300 honored read request
16:49:51.663 [DEBUG] [.discovery.XiaomiItemDiscoveryService] - Discovered device - sid: 158d0001225300 model: motion
16:49:51.679 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.696 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d000121b7b5 honored read request
16:49:51.704 [DEBUG] [.discovery.XiaomiItemDiscoveryService] - Discovered device - sid: 158d000121b7b5 model: switch
16:49:51.727 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.740 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d000183fe39 honored read request
16:49:51.754 [DEBUG] [ernal.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“read_ack”,“model”:“magnet”,“sid”:“158d000183fe39”,“short_id”:13554,“data”:"{“voltage”:3015,“status”:“close”}"}
16:49:51.764 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.772 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d00016dafc8 honored read request
16:49:51.786 [DEBUG] [ernal.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“read_ack”,“model”:“sensor_motion.aq2”,“sid”:“158d00016dafc8”,“short_id”:15240,“data”:"{“voltage”:3025,“lux”:“2”}"}
16:49:51.803 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.816 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d00016dafb1 honored read request
16:49:51.825 [DEBUG] [ernal.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“read_ack”,“model”:“sensor_motion.aq2”,“sid”:“158d00016dafb1”,“short_id”:3279,“data”:"{“voltage”:2995}"}
16:49:51.834 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.849 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d0001e44c3f honored read request
16:49:51.858 [DEBUG] [ernal.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“read_ack”,“model”:“sensor_magnet.aq2”,“sid”:“158d0001e44c3f”,“short_id”:34493,“data”:"{“voltage”:3015,“status”:“close”}"}
16:49:51.867 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.888 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d0001dbd1e9 honored read request
16:49:51.897 [DEBUG] [ernal.handler.XiaomiDeviceBaseHandler] - Item got update: {“cmd”:“read_ack”,“model”:“sensor_magnet.aq2”,“sid”:“158d0001dbd1e9”,“short_id”:34733,“data”:"{“voltage”:3015,“status”:“close”}"}
16:49:51.914 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.939 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device 158d00044c344c honored read request
16:49:51.953 [DEBUG] [.discovery.XiaomiItemDiscoveryService] - Discovered device - sid: 158d00044c344c model: sensor_wleak.aq1
16:49:51.968 [DEBUG] [g.mihome.internal.socket.XiaomiSocket] - Received Datagram from 10.1.1.110:9898 on port 9898
16:49:51.983 [DEBUG] [.internal.handler.XiaomiBridgeHandler] - Device null honored read request
16:54:51.995 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:bridge:be88f9c4cd’ changed from ONLINE to OFFLINE
16:54:52.008 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_magnet:be88f9c4cd:158d000183fe39’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
16:54:52.021 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_magnet_aq2:be88f9c4cd:158d0001dbd1e9’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
16:54:52.035 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:gateway:be88f9c4cd:34ce00839810’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
16:54:52.048 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_magnet_aq2:be88f9c4cd:158d0001e44c3f’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
16:54:52.057 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_motion_aq2:be88f9c4cd:158d00016dafb1’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
16:54:52.065 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - Thing ‘mihome:sensor_motion_aq2:be88f9c4cd:158d00016dafc8’ changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

I haven’t had this issue with OH2.5. Anyone have any ideas? I set my wireless to be the primary on my Rpie.

Craig

same here (on OH3 M5) did you find a solution by now?

As luck would have it, my SD card died on me. I decided to stick with 2.5 for now. The Xiaomi gateway seems to be behaving just fine.

same here on OH3 3.0.0. did you find a solution?

I’m also experiencing the same problem using the release version of OH3, and Xiaomi Gateway v2, with the Mihome binding. The bridge goes offline after a few minutes, showing similar errors to those posted by the OP. Going into the bridge’s thing settings, and clicking save brings it back online again for a short period, and then offline again…

@marcel_verpaalen - have you come across this or do have any suggestions on what could be the problem? Thanks in advance.

1 Like

If you are on oh3 you can try to enable the cloud communication… Maybe that helps.

Once you do, send a debug log to know the responses

Many thanks for the quick reply. I am not yet very familiar with OH3 - can you point me to where the cloud communciations is to be enabled? I don’t see an option for this under the bridge or in any of the obvious places under openHAB settings!

In the meantime, I was carefully watching the logs as the bridge went offline just now - nothing meaningful is posted to the logs unfortunately, even with TRACE enabled on the binding logs. The only thing we get is the bridge going offline, followed by the remaining Xiaomi devices:

2020-12-26 08:10:45.783 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:86sw2:7811dcb9d14c:158d00027c0edf' changed from OFFLINE (BRIDGE_OFFLINE) to UNINITIALIZED
2020-12-26 08:10:45.810 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:86sw2:7811dcb9d14c:158d00027c0edf' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2020-12-26 08:10:45.812 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:sensor_motion_aq2:7811dcb9d14c:158d0002f3bd64' changed from OFFLINE (BRIDGE_OFFLINE) to UNINITIALIZED
2020-12-26 08:10:45.836 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mihome:sensor_motion_aq2:7811dcb9d14c:158d0002f3bd64' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

I then did a “scan” for new devices for the Xiaomi Mihome binding. Even though the bridge is offline, the scan discovered the gateway, but also threw the following error:

2020-12-26 08:02:58.757 [DEBUG] [discovery.XiaomiItemDiscoveryService] - Start scan for items
2020-12-26 08:02:58.761 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Having 1 Item Discovery listeners
2020-12-26 08:02:58.762 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Triggered discovery
2020-12-26 08:02:58.763 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Send to bridge mihome:bridge:7811dcb9d14c: {"cmd": "get_id_list"}
2020-12-26 08:02:58.764 [WARN ] [internal.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.
2020-12-26 08:02:58.766 [ERROR] [nternal.DiscoveryServiceRegistryImpl] - Cannot trigger scan for thing types '[mihome:ctrl_ln1, mihome:ctrl_ln2, mihome:sensor_motion, mihome:sensor_motion_aq2, mihome:86sw1, mihome:86sw2, mihome:sensor_magnet, mihome:sensor_magnet_aq2, mihome:sensor_plug, mihome:smoke, mihome:sensor_wleak_aq1, mihome:sensor_switch, mihome:sensor_switch_aq2, mihome:curtain, mihome:sensor_lock_aq1, mihome:gateway, mihome:natgas, mihome:sensor_cube, mihome:sensor_weather_v1, mihome:sensor_vibration, mihome:basic, mihome:ctrl_neutral1, mihome:ctrl_neutral2, mihome:sensor_ht]' on 'XiaomiItemDiscoveryService'!
java.lang.NullPointerException: null
	at org.openhab.binding.mihome.internal.handler.XiaomiBridgeHandler.toJsonValue(XiaomiBridgeHandler.java:369) ~[?:?]
	at org.openhab.binding.mihome.internal.handler.XiaomiBridgeHandler.sendCommandToBridge(XiaomiBridgeHandler.java:298) ~[?:?]
	at org.openhab.binding.mihome.internal.handler.XiaomiBridgeHandler.sendCommandToBridge(XiaomiBridgeHandler.java:280) ~[?:?]
	at org.openhab.binding.mihome.internal.handler.XiaomiBridgeHandler.writeToBridge(XiaomiBridgeHandler.java:317) ~[?:?]
	at org.openhab.binding.mihome.internal.handler.XiaomiBridgeHandler.discoverItems(XiaomiBridgeHandler.java:393) ~[?:?]
	at org.openhab.binding.mihome.internal.discovery.XiaomiItemDiscoveryService.startScan(XiaomiItemDiscoveryService.java:68) ~[?:?]
	at org.openhab.core.config.discovery.AbstractDiscoveryService.startScan(AbstractDiscoveryService.java:194) ~[bundleFile:?]
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:377) [bundleFile:?]
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScans(DiscoveryServiceRegistryImpl.java:353) [bundleFile:?]
	at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:211) [bundleFile:?]
	at org.openhab.core.io.rest.core.internal.discovery.DiscoveryResource.scan(DiscoveryResource.java:105) [bundleFile:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) [bundleFile:1.0.9]
	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) [bundleFile:1.0.9]
	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) [bundleFile:1.0.9]
	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) [bundleFile:1.0.9]
	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) [bundleFile:1.0.9]
	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) [bundleFile:1.0.9]
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [bundleFile:1.0.9]
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [bundleFile:1.0.9]
	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [bundleFile:1.0.9]
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220) [bundleFile:1.0.9]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [bundleFile:3.1.0]
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) [bundleFile:1.0.9]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2020-12-26 08:02:58.829 [DEBUG] [scovery.XiaomiBridgeDiscoveryService] - Stop scan
2020-12-26 08:02:58.830 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Interrupting receiver thread Thread[XiaomiSocketReceiveThread(0, discovery),5,main]
2020-12-26 08:02:58.831 [DEBUG] [nternal.socket.XiaomiDiscoverySocket] - Setup discovery socket
2020-12-26 08:02:58.832 [DEBUG] [nternal.socket.XiaomiDiscoverySocket] - Initialized socket to null:-1 on 0.0.0.0/0.0.0.0:52993
2020-12-26 08:02:58.833 [DEBUG] [scovery.XiaomiBridgeDiscoveryService] - Start scan for bridges
2020-12-26 08:02:58.849 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 172.16.3.30:4321 on port 52993
2020-12-26 08:02:58.853 [DEBUG] [scovery.XiaomiBridgeDiscoveryService] - Received message {"cmd":"iam","port":"9898","sid":"7811dcb9d14c","model":"gateway","proto_version":"1.1.2","ip":"172.16.3.30"}
2020-12-26 08:02:58.854 [DEBUG] [scovery.XiaomiBridgeDiscoveryService] - Discovered Xiaomi Gateway - sid: 7811dcb9d14c ip: 172.16.3.30 port: 9898
2020-12-26 08:03:28.833 [DEBUG] [scovery.XiaomiBridgeDiscoveryService] - Stop scan
2020-12-26 08:03:28.839 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Interrupting receiver thread Thread[XiaomiSocketReceiveThread(0, discovery),5,main]
2020-12-26 08:03:28.845 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Closing socket java.net.DatagramSocket@5b9cf079
2020-12-26 08:03:28.849 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Receiver thread ended

Does this help?

Hi again @marcel_verpaalen

I just realised that you are referring to the cloud communications option on the Miio binding. Apologies but I should have clarified that I am referring to the Mihome binding.

Can the Miio replace the Mihome, for the purposes of responding to the Aqara wireless wall switches and motion sensors?

Second that request - I also have the Xiaomi Binding with the same issue.
Also (maybe noteworthy) I disabled the Xiamo gateway’s communication with the internet…

1 Like

@smar sorry… I indeed was replying to the message while reading not reading the thread very well.

The miio binding can communicate with the gateway, send commands and like, but currently has no functionality to conveniently control your aqara devices.
I think a combination of the mihome and miio binding is needed to properly control connected devices.

Maybe @rvalle made some progress in the mean time?

1 Like

@marcel_verpaalen, so far I got OH 3 instaled and zbbridge working.

xiaomi and aqara sensors working via the zbbridge.

still have not tested the hub/bridge device.

Thanks Marcel.

I have not upgraded the firmware in my V2 gateway, and still have developer access etc - so not quite the same problem as @rvalle I think. Also the gateway works absolutely fine as soon as I go back to OH 2.5, so clearly the problem is related to OH3.

As a workaround, I have a rule that restarts the mihome binding each time the bridge goes offline. Not ideal but at least it is working. Interestingly, the gateway goes offline almost exactly 5 minutes after coming online each time…

1 Like

Could you post your rule in which you start the mihome binding here? Or did you find another solution in the meantime?

My rule is written in jython, and so will not work if you are using the standard rules DSL:

from core.rules import rule
from core.triggers import when 
from core.log import logging, LOG_PREFIX
import java.time.Duration as Duration
from core.actions import Exec

LOG_BASE = "{}.xiaomi_gw".format(LOG_PREFIX)
log = logging.getLogger(LOG_BASE)

@rule("Xiaomi Bridge Offline")
@when("Thing mihome:bridge:xiaomigw changed from ONLINE to OFFLINE")
def xiaomi_gw_offline(event):
    log = logging.getLogger(LOG_BASE + "." + inspect.currentframe().f_code.co_name)
    log.info("[DEBUG] event triggered: {}".format(event))    

    Exec.executeCommandLine(Duration.ofSeconds(15),"/bin/sh", "-c", "/openhab/runtime/bin/client -p habopen bundle:restart org.openhab.binding.mihome")    
    log.info("[DEBUG] Sent Mihome binding restart command")    

If this does not work for you, you could try to use one of the aqara to mqtt scripts that are available on github, and then create corresponding mqtt things in openhab etc.

Thanks for that - I’ll try it. Thankfully, I have installed jython, so I should be able to work with your rule. I’ve also thought about the mqtt work around, but yours seems more elegant for the moment.

In any case, as established earlier in this threat, this seems to be an issue of OH3 rather than the XIaomi hard- or software. Maybe @Ondrej_Pecta as the lead developer for the binding could have a look?

Edit - I didn’t use a rule, but rather a shell command which is executed everxy 5 minutes via cron.
I know that this is not the most elegant solution, but it does work for me :wink:

Just a short update - the continuous restarting ot the binding didn’t seem like the best solution, so I thought of something different. I experimented with using the remoteHAB binding to my existing OH2.5 installation - which was on a different virtual machine.
Then, it didn’t sound efficient to have a VM just for connecting to the XIaomi Binding, so I tried installing OH2 alongside OH3 on one machine. Which initially broke OH3, but - to cut a long story short:

When I had a OH2.5 installation and upgraded this to OH3, the binding worked like a charme, only for new installs it goes offline like described above.
Steps which worked for me (ubuntu Linux):

Starting point: Existing OH3 installation

  • Install OH2 (mind you: this will “break” your OH3 installation, but keeps most of the config)
  • Install Xiaomi Binding
  • configure Xiaomi Gateway
  • install OH3 again

Result: you will have an (almost) clean install of OH3 with only the Xiaomi Binding config kept from OH2, but this time, the binding will not go offline.

Hope that helps if anyone encounters the same issue with XIaomi BInding

Thanks for the update and great to hear you have found a workaround!

Hi guys, I have encountered same issue with clean OH3 installation. I had also another issue - no button channel worked. I solved both issues with filling Gateway MAC address into serial number (advanced options) in mihome:bridge Thing.

4 Likes

Thanks - my workaround was still working, but I filled in the MAC address anyway…