Code Monkey home page Code Monkey logo

domoticz-mirobot-plugin's Introduction

Xiaomi Mi Robot Vacuum - Domoticz Python plugin

PyPI pyversions

This plugin uses the Python-miio library to control the Xiaomi Mi Robot Vacuum.

See this link for more information on how to use Python plugins in Domoticz.

How it works

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

Status: show current status and battery level in readable layout of switch. Status updates by polls (interval) and when you click Control device (for instant status change).

Control: for sending commands.

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

Care: 5 devices for the care status, and a care reset tool.

Zone Control

Target Control

Installation

Python >= 3.8 is required.

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.

Then go to plugins folder and clone repository:

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

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

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

Device token

The device token is required to be set in the miio_server.sh script, which is the identification of the Xiaomi Mi vacuum. Check the instruction on how to get access to the correct device token.

Credits

Originally created by: mrin/domoticz-mirobot-plugin

domoticz-mirobot-plugin's People

Contributors

mrin avatar joro75 avatar olivierberthomme avatar avgays avatar jerome-labidurie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.