Page 1 of 16

Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 22 August 2017 21:10
by mrinner
Plugin for Xiaomi Vacuum (based on python-miio)

Can be found here: https://github.com/mrin/domoticz-mirobot-plugin

Provide sub devices:
- Status (polls by interval)
- Control
- Fan Level
- Battery
- Care Main Brush, Side Brush, Filter, Sensor
- Care reset control

29769383-c8202814-8bf2-11e7-86b2-3629bfc63dc0.png
29769383-c8202814-8bf2-11e7-86b2-3629bfc63dc0.png (11.9 KiB) Viewed 24360 times
29668575-6906ea22-88e9-11e7-8508-8f0ff48e2f78.png
29668575-6906ea22-88e9-11e7-8508-8f0ff48e2f78.png (14.29 KiB) Viewed 24360 times
29568433-0da95692-8759-11e7-8706-344c02536d6a.png
29568433-0da95692-8759-11e7-8706-344c02536d6a.png (14.09 KiB) Viewed 24360 times

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Thursday 24 August 2017 17:27
by mrinner
Added "Fan Level" subdevice.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Friday 25 August 2017 19:14
by DennisD
Thx, didn't tried it yet, because i have the lua scripts.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Saturday 26 August 2017 9:37
by blacksn0w
Great work!
Working flawlessy and is replacing my current bash + cronjob solution. :D

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 28 August 2017 12:36
by mrinner
"Battery level" moved in new device. Before was an issue with status log change when just battery level updated, was floods in history log for "Status device".

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 28 August 2017 19:03
by Martins80
As i see here, more devices using the same protocol are suppported:
https://github.com/rytilahti/python-mirobo
i have two power strips but i have been not able to make it work :cry:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 28 August 2017 21:31
by mrinner
Martins80 wrote: Monday 28 August 2017 19:03 i have two power strips but i have been not able to make it work :cry:
I don't have 6-port strips, but seems all should be ok. Did you get token and implement code for it in python script? (I see what python-mirobo doesn't have CLI mode for strip) Errors?

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 28 August 2017 21:35
by martijnm
As I read it, the script does not support the other "supported" devices:
Although this library (and tool) currently only supports the vacuum cleaner, some other Xiaomi products use the same underlying communication protocol (another source for vacuum-specific documentation), so patches for supporting other Xiaomi devices using the same protocol are welcome!

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 28 August 2017 21:55
by mrinner
Seems it should work, because I see strip.py in lib which is extended from basic "Device", so it should work, but not as CLI tool, just need some code to write.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 11:57
by deennoo
Nice work !

Maybe as you have seen mi-robo can now drive xiaomi philips ball bulb (i put some element on the issue, was isn't working), it use miceil command, does it will be hard to add for you ?

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 12:06
by Martins80
I'm sure it is hard to do. Im trying to write some code for the strip as i have the hardware, but i need some time to figure out how it works. Without the hardware is almost impossible to make it.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 13:39
by cattoo
Ive done as the page said, but when ill try to add the hardware, the type dont show only the Xaiomi gateway and no Vacuum :cry:
Running beta 3.8369

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 14:10
by mrinner
cattoo wrote: Tuesday 29 August 2017 13:39 Ive done as the page said, but when ill try to add the hardware, the type dont show only the Xaiomi gateway and no Vacuum :cry:
Running beta 3.8369
It works on stable release currently. Since beta 3.8367 python plugin system disabled for some period of time by developers of Domoticz. (ref. to issue viewtopic.php?f=6&t=19122)

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 14:37
by deennoo
Martins80 wrote:I'm sure it is hard to do. Im trying to write some code for the strip as i have the hardware, but i need some time to figure out how it works. Without the hardware is almost impossible to make it.
Looking how this plugin is made.

Looks like it use a wrapper file to speak to the vaccum.

Wrapper is a good idea for all device supported by mirobo lib.

Also pip3 install mirobo is installing an old version for me, i have to gitclone and manual instt pyrhon-murobo to retieve miceil and other files missing

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 14:56
by mrinner
deennoo wrote: Tuesday 29 August 2017 14:37 Looks like it use a wrapper file to speak to the vaccum.
Yes, it's due some limitation of python plugin system (no asynchronous, callbacks etc..). I tried to use mirobo lib directly, but it doesn't work as expected, so for now it's through wrapper.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 17:12
by cattoo
mrinner wrote: Tuesday 29 August 2017 14:10
cattoo wrote: Tuesday 29 August 2017 13:39 Ive done as the page said, but when ill try to add the hardware, the type dont show only the Xaiomi gateway and no Vacuum :cry:
Running beta 3.8369
It works on stable release currently. Since beta 3.8367 python plugin system disabled for some period of time by developers of Domoticz. (ref. to issue viewtopic.php?f=6&t=19122)
Well im back on stable och the Hardware is added, but now it shows me, what do ill need to change?

Code: Select all

2017-08-29 17:05:13.215 Error: (xiaomi-mi-robot-vacuum) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/xiaomi-mirobot/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-08-29 17:05:13.215 Error: (Inga) Module Import failed, exception: 'SystemError'
2017-08-29 17:06:30.029 Error: Inga hardware (37) thread seems to have ended unexpectedly

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Tuesday 29 August 2017 18:15
by mrinner
Hmm.. for testing purpose open the plugin folder and file plugin.py, then try comment lines and restart domoticz.

Code: Select all

import Domoticz
#import subprocess
#import os
#import json
Possible one of the system lib cannot be import, but it should work as it is python system libs... As I remember I got some error like you, but restart solved this issue.

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Monday 04 September 2017 11:16
by Martins80
mrinner wrote: Monday 28 August 2017 21:31
Martins80 wrote: Monday 28 August 2017 19:03 i have two power strips but i have been not able to make it work :cry:
I don't have 6-port strips, but seems all should be ok. Did you get token and implement code for it in python script? (I see what python-mirobo doesn't have CLI mode for strip) Errors?
yesterday i installed miio libraries and now i have the tokens for the power strips.

I think that we should group the wifi xiaomi devices in one develop thread as they share communications protocol...

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Wednesday 27 September 2017 23:38
by wywywywy
Hi guys. I've run into a problem that I hope you guys can help with please.

So I've git cloned this and installed mirobo in the .vendor directory with all the requisites, and restarted Domoticz multiple times.

But, when I go to the Setup > Hardware screen, I'm not seeing the parameters for this plugin. Clicking on the Add button also does nothing.

It is as if Domoticz can't read the plugin.py correctly. This is no errors in the log, even with -verbose 2.

The PluginSystem is definitely started - "PluginSystem: Started, Python version '3.5.2'."

Any ideas please?

Image

This is the latest stable Domoticz v3.8153, on an Orange Pi Zero, with Ubuntu Server 16 LTS.

Apt update and upgrade were performed prior to installing this.

Many thanks!

Re: Python plugin: Xiaomi Mi Robot Vacuum

Posted: Friday 29 September 2017 13:41
by kluczus
Ho to check a status of the vacuum ? I installed plugin, everything works just fine. I was trying to define a blockly with notification when vacuum is comming back to home but without luck.
Blocky

Code: Select all

if vacuum-status = "Back to home" then ....
is not working