Xiaomi Mi Robot

For those installing the binding via market place:

Did minor update that will improve the error logging & improve formatting of the DND times.
Note for those updating, please remove your vacuum thing (don’t forget to store your token) and add it back again after the update. This is needed as the config was changed

@BOFH90 send you PM wrt for specific test version to test the multiple vacuums

Your test-version is working successfully with two robots. Even the auto-discovery for both is working after installing the binding.

Thank you so much for your effort.

EDIT: It now started to fail again:
2017-07-05 12:30:52.342 [hingStatusInfoChangedEvent] - ‘xiaomivacuum:vacuum:03D87B3E’ changed from OFFLINE (COMMUNICATION_ERROR): Die Adresse wird bereits verwendet (Bind failed) to OFFLINE (COMMUNICATION_ERROR): No valid status response

2017-07-05 12:30:54.995 [hingStatusInfoChangedEvent] - ‘xiaomivacuum:vacuum:034D720F’ changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): No valid status response

2017-07-05 12:31:30.022 [hingStatusInfoChangedEvent] - ‘xiaomivacuum:vacuum:034D720F’ changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): No valid status response

The binding works like a charm, thanks for that!

What does the variable “in_cleaning” show? For me it doesn’t change while the vacuum is cleaning (which can be determined by the state variable anyway). Does it show the need to empty the dust bin?

Are the maps of the cleaning process created and stored in the vacuum itself or somewhere in China? Is it possible to get the map of the current and past cleaning processes without using the Mi Home app/without internet access?

The Binding now works for one of both robots, the second one worked for 2-5 minutes and then switching between offline and online again. But the first is online and working since 2 hours now.

I see in the python script an interesting remark
Anyway, thanks to #21 I realized that the id generation is the problem and I got the cli tool working again by not reusing the same 'id' for communication (the robot answers once per 'id' in a specific time-frame.

which may occur with the way the binding is configured. it could explain why it works for some time and than not.
In the binding each time an error occurs, I reset this id to 1, which may lead that within the timeframe no more commands are accepted.

1 Like

I made a small update to the binding.

To easier have the latest info available I made a new topic for the binding in the bindings category to continue the discussion

Hi, I’m trying to connect to my new vacuum cleaner that I received today, but so far no luck with that.
It seems that my device has some strange device ID. Xiaomi Mi Robot Vacuum should have 0x02f2 (754), but I’m getting 984 (0x03D8).

INFO:mirobo.device:Sending discovery to <broadcast> with timeout of 5s..
INFO:mirobo.device: IP 192.168.8.1: 984 - token: b'51344c5942785736757a3133766a7836'

Firmware version of my device is: 3.3.9_003077.

When I try to connect it always ends up with timeout:

INFO:mirobo.cli:Debug mode active
ERROR:mirobo.cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:mirobo.cli:Connecting to 192.168.3.100 with token 51344c5942785736757a3133766a7836
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Discovered 984 18672 with ts: 2017-07-13 21:15:10
DEBUG:mirobo.device:192.168.3.100:54321 >>: {'id': 1, 'method': 'get_status'}
ERROR:mirobo.device:got error when receiving: timed out
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/mirobo/device.py", line 129, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out

Have somebody came across to this?
Thanks for info

I think you need python 3.5 version to run it.

I tried to update to Python 3.5, but it’s the same.

There is also checking the Python version in cli.py and Python 3.4 should be fine.
if sys.version_info < (3, 4):
print(“To use this script you need python 3.4 or newer, got %s” %
sys.version_info)
sys.exit(1)

So the problem is now fixed and I’m able to use the connection.
Important note for everybody using Xiaomi Vacuum Cleaner with firmware 3.3.9. It is no longer possible to retrieve the token using discover mode. The only possible way is to get token from your Android or iOS device that was previously paired with your vacuum cleaner: https://github.com/home-assistant/home-assistant.github.io/blob/next/source/_components/switch.xiaomi_vacuum.markdown

Is it still possible to retrieve the token with the Mi Toolkit?

I have done a dump of the communication on signin for the Xiaomi App, including the device download. Is anyone interested in seeing that to see if we can get the token from that? Skimming through it the responses are somehow encoded (not plain json or xml)

Sure, that may help indeed. There are still quite some questions left in that area,

1 Like

Hi, this is a non-geek question

for the common user, is there a way to control the Xiami mi vacuum cleaner either directly on the cleaner itself, or at least communication with it through an iPod 6 gen without internet connection ? I don’t want to send any information whatsoever to the Chinese.

Thanks

The binding uses direct control (local/ direct), no communication via the cloud.
You can deny internet access for the vacuum if you control it via the binding.
So, the short answer, yes, you can control it without ever connecting it to the internet if you want.

ok, did I understood wrongly when I supposed I needed a one-time internet connection through the device I wanted to use with the Xiami for registration purposes ?

What exactly am I supposed to install on my iPod in order to operate this direct control ?
Thanks

Okay, I think you can control your vacuum through openhab without ever connecting it to Xiaomi cloud.

The way to do it is to look at the first post on how to retrieve the token (connecting openhab to the device wifi network, run discover for the token).
Once you have the token, use the command channel to send the command for changing the wifi network. miIO.config_router , use as param ssid & password with your desired wifi network. I see I haven’t documented that command yet. I’m away from home this weekend, can add that after the weekend

Than the vacuum will connect to your home network. You can than run openhab on your local network, have the webbrowser or ios app for openhab to control it.

Above way, you never need to connect it to internet. The disadvantage is that the Xiaomi mihome app can’t be used.
If you want to use the Xiaomi mihome app, you need to do the wifi network change via the Xiaomi app at that time its connected to the internet.
Once linked to the mihome app internet access is no longer needed.

Hope the 2 options are clear.

OK, did anyone actually tried to control his Xiami with this ?

Recently the “find_me” command stopped working. The error I get is as follows:

[ERROR] [.thing.internal.CommunicationManager] - Exception occurred while calling handler: java.lang.IllegalStateException: This is not a JSON Array.
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: This is not a JSON Array.
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:220) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.thing.internal.CommunicationManager.receiveCommand(CommunicationManager.java:74) [105:org.eclipse.smarthome.core.thing:0.9.0.201709011622]
	at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:47) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:193) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181) [98:org.eclipse.smarthome.core:0.9.0.201709011622]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.IllegalStateException: This is not a JSON Array.
	at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:106) ~[?:?]
	at org.openhab.binding.miio.internal.MiIoCommunication.sendCommand(MiIoCommunication.java:73) ~[?:?]
	at org.openhab.binding.miio.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:165) ~[?:?]
	at org.openhab.binding.miio.handler.MiIoVacuumHandler.handleCommand(MiIoVacuumHandler.java:96) ~[?:?]
	at org.eclipse.smarthome.core.thing.internal.CommunicationManager$1.call(CommunicationManager.java:77) ~[?:?]
	at org.eclipse.smarthome.core.thing.internal.CommunicationManager$1.call(CommunicationManager.java:1) ~[?:?]
	at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218) ~[?:?]
	... 12 more

Yep, and it works great.