Skip to content

A Python plugin for Domoticz to access Xiaomi Mi Air Purifier 3 / 3 H / Pro H

License

Notifications You must be signed in to change notification settings

JacekHoleczek/Domoticz-Xiaomi-Mi-Air-Purifier-MIoT-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domoticz-Xiaomi-Mi-Air-Purifier-MIoT-Plugin

A Python plugin for Domoticz to access Xiaomi Mi Air Purifier 3 / 3 H / Pro H

Note: it does NOT work for Xiaomi Mi Air Purifier 3 C / Pro

Based on the repositories:

Installation

The instructions shown below are for a "Raspberry Pi 4 Model B" running the "Raspbian GNU/Linux 10 (Debian Buster)" operating system. However, they should also be fine for another Debian based systems.

Make sure that your Domoticz instance supports Python plugins: https://www.domoticz.com/wiki/Using_Python_plugins

Make sure that you have the "rustc" compiler (the "rustc --version" must be "1.41.0" or newer) and its "cargo" package manager installed.

sudo apt-get install rustc cargo

Install the required Python packages.

Note: on a "Debian Buster", one cannot install "python-miio >= 0.5.9", because it depends on "cryptography >= 35", which fails to build on this system. However, this problem does no exist on other (newer) systems (and then, one does not need to explicitly request "==0.5.8" below).

pip3 install -U python-miio==0.5.8 # the last version that uses cryptography 3.4.x
pip3 install -U micloud

You can now retrieve informations about your device (the default "<language_code_of_the_server>" is "de").

micloud -u <your_Xiaomi_username> -c <language_code_of_the_server> --pretty # notice the returned "<localip>" and "<token>"
miiocli device --ip <localip> --token <token> info # a simple test that we can directly access it

Get the plugin source code into your Domoticz "plugins" directory.

cd YOUR_DOMOTICZ_PATH/plugins # usually "${HOME}/domoticz/plugins"
git clone https://github.com/JacekHoleczek/Domoticz-Xiaomi-Mi-Air-Purifier-MIoT-Plugin

Use the "MyAir.py" script to verify that everything works.

cd Domoticz-Xiaomi-Mi-Air-Purifier-MIoT-Plugin
./MyAir.py -h
./MyAir.py --debug <localip> <token>

Adjust the "python-miio" location in the "plugin.py" file.

PYTHON_MIIO_LOCATION="$(pip3 show python-miio | sed -n -e '{s/^Location: //p}')"
# echo ${PYTHON_MIIO_LOCATION}
sed -i -e '{s#\"PYTHON_MIIO_LOCATION\"#\"'${PYTHON_MIIO_LOCATION}'\"#}' plugin.py

Restart the Domoticz service and reload the web page, then:

  • go to "Setup" -> "Hardware" and define a new one of the "Type: Xiaomi Mi Air Purifier MIoT",
  • set the "Name", the "Local IP" (="<localip>"), and the "Token" (="<token>"),
  • click the "Add" button.

Enjoy your new "Setup" -> "Devices".

Update

Get the new plugin source code into your Domoticz "plugins" directory.

cd YOUR_DOMOTICZ_PATH/plugins/Domoticz-Xiaomi-Mi-Air-Purifier-MIoT-Plugin
git reset --hard -q # discard any local changes completely
git pull

Adjust the "python-miio" location in the "plugin.py" file, as shown above.

Restart the Domoticz service, e.g.:

sudo systemctl restart domoticz.service

Note: when the plugin source code changes, you may need to "Setup" -> "Hardware" -> "Delete" your device first, then restart the Domoticz service (and reload the web page), and finally "Setup" -> "Hardware" -> "Add" your device again.

Troubleshooting

In case of problems (e.g., the plugin is not visible in the plugin list), check the "Setup" -> "Log" and see the Domoticz Wiki (e.g., for typical problems locating Python).

About

A Python plugin for Domoticz to access Xiaomi Mi Air Purifier 3 / 3 H / Pro H

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages