Xiaomi Robot Vacuum Binding

@Multisaft7
A new version of the iBackup Viewr is out - you can now specify a password when you open the backups. Meaning you no longer need to create an unencrypted backup - you can just use an encrypted one.

@marcel_verpaalen
Thank you so much for creating this binding. Works like a charm for me although I needed to take the robot out of the guest wifi into my standard wifi to discover it as a thing through the binding. Any way to get around that? I would like to keep it in the guest wifi for security reasons.

One question:
You posted on July21st that the channels changed with a new release. Does this mean that the .items-file also needs to be modified? To me it looks like verything is fine.
I used the .items you posted on July 10th. It would be great if you could provide a new sample .items and .sitemap file whenever the channels change. This would make adding the robot to basic UI so much easier for noobs like me.

1 Like

@Michael_Freundlieb
Thanks for your feedback.

Wrt to the channels update, I think most times I updated the 2nd post along with the changes in the binding. Hence, if you copied that file you should be fine.
The very latest update adds network channels, I think those still need to be added to the 2nd post for completion. I’ll add that shortly. (These files I copied from my production system… I’ve not yet addressed those channels there)

Wrt to your guest network… the binding needs to be able to directly reach the vacuum. So if you have it on your guestnetwork, you probably need to add a route/firewall rule to allow that connection to work.
The mihome app probably works in ‘remote’ mode (can be seen in the app) this means it communicates all commands via the cloud in that case. As the cloud logon & communication is not yet understood, connections for the binding are send directly instead of via the cloud.
So I suggest to setup your network indeed so the vacuum is separated from the main network, but still directly reachable from it. (E.g with static routes, firewalls, vlans etc).
The port to open is udp 54321.
Hope this helps

New update is available
Changes:

  • Discovery is done as generic mi io device. Once a valid token is entered, the generic device is changed to a vacuum.
    In case of other mi io devices it is changed to an ‘unsupported’ devicetype. That still allows for custom commands to be send.
  • change the logic of online/offline. This should prevent ‘flipping’ between online& offline each time.
    Note when the binding is starting, the very first online indicated that the device is pingable. If afterwards out goes offline is mainly indicated a tolken issue.

Note. I’ll add some test commands for other Xiaomi devices shortly.

I’ve now got the app working properly. The issue, oddly, is that I needed to sign-in to the ‘mainland china’ server in order to get the full functionality of the app. I was signed into the USA server previously.

Now to get that token, and get it set-up with openhab.

umm … how exactly do I do this?

MiToolkit has created 3 files in its ‘save’ folder, backup.ab, backup.list & backup.tar, but where exactly do I find the token?

@marcel_verpaalen great work with this binding. :ok_hand:

When setting up the binding I run into something I found strange about the action channel.
After issuing an vacuum command the binding is bouncing to the dock state.

Check this log:

17:41:05.516 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'PinguRobotVacuum_Actions_ControlVacuum' received command dock
17:41:05.528 [INFO ] [marthome.event.ItemStateChangedEvent] - PinguRobotVacuum_Actions_ControlVacuum changed from vacuum to dock
17:41:05.734 [INFO ] [marthome.event.ItemStateChangedEvent] - PinguRobotVacuum_Actions_ControlVacuum changed from dock to vacuum

Maybe this is logical if the robot after getting vacuum command have time to scans its state before “taking off” and finds itself still in the dock, eg. reports that (2). And a short time thereafter starts the vacuum and then reports that again (3).

I would find it nice if there would be an debouncing check on 200ms or similar to avoid this behavior. This will make GUI:s correct and scripting much more simple to implement against the binding.

Using device firmware: 3.3.6_003062
Binding version: market:binding-3499123 - 1.0

Personally I haven’t used that tool yet. It wasn’t available. As far as I understood it should give it when you run it.

Alternative is to unzip the files, open miio2 db file with sqlite viewer and look for the table as in the screenshot a few post above.

I haven’t seen that yet, but I can imagine that this could happen in case of specific tim i ng. I’ll make a small amendment to avoid this

1 Like

Thanks for the update!
I have tried to re-add a wifi smart socket but stuck on Uninitialized. Is it a normal behavior?
Looking forward for examples :slight_smile:

No, it is not expected :frowning: I’ve identified the issue, will post an updated version in the next hour

I think for the powerplug/strip commands that should work:
set_power[“on”]
set_power[“off”]
get_prop[‘power’, ‘temperature’, ‘current’, ‘mode’]
set_power_mode[“green”]
set_power_mode[“normal”]

If these commands work, pls send me the full responses, than I can add them

