Xiaomi Robot Vacuum Binding

well, Im trying to send a command to the mi home gateway, making the radio play, I normal use the REST ui to test, I build my rules in Node-red. but before all this, I need to be able to send commands to the gateway, like your:

sendCommand(Xiaomi_Gateway_ActionsCommands, 'play_specify_fm {"type": 0, "id": 0, "url": "http://live.xmcdn.com/live/1005/64.m3u8"}')

If my item is not working, I can’t. So Im trying the configure my gateway item with the xioami IO binding. The error I get is most like due to problems with the token(due to gave error Given final block not properly padded error), but I use the same token for the mi smart home binding… so Im interested in how you did it.

I understand now.
The token is wrong.

In the MiHome binding, there is no “token”, only a serial number and the API key you got from the xiaomi app on your phone.
In the Mi IO binding, you need the key. You can extract it the same ways as for the vacuum (with the sqlite file from your phone for instance).

1 Like

Thanks alot! :smiley:
I looked in the /data/data/com.xiaomi.smarthome/databases/miio2.db with SQLliteManager on my android. I can’t seem to find the token for the gateway, the miio discover doesn’t work either on the gateway.
Did you get the token for your gateway recently? I think there was some changes to how you can get the token.

Brian,
look here: Version 5.0.19 or older required to retrive token.

1 Like

Marcel,
I am running openHAB 2.3.0 Build #1204 and just updated your binding to latest version (Mar 17)
Getting the following errors when openhab starts:

2018-03-18 18:19:54.326 [ERROR] [org.openhab.binding.miio            ] - [org.openhab.binding.miio.internal.discovery.MiIoDiscovery(76)] The activate method has thrown an exception

java.lang.IncompatibleClassChangeError: Expected non-static field org.openhab.binding.miio.internal.discovery.MiIoDiscovery.scheduler

	at org.openhab.binding.miio.internal.discovery.MiIoDiscovery.startBackgroundDiscovery(MiIoDiscovery.java:79) ~[?:?]

	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.activate(AbstractDiscoveryService.java:403) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:229) ~[45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) ~[45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:650) ~[45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:506) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:307) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:299) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:298) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:109) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:823) [45:org.apache.felix.scr:2.0.12]

	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) [?:?]

	at java.security.AccessController.doPrivileged(Native Method) ~[?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619) [?:?]

	at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.inject.BindMethod.getServiceObject(BindMethod.java:651) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2201) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1714) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:372) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:320) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:291) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127) [45:org.apache.felix.scr:2.0.12]

	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]

	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) [?:?]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:887) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:874) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:941) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:741) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) [45:org.apache.felix.scr:2.0.12]

	at org.apache.felix.utils.extender.AbstractExtender.addingBundle(AbstractExtender.java:187) [45:org.apache.felix.scr:2.0.12]

	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469) [?:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415) [?:?]

	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) [?:?]

	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) [?:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]

	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) [?:?]

	at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?]

	at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?]

	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:470) [?:?]

	at org.eclipse.osgi.container.ModuleContainer.start(ModuleContainer.java:736) [?:?]

	at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:727) [?:?]

	at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:497) [?:?]

	at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:443) [?:?]

	at org.eclipse.osgi.container.ModuleContainer.refresh(ModuleContainer.java:987) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1368) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]

Previous version do not had these errors.
Thanks for your support!

That is indeed very odd.
I remember reading something about significant change just happening which gave this error on several bindings

I’ll check it out on my instance

Hello @marcel_verpaalen

Could you add another brightness channel for the night mode of the jiayoue ceiling lights ?

To get the current brightness value when lamp is in night mode get_prop[“nl_br”]’ is needed.

Kind regards

I got my first xiaomi wifi device a few days ago and today i included it into openhab.

It is a xiaomi miio yeelink light strip 1 MW300 (this is shown in paper ui).

It is identified as Xiaomi Mi IO Basic device.

I installed mihoma app 5.0.19 on my second android device and i could see the token with rootexplorer internal viewer. With new mihome app on my main device, the value for token was empty, but on my old device i could see the token.

