Skip to content

olivierberthomme/domoticz-mirobot-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xiaomi Mi Robot Vacuum - Domoticz Python plugin

This plugin uses the Python-miio library.

[Python-miio] require Python 3.5

See this link for more information on the Domoticz plugins.

How it works

Plugin provides: Status, Control, Fan Level, Battery, Care status devices, Zone Control, Target Control

Status: show current status in readable layout of switch. Status updates by polls (interval) and when you click Control device (for instant status change). since 0.1.5 Battery Level added to status

Control: for sending commands.

Fan Level: for adjusting suction power. (MiHome app related: Quiet=38, Balanced=60, Turbo=77, Max=90)

Battery: since 0.1.5 removed

Care: since 0.1.0 new 5 devices (care status + reset tool)

Zone Control

Target Control

Installation

Before installation plugin check the python3, python3-dev, pip3 is installed for Domoticz plugin system:

sudo apt-get install python3 python3-dev python3-pip

Make sure you have libffi and openssl headers installed, you can do this on Debian-based systems (like Rasperry Pi) with:

sudo apt-get install libffi-dev libssl-dev.

Also do note that the setuptools version is too old for installing some requirements, so before trying to install this package you should update the setuptools with:

sudo pip3 install -U setuptools.

Then go to plugins folder and clone repository:

cd domoticz/plugins
git clone https://github.com/avgays/domoticz-mirobot-plugin.git xiaomi-mirobot
cd xiaomi-mirobot
mv ~/domoticz/plugins/xiaomi-mirobot/miio/ ~/

# and then:
sudo pip3 install -r pip_req.txt 
# or sudo pip3 install gevent msgpack-python python-miio

Need some prepare of MIIO Server to run as service:

  1. Open and edit miio_server.sh by vi/nano:
cd ~/miio/
nano ~/miio/miio_server.sh

# 1. Check and update absolute path to miio_server.py
# 2. Update IP and TOKEN for robot
# 3. Optional. Change MIIO server host-port bindings if need it

# file miio_server.sh
DAEMON_USER=root
DAEMON=/home/pi/miio/miio_server.py
DAEMON_ARGS="192.168.1.12 476e6b70343055483230644c53707a12"
DAEMON_ARGS="$DAEMON_ARGS --host 127.0.0.1 --port 22222"
#
  1. Check path to python3 which python3. By default is /usr/bin/python3. If your path different than default, update miio_server.py first line with your path.
#!/usr/bin/python3
  1. For run as system service:
sudo chmod +x miio_server.py
sudo chmod +x miio_server.sh

# check your path here:
sudo ln -s /home/pi/miio/miio_server.sh /etc/init.d/miio_server

# add to startup
sudo update-rc.d miio_server defaults
sudo systemctl daemon-reload

# if you want to remove from startup
sudo update-rc.d -f miio_server remove
  1. Run server and test script:
sudo service miio_server start
sudo chmod +x test.py
sudo ./test.py

# to stop miio server service
sudo service miio_server stop

Also you can run MIIO Server manually and look log output:

sudo ./miio_server.py 192.168.1.12 476e6b70343055483230644c53707a12 --host 127.0.0.1 --port 22222

# then you can run test
sudo ./test.py

If server and test is ok, time to restart the Domoticz:

sudo service domoticz.sh restart

Now go to Setup -> Hardware in your Domoticz interface and add type with name Xiaomi Mi Robot Vacuum.

Field Information
Data Timeout Keep Disabled
MIIOServer IP Address: by default 127.0.0.1
MIIOServer Port: by default 22222
Zones: JSON eg {"10":["bedroom",[[23700,24900,30300,28700,1]]], "20":["kitchen", [[17800,27800,22400,31000,1]]]} Level, Zone name, 4 Zone coordinates, times to repeat
Targets: JSON eg {"10":["Target",[21700,27400]]} Level, Target name, Target coordinates
Update interval In seconds, this determines with which interval the plugin polls the status of Vacuum. Suggested is no lower then 5 sec due timeout in python-mirobo lib, but you can try any.
Fan Level Type Standard - standard set of buttons (values supported by MiHome); Slider - allow to set custom values, up to 100 (in standard Max=90) (values not supported by MiHome)
Debug When set to true the plugin shows additional information in the Domoticz log

How to find zone cordinates

Check the instruction

After clicking on the Add button the new devices are available in Setup -> Devices.

If you want to change Fan Level Type just disable hardware, update type and enable again. Old device can be deleted manually in Devices menu.

How to update plugin

cd domoticz/plugins/xiaomi-mirobot
git pull

Restart the Domoticz service

sudo service domoticz.sh restart

Screenshots

RR_Status control_unit RR_Zone RR_Target

fan_level fan_level2

care1 care2

How to obtain device Token

Check the instruction

About

Xiaomi Mi Robot Vacuum plugin for Domoticz

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 95.2%
  • Shell 4.8%