HI Marcel,
Is it possible to control devices that currently not supported in miio, but I could control them via “device.call()” for example I’ve sniffed data from my Xiaomi Philips Ceiling lamp and could control it via " device.call(‘set_mode’, [‘toggle’]) " and so on.

Hi,
Yes it should be. Discover your device.
Add the token, send the command to the ‘actions#command’ channel
Nb. This channel is an advanced one, hence by default hidden.

Pls let me know the result.
Pls use the latest version (today afternoon)

I’m getting some errors from the sitemap when using one of the item definitions you made as en example above, specifically the actionfan:

2017-08-08 09:45:50.438 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'Standard' of item vacActionFan with format '%.0f': java.util.IllegalFormatConversionException: f != java.lang.String
2017-08-08 09:45:50.439 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '60' of item vacActionFan with format '%.0f': java.util.IllegalFormatConversionException: f != java.lang.String
2017-08-08 09:45:50.439 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'Standard' of item vacActionFan with format '%.0f': java.util.IllegalFormatConversionException: f != java.lang.String
2017-08-08 09:45:50.439 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '60' of item vacActionFan with format '%.0f': java.util.IllegalFormatConversionException: f != java.lang.String
2017-08-08 09:45:50.439 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'Standard' of item vacActionFan with format '%.0f': java.util.IllegalFormatConversionException: f != java.lang.String
2017-08-08 09:45:50.439 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '60' of item vacActionFan with format '%.0f': java.util.IllegalFormatConversionException: f != java.lang.String

Item:

String vacActionFan      		"Vacuumfan"         (gVac_Fe_Stue)  						{ channel="xiaomivacuum:vacuum:03D8FC7F:actions#fan" 		}

Sitemap:

Selection item=vacActionFan  icon="fan" mappings=[38="Stille", 60="Normal", 77="Power",90="Full"]

HI,
I’ve tried to test it but with no luck. Should auto-discover work or I need to add it manually?
Auto-discovery for me doesn’t work. I’ve tried to add it manually, tried both Mi IO Device and Unsupported MI IO Device, but the status always either “OFFLINE - COMMUNICATION_ERROR No Response from device” or just “OFFLINE” .
I’ve added Ip-address of lamp, token and ID in thing config.

14:52:35.076 [DEBUG] [ivacuum.handler.XiaomiGenericHandler] - Update connection 'xiaomivacuum:generic:ba7e93f2’
14:52:35.078 [DEBUG] [aomivacuum.handler.XiaomiMiIoHandler] - Ping MiIO device 57992992 at 192.168.1.33
14:52:35.163 [DEBUG] [aomivacuum.handler.XiaomiMiIoHandler] - Ping response from device 0374E720 at 192.168.1.33. Time stamp: 1970-01-01T06:35:42, OH time 2017-08-08T14:52:35.163, delta 47
14:52:35.166 [DEBUG] [omivacuum.internal.RoboCommunication] - Send command: {‘method’: ‘miIO.info’, ‘id’: 98} -> 192.168.1.33 (Device: 57992992 token: C46BDF4E564F927B204BFFE801DC4E19)
14:52:50.184 [DEBUG] [omivacuum.internal.RoboCommunication] - Communication error for vacuum at 192.168.1.33: Receive timed out
14:52:50.187 [DEBUG] [omivacuum.internal.RoboCommunication] - No response from device 57992992 at 192.168.1.33 for command {‘method’: ‘miIO.info’, ‘id’: 98}.

But I could control, discover and so on via miio package.

daznik@OPENHAB:~ $ miio --control 57992992 --method set_mode --params '[“toggle”]'
INFO Attempting to control 57992992

INFO Got result:
[
“ok”
]

Also when I try to send commands to " xiaomivacuum:generic:ba7e93f2:actions#commands "

