From 0ad1bbca7e8e6a6ab0e62537743849ad2a56dc58 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Tue, 12 Nov 2019 00:27:39 +0100 Subject: [PATCH] Add check-manifest, check for pypi-description, flake8-docstrings Also, add already shipped docs/yeelight.rst that wasn't in the repo --- .pre-commit-config.yaml | 6 +++ azure-pipelines.yml | 4 ++ docs/yeelight.rst | 85 +++++++++++++++++++++++++++++++++++++++++ tox.ini | 18 ++++++++- 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 docs/yeelight.rst diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4f9d502f..d0c05b213 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: rev: v2.3.0 hooks: - id: flake8 + additional_dependencies: [flake8-docstrings] - repo: https://github.com/pre-commit/mirrors-isort rev: v4.3.21 @@ -25,3 +26,8 @@ repos: # hooks: # - id: mypy # args: [--no-strict-optional, --ignore-missing-imports] + +- repo: https://github.com/mgedmin/check-manifest + rev: "0.40" + hooks: + - id: check-manifest diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 56a942701..1d5a0ed7b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -45,3 +45,7 @@ steps: - script: | pytest --cov miio --cov-report html displayName: 'Tests' + +- script: | + pre-commit run check-manifest --all-files + display: 'Check MANIFEST.in' diff --git a/docs/yeelight.rst b/docs/yeelight.rst new file mode 100644 index 000000000..84c72d108 --- /dev/null +++ b/docs/yeelight.rst @@ -0,0 +1,85 @@ +Yeelight +======== + +.. NOTE:: + + Only basic support for controlling Yeelight lights is implemented at the moment. + + You will likely want to use `python-yeelight `_ + for controlling your lights. + + +Currently supported features: + +- Querying the status. +- Turning on and off. +- Changing brightness, colors (RGB and HSV), color temperature. +- Changing internal settings (developer mode, saving settings on change) + + +Use ``miiocli yeelight --help`` +for help on available commands and their parameters. + +To extract the token from a backup of the official Yeelight app, refer to :ref:`yeelight_token_extraction`. + +.. _yeelight_token_extraction: + +Token extraction +---------------- + +In order to extract tokens from the Yeelight Android app, +you need to create a backup like shown below. + +.. code-block:: bash + + adb backup -noapk com.yeelight.cherry -f backup.ab + +If everything went fine and you got a ``backup.ab`` file, +from which you can extract the tokens with ``miio-extract-tokens`` as described in :ref:`token_extraction`. + +.. code-block:: bash + + miio-extract-tokens /tmp/yeelight.ab --password a + + Unable to find miio database file apps/com.xiaomi.smarthome/db/miio2.db: "filename 'apps/com.xiaomi.smarthome/db/miio2.db' not found" + INFO:miio.extract_tokens:Trying to read apps/com.yeelight.cherry/sp/miot.xml + INFO:miio.extract_tokens:Reading tokens from Yeelight Android DB + Yeelight Color Bulb + Model: yeelink.light.color1 + IP address: 192.168.xx.xx + Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + MAC: F0:B4:29:xx:xx:xx + Mi Bedside Lamp + Model: yeelink.light.bslamp1 + IP address: 192.168.xx.xx + Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + MAC: 7C:49:EB:xx:xx:xx + + +Usage examples +-------------- + +Status reporting +~~~~~~~~~~~~~~~~ + +:: + + $ miiocli yeelight --ip 192.168.xx.xx --token xxxx status + Name: + Power: False + Brightness: 39 + Color mode: 1 + RGB: (255, 152, 0) + HSV: None + Temperature: None + Developer mode: True + Update default on change: True + + +.. NOTE:: + + If you find a new command please let us know by creating a pull request + or an issue, if you do not want to implement it on your own! + + +:py:class:`API ` diff --git a/tox.ini b/tox.ini index 15e5f93a3..f8481438c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py35,py36,py37,flake8,docs +envlist=py35,py36,py37,flake8,docs,manifest,pypi-description [tox:travis] 3.5 = py35 @@ -85,3 +85,19 @@ omit = [coverage:report] exclude_lines = def __repr__ + +[testenv:pypi-description] +basepython = python3.7 +skip_install = true +deps = + twine + pip >= 18.0.0 +commands = + pip wheel -w {envtmpdir}/build --no-deps . + twine check {envtmpdir}/build/* + +[testenv:manifest] +basepython = python3.7 +deps = check-manifest +skip_install = true +commands = check-manifest