I installed the binding inside paper ui from the market and i got new things in my inbox. I entered the the token and i got the channels.

Now i can switch the light strip on and off. It is wokring. The other functions will be included soon.

Is this identification as “Xiaomi Mi IO Basic device” the right one?

Power is shown as switch the other channels as numbers (brightness, delayoff, color), name is a string item.


Can i use color picker item with the number channel from the lightstrip?

Hi,

Got my robot cleaner (Ver 2) yesterday. At first didn’t notice that I need version 5.0.19 to get the token so i’ve wasted some time trying to get it :frowning:
After switching to version 5.0.19, I’ve got the token immediately (didn’t need to use main china land, other works fine).
As I am defining all things only via configuration files (and not using paperUI), it took me some time to find the Thing definition and now IT IS WORKING :slight_smile:

@marcel_verpaalen Big Thanks for the binding! great job!

Can you show me your thing definition? I want to switch to manual configuration?

Sure,

Thing miio:vacuum:gf “Xiaomi Robot Vaccum Cleaner” [ host=“192.168.0.132”, token=“7066xxxxxxxxxxxxxxxx” ]

gf for me is: ground floor, but you can set any other id

My yeelight lightstrip is shown as

Xiaomi Mi IO Basic device

in paper ui. Do i have to enter this into the thing file or do i have to enter another description for my light?

This is my item:

Switch  Xiaomi_LightStrip_Switch  "Xiaomi Light Strip Power"  {channel="miio:basic:0456A014:power"}

Is “miio:basic:…” the right word for the item or can i also use other words? Maybe “light”? Is this only cosmetic or is there a functional difference also?

@halloween
miio:basic: is indeed the right thingtype.
The basic type is for all devices that have their definition coming from the database entries.
The 3rd part of the thingId you can make whatever you like, it does not need to be the number which you have right now ( e.g. miio:basic:strip1:power)

Thanks!

Another question: I have number items for brightness, color and mode.

brightness works with dimmer on my sitemap.

But color is not working with dimmer. What is the right widget to use on my sitemap? Can i use the colorwheel with this number item?

And what is mode? I always get the value “2” and i can´t change it.

Can I somehow enable Air Purifier 2S (this is newer version os AP 2 with PM2.5 sensor and OLED screen). Currently it is discovered as Unsupported device. I hope that interface is the same as for old version at least beside the PM sensor readout. I would be happy to control 2S just like 2.

You can add it manually as basic device and update the model string in the config to one of the older models which is supported e.g. to zhimi.airpurifier.v6
You can try different models to see which best match your device.
Let me know which one it it and your exact model string then I can add it to the db

AirPurifier 2S is detected as zhimi.airpurifier.ma2. Adding basic device and configuring it as zhimi.airpurifier.v6 worked like a charm. Even LED control turns on/off the OLED screen. Thank you very much for solution.

I cannot add link to miio:basic:e208e4cf:bright and miio:basic:e208e4cf:filterlife, but it’s not a problem. Everything else seams to work fine.

Let me know if and how I could help in adding 2S officially.

24-03 Small update to the binding

  • Added AirPurifier 2S detected as zhimi.airpurifier.ma2 to the database @Jakub_Gorzynski
  • Added Philips Eyecare 2 & improve Yeelight 650 (thanks to @dimalo)

Known issues

  • Ports not being closed found by @mhilbush
  • Yeelights still very alpha supported

Note: latest Android MiHome no longer has the tokens in the database. Use 5.0.19 version, see link in the post earlier

I took a quick look at the code. It may be something as simple as closing clientSocket in stopReceiverThreat instead of (or in addition to) the calls to interrupt/join. I think that will cause an IOException in receiveData, which is caught and will cause the receiver thread to exit.

I’ve running the binding now for months and it worked really fine. Yesterday i switched my openhab to docker an now i can’t control my vaccuum and i get no state updates. The paper ui shows me that everything is online. Nothing can be seen in the logs.
Any ideas how i can find out whats going wrong?

Binding versions:
Docker: 2.3.0.201803241110
Raspberry: 2.2.0.201710152134