14:57:50.776 [DEBUG] [ivacuum.handler.XiaomiGenericHandler] - Update connection 'xiaomivacuum:generic:ba7e93f2’
14:57:50.778 [DEBUG] [aomivacuum.handler.XiaomiMiIoHandler] - Ping MiIO device 57992992 at 192.168.1.33
14:57:51.018 [DEBUG] [aomivacuum.handler.XiaomiMiIoHandler] - Ping response from device 0374E720 at 192.168.1.33. Time stamp: 1970-01-01T06:40:56, OH time 2017-08-08T14:57:51.017, delta 47
14:57:51.020 [DEBUG] [omivacuum.internal.RoboCommunication] - Send command: {‘method’: ‘miIO.info’, ‘id’: 183} -> 192.168.1.33 (Device: 57992992 token: C46BDF4E564F927B204BFFE801DC4E19)
14:58:03.682 [DEBUG] [omivacuum.internal.RoboCommunication] - Send command: {‘method’: ‘set_mode’, ‘params’: [toggle],‘id’: 184} -> 192.168.1.33 (Device: 57992992 token: C46BDF4E564F927B204BFFE801DC4E19)
14:58:03.687 [INFO ] [marthome.event.ItemStateChangedEvent] - Philips1 changed from null to set_mode[toggle]
14:58:06.042 [DEBUG] [omivacuum.internal.RoboCommunication] - Communication error for vacuum at 192.168.1.33: Receive timed out
14:58:06.044 [DEBUG] [omivacuum.internal.RoboCommunication] - No response from device 57992992 at 192.168.1.33 for command {‘method’: ‘miIO.info’, ‘id’: 183}.
14:58:08.683 [WARN ] [ore.internal.events.OSGiEventManager] - Dispatching event to subscriber ‘org.eclipse.smarthome.core.thing.internal.ThingManager@1303f6d’ takes more than 5000ms.
14:58:08.689 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Philips1’ received command set_mode[toggle]
14:58:21.060 [DEBUG] [omivacuum.internal.RoboCommunication] - Communication error for vacuum at 192.168.1.33: Receive timed out
14:58:21.062 [DEBUG] [omivacuum.internal.RoboCommunication] - No response from device 57992992 at 192.168.1.33 for command {‘method’: ‘set_mode’, ‘params’: [toggle],‘id’: 184}.
14:58:21.087 [INFO ] [marthome.event.ItemStateChangedEvent] - Philips1 changed from set_mode[toggle] to null

Also I have another miio devices but they also non-discoverable via binding, but I could see them through miio package

daznik@OPENHAB:~ $ miio --discover
INFO Discovering devices. Press Ctrl+C to stop.

Device ID: 52273049
Model info: Unknown
Address: 192.168.1.30 (Xiaomi_GW)
Token: ???
Support: Unknown

Device ID: 57992992
Model info: Unknown
Address: 192.168.1.33 (Xiaomi_Philips_Light_1)
Token: c46bdf4e564f927b204bffe801dc4e19 via stored token
Support: Unknown

Device ID: 52819025
Model info: Unknown
Address: 192.168.1.32 (Xiaomi_Plug)
Token: 20baddcb82613fc040de173276c995c9 via auto-token
Support: Unknown

Device ID: 54220075
Model info: Unknown
Address: 192.168.1.31 (Xiaomi_Air_Pur)
Token: a9523eb3880289b53c49bfedd89064e8 via auto-token
Support: Unknown

Binding updated in market place

Renamed the binding to miio binding to reflect the possibility to control many other Xiaomi Wifi devices. This means manual item files need to be updated to use it. (updated file in 2nd post)
Many small improvements to the connectivity, starting sequence etc
Refresh after sending each command (issue from @elias_gabrielsson)
The discovery sequnce has changed. Your device is discovered as a xiaomi generic device. Once the tolken is there and communication is successful, the type is changed to the vacuum and the vacuum related channels become available. For other Xiaomi devices, it will either change to the appropriate type (basic) or change to unsupported.

  • Preliminary/experimental support for Xiaomi air purifier

Due to the rename, when you install the new binding you need to update your item files as well

Yes, the String type needs to change to a Number.
The definitions in the 2nd post have been updated to that now.

1 Like

Hm, I’m still getting a warning on this when I load/browse the sitemap

Item

Number vacActionFan_Fe_Stue      		"Støvsuger vifte"         (gVac_Fe_Stue)  						{ channel="miio:generic:03D8FC7F:actions#fan" 		}

Sitemap

Selection item=vacActionFan_Fe_Stue label="test123" icon="fan" mappings=[38="Stille", 60="Normal", 77="Power",90="Full"]

Log

2017-08-16 08:19:54.576 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'Standard' of item vacActionFan_Fe_Stue with format '%.0f': {}
java.util.IllegalFormatConversionException: f != java.lang.String
        at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302) [?:?]
        at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2806) [?:?]
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2753) [?:?]
        at java.util.Formatter.format(Formatter.java:2520) [?:?]
        at java.util.Formatter.format(Formatter.java:2455) [?:?]
        at java.lang.String.format(String.java:2940) [?:?]

(This comes 3 times)

is it possible to download the binding manually? AFAIK, market bindings must be installed each boot :tired_face:

You don’t need to reinstall with each reboot the market bindings. They will persist
Nevertheless if you want to download, go to the eclipse marketplace site and find the binding and click download button. It will give the hyperlink to the file.

Really? I have to install it every time I boot …:frowning:

Thank you!