Python plugin: Xiaomi Mi Robot Vacuum

Python and python framework
mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » Tuesday 22 August 2017 21:10

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 2800 times
29668575-6906ea22-88e9-11e7-8508-8f0ff48e2f78.png
29668575-6906ea22-88e9-11e7-8508-8f0ff48e2f78.png (14.29 KiB) Viewed 2800 times
29568433-0da95692-8759-11e7-8706-344c02536d6a.png
29568433-0da95692-8759-11e7-8706-344c02536d6a.png (14.09 KiB) Viewed 2800 times
Last edited by mrinner on Sunday 12 November 2017 18:26, edited 6 times in total.

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » Thursday 24 August 2017 17:27

Added "Fan Level" subdevice.

DennisD
Posts: 59
Joined: Friday 18 September 2015 21:46
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by DennisD » Friday 25 August 2017 19:14

Thx, didn't tried it yet, because i have the lua scripts.

User avatar
blacksn0w
Posts: 111
Joined: Friday 10 March 2017 23:27
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Germany
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by blacksn0w » Saturday 26 August 2017 9:37

Great work!
Working flawlessy and is replacing my current bash + cronjob solution. :D
This post was made with ♥ in Cologne. Raspberry Pi 3B (with SSD), Aeotec Z-Stick Gen5, RFLink R48, MiHome

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » Monday 28 August 2017 12:36

"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".

Martins80
Posts: 11
Joined: Saturday 26 August 2017 21:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Martins80 » Monday 28 August 2017 19:03

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:

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » 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?

martijnm
Posts: 24
Joined: Thursday 04 February 2016 14:06
Target OS: Raspberry Pi
Domoticz version: 3.530
Location: Emmen, Drenthe
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by martijnm » Monday 28 August 2017 21:35

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!

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » Monday 28 August 2017 21:55

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.

deennoo
Posts: 913
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by deennoo » Tuesday 29 August 2017 11:57

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 ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

Martins80
Posts: 11
Joined: Saturday 26 August 2017 21:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Martins80 » Tuesday 29 August 2017 12:06

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.

cattoo
Posts: 63
Joined: Sunday 20 September 2015 17:37
Target OS: Raspberry Pi
Domoticz version: 2.3072
Location: Sweden
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by cattoo » 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
Last edited by cattoo on Tuesday 29 August 2017 15:29, edited 1 time in total.

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » 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)

deennoo
Posts: 913
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by deennoo » Tuesday 29 August 2017 14:37

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
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » Tuesday 29 August 2017 14:56

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.

cattoo
Posts: 63
Joined: Sunday 20 September 2015 17:37
Target OS: Raspberry Pi
Domoticz version: 2.3072
Location: Sweden
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by cattoo » Tuesday 29 August 2017 17:12

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

mrinner
Posts: 50
Joined: Tuesday 22 August 2017 20:50
Target OS: Raspberry Pi
Domoticz version:
Location: Belarus
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by mrinner » Tuesday 29 August 2017 18:15

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.

Martins80
Posts: 11
Joined: Saturday 26 August 2017 21:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by Martins80 » Monday 04 September 2017 11:16

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...

wywywywy
Posts: 5
Joined: Wednesday 27 September 2017 23:32
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by wywywywy » Wednesday 27 September 2017 23:38

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!

kluczus
Posts: 22
Joined: Tuesday 12 September 2017 14:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Robot Vacuum

Post by kluczus » Friday 29 September 2017 13:41

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
........................................................................................
RPi2 + sonoff + 433MHz + Xiaomi Gateway + EQ-3 MAX!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests