Contributing

Contributions of any sort are more than welcome, so we hope this short introduction will help you to get started! Shortly put: we use black to format our code, isort to sort our imports, pytest to test our code, flake8 to do its checks, and doc8 for documentation checks.

Development environment

This section will shortly go through how to get you started with a working development environment. We assume that you are familiar with virtualenv and are using it somehow (be it a manual setup, pipenv, ..). The easiest way to start is to use pip to install dependencies:

pip install -r requirements.txt

followed by installing the package in development mode

pip install -e .

To verify the installation, simply launch tox to run all the checks:

tox

In order to make feedback loops faster, we automate our code checks by using precommit hooks. Therefore the first step after setting up the development environment is to install them:

pre-commit install

You can always execute the checks also without doing a commit.

Code checks

Instead of running all available checks during development, it is also possible to execute only the code checks by calling. This will execute the same checks that would be done automatically by precommit when you make a commit:

tox -e lint

Tests

We prefer to have tests for our code, so we use pytest you can also use by executing:

pytest miio

When adding support for a new device or extending an already existing one, please do not forget to create tests for your code.

Generating documentation

To install necessary packages to compile the documentation, run:

pip install -r requirements_docs.txt

After that, you can compile the documentation and open it locally in your browser:

cd docs
make html
$BROWSER _build/html/index.html

Replace $BROWSER with your preferred browser if the environment variable is not set.

Adding support for new devices

The miio javascript library contains some hints on devices which could be supported, however, the Xiaomi Smart Home gateway (Home Assistant component already work in progress) as well as Yeelight bulbs are currently not in the scope of this project.

Todo

Add instructions how to extract protocol from network captures

Adding tests

Todo

Describe how to create tests. This part of documentation needs your help! Please consider submitting a pull request to update this.

Documentation

Todo

Describe how to write documentation. This part of documentation needs your help! Please consider submitting a pull request to update this.