Mi(Xiaomi) Smart home bindings?

May it is only news for me that the events changed in the switch button:

CLICK --> SHORT_PRESSED
DOUBLE_CLICK --> DOUBLE_PRESSED
LONG_CLICK_PRESS --> LONG_PRESSED
LONG_CLICK_RELEASE --> LONG_RELEASED

In rules you have to replace with the new ones :slight_smile: After I replaced everything back to as before.

yes guys. Sorry for that. the new events are more OH style so we changed them.
also the battery channels are different now. showing values from 0-100%
please have a look in the readme and check your settings and rules.

its also recommended to remove all things and readd everything again.
then all the channels and settings are right.

have fun! :wink:

1 Like

What´s the right way to get battery low notification?

I changed my rule file to the example from openhab docs, but now i get errors in the log-file:

2017-06-28 10:00:16.716 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'xiaomi.rules' has errors, therefore ignoring it: [125,58]: mismatched input 'changed' expecting 'triggered'
[134,58]: mismatched input 'changed' expecting 'triggered'
[143,58]: mismatched input 'changed' expecting 'triggered'
[152,58]: mismatched input 'changed' expecting 'triggered'
[161,58]: mismatched input 'changed' expecting 'triggered'
[170,58]: mismatched input 'changed' expecting 'triggered'

I changed to this:

rule "Xiaomi Aqara 1 - Battery Low - below 2800 mW"
when
    Channel "mihome:86sw2:158d00012a4d7d:lowBattery" changed to ON
then
        logInfo("RULES", "Xiaomi Aquara 1 triggered Battery LOW")
		sendNotification("xyz@abc.qq", "Xiaomi Aqara 1 Battery LOW - Voltage: " + Xiaomi_Aqara_Voltage_1.state + " mV")
end

Before this changes, i had it like this way, without errors:

when
    Channel "mihome:86sw2:158d00012a4d7d:batteryLevel" triggered LOW
then

Is the openhab documentation not correct?

expecting “triggered” error:

–> Shouldn´t it be:

when
    Item Switch_BatteryLow changed to ON
then

???

100% = 3100 mV
0% = 2700 mV

Is this right?

Hello,
I would like to purchase some XIAOMI products and add them to OpenHAB2.
Could you confirm me that I need at least a Xiaomi Gateway that comunicates to openhab via WiFi. Is that correct?
Which gateway do I need?
Thanks!
Simon

https://xiaomi-mi.com/sockets-and-sensors/xiaomi-mi-gateway-2/
https://xiaomi-mi.com/sockets-and-sensors/xiaomi-mi-smart-home-kit/

Thank you!

Simon

Thanks your are right.

percentages are right. the low Battery switch is put to ON from 20% on

The Xiaomi Aqara curtain motor should work with both the gateway 2 and Aqara Gateway 3 as far as I know, see: Page Not Found - Aliexpress.com

Do you know something about the Xiaomi Honeywell Smoke Sensor?

Can you do something “smart” whith it? Play sounds like the Gateway? Are there LEDs included to make a blinking light?

Today i made an update to the latest snapshot version of OH 2.2. I had installed snapshot 2.1 (or 2.2) on june 29th the last time.

Now i don´t get any values from xiaomi any more.

On Paper UI Configuration-Things i can see “uninitialized” and inside the thing i see “uninitialized - handler_initializing_error”.

Anybody knows something about? What can i do? I configured my xiaomi thing new when i installed the latest snapshot a week ago and i changed to manuyl config of the things. It worked until the update of the snapshot i made today.

I have similar problem. Initially I installed market:binding and configured everything. After each OH2 snapshot update I have to reinstall this binding and after several reinstallations I stopped to receive battery level from sensors (didn’t have time to investigate this problem) . After binding-mihome announcement I migrated to it and everything is OK but after last OH2 snapshot update I got the same status “uninitialized - handler_initializing_error” reinstallations and reboots didn’t help. I’ve rolled back to market:binding and it started to work again (except battery level and wireless switch also stopped to work). Hope will have time to investigate these problems during weekend :slight_smile:

Similar issue. Openhab 2.2 lattest snapshot upgraded. Removed the mihome JAR file. Restarted Openhab2. Installed the binding from the Addon --> Binding. The things moved to uninitialized status. Removed the Gatway thing. But it can not be rediscover it again. From log:

2017-07-05 16:13:56.731 [DEBUG] [nternal.DiscoveryServiceRegistryImpl] - Triggering scan for thing types '[mihome:bridge]' on 'XiaomiBridgeDiscoveryService'...
2017-07-05 16:13:56.732 [DEBUG] [scovery.XiaomiBridgeDiscoveryService] - Stop scan
2017-07-05 16:13:56.744 [ERROR] [nternal.DiscoveryServiceRegistryImpl] - Cannot trigger scan for thing types '[mihome:bridge]' on 'XiaomiBridgeDiscoveryService'!
java.lang.NullPointerException
        at org.openhab.binding.mihome.internal.socket.XiaomiDiscoverySocket.setupSocket(XiaomiDiscoverySocket.java:45)
        at org.openhab.binding.mihome.internal.socket.XiaomiSocket.<init>(XiaomiSocket.java:68)
        at org.openhab.binding.mihome.internal.socket.XiaomiDiscoverySocket.<init>(XiaomiDiscoverySocket.java:32)
        at org.openhab.binding.mihome.internal.discovery.XiaomiBridgeDiscoveryService.startScan(XiaomiBridgeDiscoveryService.java:60)
        at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.startScan(AbstractDiscoveryService.java:199)
        at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:392)
        at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScans(DiscoveryServiceRegistryImpl.java:377)
        at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:221)
        at org.eclipse.smarthome.io.rest.core.discovery.DiscoveryResource.scan(DiscoveryResource.java:86)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_65]
        at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_65]
        at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)[161:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)[161:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)[161:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)[161:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)[161:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)[161:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)[162:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)[159:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)[159:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)[159:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)[159:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)[159:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76)[13:com.eclipsesource.jaxrs.publisher:5.3.1.201602281253]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[85:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[85:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[176:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[83:org.eclipse.jetty.security:9.2.19.v20160908]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[176:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[85:org.eclipse.jetty.servlet:9.2.19.v20160908]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[176:org.ops4j.pax.web.pax-web-jetty:4.3.0]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.Server.handle(Server.java:499)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[84:org.eclipse.jetty.server:9.2.19.v20160908]
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[75:org.eclipse.jetty.io:9.2.19.v20160908]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[87:org.eclipse.jetty.util:9.2.19.v20160908]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[87:org.eclipse.jetty.util:9.2.19.v20160908]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]

Uninstalled from the gui, moved back the JAR version, and now the discovery working, and everything get back.

One short question:

I removed xiaomi binding in the paper ui (uninstalling) and copied back an old jar-file to the addon-directory. After restart of openhab, xiaomi-binding is “installed” again in paper ui.

Do i have to remove xiaomi from addons.cfg too? Or can i simply uninstall only with paper ui and no additional manual work?

Hi, I just reinstalled Openhan 2.1 after playing around with an other automation system.
I have a setup of with the gateway 2, with buttoms, door sensors, cube, motion sensor, zigbee and wifi plug.
I take it wifi plug doesn’t work with this binding but I have problems with my plug, everything else is working, also the sound and light from the gateway.
When I try to switch off the plug this happens (from karaf:)

21:59:20.000 [INFO ] [marthome.event.ItemStateChangedEvent] - XiaomiMiSmartSocketPlug_Power changed from ON to OFF
21:59:21.572 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘XiaomiPlug’ received command OFF
21:59:21.580 [INFO ] [marthome.event.ItemStateChangedEvent] - XiaomiPlug changed from ON to OFF
21:59:21.593 [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(FutureTask.java:266)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.lang.NullPointerException

Help would be much appreciated!

@Moellegaard, I had the same problem. I reinstalled using OpenHabian and the latest version 2.1. My workaround is to remove the Mi Home binding from Paper UI\Add-ons\Bindings and then manually added the binding from https://github.com/openhab/openhab2-addons/pull/2416 (the third entry down) into the openhab2-addons directory. That seems to work. It looks like the latest fix by @dimalo didn’t get propagated to the official binding release.

2 Likes

I tried to place both the .jar and .zip file in my addon dir but I cant’t make it work. Do I need to run a command or something? I did reboot.

You only need the .jar file.

Can you tell us, what you have done so far?

Have you uninstalled the xiaomi binding with paper ui?

Whats inside the addons.cfg?

Okay, I deleted the zip files and uninstalled the xiaomi binding in paper UI.
I did add anything to the addons.cfg. I was thinging I only needed to add it to the addons folder.

if I add something to the addons.cfg, I need to add all my bindings right? or else it will uninstall the ones that I don’t use.

What do I need to add to the cfg?
the name of my downloaded binding is:

org.openhab.binding.mihome-2.2.0-SNAPSHOT.jar

Is it a problem that I run the 2.1 version of openhab?
(I had problems upgrading)
Thanks

You only have to add bindings to the addons.cfg if you install them with paper ui. But i don´t know if it will be uninstalled if there is nothing isnide or if it will be installed, if you write something in…

If you manually add a file to the addons-folder, you don´t have to add something to addons.cfg.

I think it should run with 2.1 too.

I don´t know if the version you downloaded is also corrupted like the version from the openhab-installation. I installed an old version from end of june manually and this is working.