From 7ffb980e91892c425e2d1a9bd127a9dc3462de1b Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Wed, 27 Sep 2017 00:04:06 +0200 Subject: [PATCH] Rename the project to python-miio This commit renames the project to its new name, python-miio. The name of the package has been changed to 'miio', although the old 'mirobo' is still available for backwards compatibility. Anyone trying to access and use the 'mirobo' package will be welcomed by a deprecation warning, although there are no plans to break the API currently. README.md got also updated to links for other home-assistant integrations available. --- README.md | 23 +++++--- miio/__init__.py | 17 ++++++ {mirobo => miio}/airhumidifier.py | 0 {mirobo => miio}/airpurifier.py | 0 {mirobo => miio}/ceil.py | 0 {mirobo => miio}/ceil_cli.py | 30 +++++------ {mirobo => miio}/chuangmi_ir.py | 0 {mirobo => miio}/device.py | 0 {mirobo => miio}/discovery.py | 0 {mirobo => miio}/extract_tokens.py | 0 {mirobo => miio}/fan.py | 0 {mirobo => miio}/philips_eyecare.py | 0 {mirobo => miio}/philips_eyecare_cli.py | 34 ++++++------ {mirobo => miio}/plug.py | 0 {mirobo => miio}/plug_cli.py | 16 +++--- {mirobo => miio}/plug_v1.py | 0 {mirobo => miio}/protocol.py | 0 {mirobo => miio}/strip.py | 0 {mirobo => miio}/tests/__init__.py | 0 {mirobo => miio}/tests/test_protocol.py | 0 {mirobo => miio}/vacuum.py | 0 {mirobo => miio}/vacuum_cli.py | 72 ++++++++++++------------- {mirobo => miio}/vacuumcontainers.py | 0 {mirobo => miio}/version.py | 0 {mirobo => miio}/waterpurifier.py | 0 {mirobo => miio}/yeelight.py | 0 mirobo/__init__.py | 23 +++----- setup.py | 22 ++++---- tox.ini | 6 +-- 29 files changed, 128 insertions(+), 115 deletions(-) create mode 100644 miio/__init__.py rename {mirobo => miio}/airhumidifier.py (100%) rename {mirobo => miio}/airpurifier.py (100%) rename {mirobo => miio}/ceil.py (100%) rename {mirobo => miio}/ceil_cli.py (87%) rename {mirobo => miio}/chuangmi_ir.py (100%) rename {mirobo => miio}/device.py (100%) rename {mirobo => miio}/discovery.py (100%) rename {mirobo => miio}/extract_tokens.py (100%) rename {mirobo => miio}/fan.py (100%) rename {mirobo => miio}/philips_eyecare.py (100%) rename {mirobo => miio}/philips_eyecare_cli.py (86%) rename {mirobo => miio}/plug.py (100%) rename {mirobo => miio}/plug_cli.py (89%) rename {mirobo => miio}/plug_v1.py (100%) rename {mirobo => miio}/protocol.py (100%) rename {mirobo => miio}/strip.py (100%) rename {mirobo => miio}/tests/__init__.py (100%) rename {mirobo => miio}/tests/test_protocol.py (100%) rename {mirobo => miio}/vacuum.py (100%) rename {mirobo => miio}/vacuum_cli.py (88%) rename {mirobo => miio}/vacuumcontainers.py (100%) rename {mirobo => miio}/version.py (100%) rename {mirobo => miio}/waterpurifier.py (100%) rename {mirobo => miio}/yeelight.py (100%) diff --git a/README.md b/README.md index 087810da3..e62f50ab4 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ -# Python-mirobo +# Python-miio -[![PyPI version](https://badge.fury.io/py/python-mirobo.svg)](https://badge.fury.io/py/python-mirobo) -[![Build Status](https://travis-ci.org/rytilahti/python-mirobo.svg?branch=0.2.0)](https://travis-ci.org/rytilahti/python-mirobo) -[![Code Health](https://landscape.io/github/rytilahti/python-mirobo/master/landscape.svg?style=flat)](https://landscape.io/github/rytilahti/python-mirobo/master) -[![Coverage Status](https://coveralls.io/repos/github/rytilahti/python-mirobo/badge.svg?branch=master)](https://coveralls.io/github/rytilahti/python-mirobo?branch=master) +[![PyPI version](https://badge.fury.io/py/python-miio.svg)](https://badge.fury.io/py/python-miio) +[![Build Status](https://travis-ci.org/rytilahti/python-miio.svg?branch=0.2.0)](https://travis-ci.org/rytilahti/python-miio) +[![Code Health](https://landscape.io/github/rytilahti/python-miio/master/landscape.svg?style=flat)](https://landscape.io/github/rytilahti/python-miio/master) +[![Coverage Status](https://coveralls.io/repos/github/rytilahti/python-miio/badge.svg?branch=master)](https://coveralls.io/github/rytilahti/python-miio?branch=master) -This project was started to allow controlling locally available Xiaomi Vacuum cleaner robot with Python (hence the name), +This project was started to allow controlling locally available Xiaomi Vacuum cleaner robot with Python (hence the old name, *python-mirobo*), however, thanks to contributors it has been extended to allow controlling other Xiaomi devices using the same protocol. +**The project has now been renamed to *python-miio*. The *mirobo* python package (as well as the console tool with the same name) are still available, + although users of the library are encouraged to start using the *miio* name in their tools. + The console tools (and the API) are expected to stay backwards-compatible for the near future.** + Thanks for the nice people over [ioBroker forum](http://forum.iobroker.net/viewtopic.php?f=23&t=4898) who figured out the encryption to make this possible. [Information about the underlying communication protocol](https://github.com/OpenMiHome/mihome-binary-protocol) ([another source for vacuum-specific documentation](https://github.com/marcelrv/XiaomiRobotVacuumProtocol)) @@ -38,7 +42,7 @@ The [miio javascript library](https://github.com/aholstenson/miio) contains some Please make sure you have libffi and openssl headers installed, you can do this on Debian-based systems (like Rasperry Pi) with ```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 ```pip3 install -U setuptools```. -The easiest way to install the package is to use pip: ```pip3 install python-mirobo``` . [Using virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) is recommended. +The easiest way to install the package is to use pip: ```pip3 install python-miio``` . [Using virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) is recommended. In case you get an error similar like ```ImportError: No module named 'packaging'``` during the installation, you need to upgrade pip and setuptools: @@ -279,4 +283,7 @@ Clean #1: 2017-03-05 16:17:52-2017-03-05 17:14:59 (complete: False, unknown: 0) ## Home Assistant support -See [Xiaomi Mi Robot Vacuum](https://home-assistant.io/components/vacuum.xiaomi/). +* [Xiaomi Mi Robot Vacuum](https://home-assistant.io/components/vacuum.xiaomi_miio/) +* [Xiaomi Philips Light](https://home-assistant.io/components/light.xiaomi_miio/) +* [Xiaomi Mi Air Purifier](https://github.com/syssi/xiaomi_airpurifier) +* [Xiaomi WiFi Plug](https://github.com/syssi/xiaomiplug) diff --git a/miio/__init__.py b/miio/__init__.py new file mode 100644 index 000000000..e92289736 --- /dev/null +++ b/miio/__init__.py @@ -0,0 +1,17 @@ +# flake8: noqa +from miio.protocol import Message, Utils +from miio.vacuumcontainers import (VacuumStatus, ConsumableStatus, + CleaningDetails, CleaningSummary, Timer) +from miio.vacuum import Vacuum, VacuumException +from miio.plug import Plug +from miio.plug_v1 import PlugV1 +from miio.airpurifier import AirPurifier +from miio.airhumidifier import AirHumidifier +from miio.waterpurifier import WaterPurifier +from miio.strip import Strip +from miio.ceil import Ceil +from miio.philips_eyecare import PhilipsEyecare +from miio.chuangmi_ir import ChuangmiIr +from miio.fan import Fan +from miio.device import Device, DeviceException +from miio.discovery import Discovery diff --git a/mirobo/airhumidifier.py b/miio/airhumidifier.py similarity index 100% rename from mirobo/airhumidifier.py rename to miio/airhumidifier.py diff --git a/mirobo/airpurifier.py b/miio/airpurifier.py similarity index 100% rename from mirobo/airpurifier.py rename to miio/airpurifier.py diff --git a/mirobo/ceil.py b/miio/ceil.py similarity index 100% rename from mirobo/ceil.py rename to miio/ceil.py diff --git a/mirobo/ceil_cli.py b/miio/ceil_cli.py similarity index 87% rename from mirobo/ceil_cli.py rename to miio/ceil_cli.py index 17c9a6f24..27602dc8b 100644 --- a/mirobo/ceil_cli.py +++ b/miio/ceil_cli.py @@ -9,10 +9,10 @@ sys.version_info) sys.exit(1) -import mirobo # noqa: E402 +import miio # noqa: E402 _LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(mirobo.Ceil) +pass_dev = click.make_pass_decorator(miio.Ceil) def validate_percentage(ctx, param, value): @@ -73,7 +73,7 @@ def cli(ctx, ip: str, token: str, debug: int): click.echo("You have to give ip and token!") sys.exit(-1) - dev = mirobo.Ceil(ip, token, debug) + dev = miio.Ceil(ip, token, debug) _LOGGER.debug("Connecting to %s with token %s", ip, token) ctx.obj = dev @@ -85,12 +85,12 @@ def cli(ctx, ip: str, token: str, debug: int): @cli.command() def discover(): """Search for plugs in the network.""" - mirobo.Ceil.discover() + miio.Ceil.discover() @cli.command() @pass_dev -def status(dev: mirobo.Ceil): +def status(dev: miio.Ceil): """Returns the state information.""" res = dev.status() if not res: @@ -108,14 +108,14 @@ def status(dev: mirobo.Ceil): @cli.command() @pass_dev -def on(dev: mirobo.Ceil): +def on(dev: miio.Ceil): """Power on.""" click.echo("Power on: %s" % dev.on()) @cli.command() @pass_dev -def off(dev: mirobo.Ceil): +def off(dev: miio.Ceil): """Power off.""" click.echo("Power off: %s" % dev.off()) @@ -123,7 +123,7 @@ def off(dev: mirobo.Ceil): @cli.command() @click.argument('level', callback=validate_percentage, required=True,) @pass_dev -def set_brightness(dev: mirobo.Ceil, level): +def set_brightness(dev: miio.Ceil, level): """Set brightness level.""" click.echo("Brightness: %s" % dev.set_brightness(level)) @@ -131,7 +131,7 @@ def set_brightness(dev: mirobo.Ceil, level): @cli.command() @click.argument('level', callback=validate_percentage, required=True,) @pass_dev -def set_color_temperature(dev: mirobo.Ceil, level): +def set_color_temperature(dev: miio.Ceil, level): """Set CCT level.""" click.echo("Color temperature level: %s" % dev.set_color_temperature(level)) @@ -140,7 +140,7 @@ def set_color_temperature(dev: mirobo.Ceil, level): @cli.command() @click.argument('seconds', callback=validate_seconds, required=True,) @pass_dev -def delay_off(dev: mirobo.Ceil, seconds): +def delay_off(dev: miio.Ceil, seconds): """Set delay off in seconds.""" click.echo("Delay off: %s" % dev.delay_off(seconds)) @@ -148,35 +148,35 @@ def delay_off(dev: mirobo.Ceil, seconds): @cli.command() @click.argument('scene', callback=validate_scene, required=True,) @pass_dev -def set_scene(dev: mirobo.Ceil, scene): +def set_scene(dev: miio.Ceil, scene): """Set scene number.""" click.echo("Eyecare Scene: %s" % dev.set_scene(scene)) @cli.command() @pass_dev -def smart_night_light_on(dev: mirobo.Ceil): +def smart_night_light_on(dev: miio.Ceil): """Smart Night Light on.""" click.echo("Smart Night Light On: %s" % dev.smart_night_light_on()) @cli.command() @pass_dev -def smart_night_light_off(dev: mirobo.Ceil): +def smart_night_light_off(dev: miio.Ceil): """Smart Night Light off.""" click.echo("Smart Night Light Off: %s" % dev.smart_night_light_off()) @cli.command() @pass_dev -def automatic_color_temperature_on(dev: mirobo.Ceil): +def automatic_color_temperature_on(dev: miio.Ceil): """Auto CCT on.""" click.echo("Auto CCT On: %s" % dev.automatic_color_temperature_on()) @cli.command() @pass_dev -def automatic_color_temperature_off(dev: mirobo.Ceil): +def automatic_color_temperature_off(dev: miio.Ceil): """Auto CCT on.""" click.echo("Auto CCT Off: %s" % dev.automatic_color_temperature_off()) diff --git a/mirobo/chuangmi_ir.py b/miio/chuangmi_ir.py similarity index 100% rename from mirobo/chuangmi_ir.py rename to miio/chuangmi_ir.py diff --git a/mirobo/device.py b/miio/device.py similarity index 100% rename from mirobo/device.py rename to miio/device.py diff --git a/mirobo/discovery.py b/miio/discovery.py similarity index 100% rename from mirobo/discovery.py rename to miio/discovery.py diff --git a/mirobo/extract_tokens.py b/miio/extract_tokens.py similarity index 100% rename from mirobo/extract_tokens.py rename to miio/extract_tokens.py diff --git a/mirobo/fan.py b/miio/fan.py similarity index 100% rename from mirobo/fan.py rename to miio/fan.py diff --git a/mirobo/philips_eyecare.py b/miio/philips_eyecare.py similarity index 100% rename from mirobo/philips_eyecare.py rename to miio/philips_eyecare.py diff --git a/mirobo/philips_eyecare_cli.py b/miio/philips_eyecare_cli.py similarity index 86% rename from mirobo/philips_eyecare_cli.py rename to miio/philips_eyecare_cli.py index e24961662..3ee173842 100644 --- a/mirobo/philips_eyecare_cli.py +++ b/miio/philips_eyecare_cli.py @@ -9,10 +9,10 @@ sys.version_info) sys.exit(1) -import mirobo # noqa: E402 +import miio # noqa: E402 _LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(mirobo.PhilipsEyecare) +pass_dev = click.make_pass_decorator(miio.PhilipsEyecare) def validate_bright(ctx, param, value): @@ -73,7 +73,7 @@ def cli(ctx, ip: str, token: str, debug: int): click.echo("You have to give ip and token!") sys.exit(-1) - dev = mirobo.PhilipsEyecare(ip, token, debug) + dev = miio.PhilipsEyecare(ip, token, debug) _LOGGER.debug("Connecting to %s with token %s", ip, token) ctx.obj = dev @@ -85,12 +85,12 @@ def cli(ctx, ip: str, token: str, debug: int): @cli.command() def discover(): """Search for plugs in the network.""" - mirobo.PhilipsEyecare.discover() + miio.PhilipsEyecare.discover() @cli.command() @pass_dev -def status(dev: mirobo.PhilipsEyecare): +def status(dev: miio.PhilipsEyecare): """Returns the state information.""" res = dev.status() if not res: @@ -110,14 +110,14 @@ def status(dev: mirobo.PhilipsEyecare): @cli.command() @pass_dev -def on(dev: mirobo.PhilipsEyecare): +def on(dev: miio.PhilipsEyecare): """Power on.""" click.echo("Power on: %s" % dev.on()) @cli.command() @pass_dev -def off(dev: mirobo.PhilipsEyecare): +def off(dev: miio.PhilipsEyecare): """Power off.""" click.echo("Power off: %s" % dev.off()) @@ -125,7 +125,7 @@ def off(dev: mirobo.PhilipsEyecare): @cli.command() @click.argument('level', callback=validate_bright, required=True,) @pass_dev -def set_bright(dev: mirobo.PhilipsEyecare, level): +def set_bright(dev: miio.PhilipsEyecare, level): """Set brightness level.""" click.echo("Brightness: %s" % dev.set_brightness(level)) @@ -133,7 +133,7 @@ def set_bright(dev: mirobo.PhilipsEyecare, level): @cli.command() @click.argument('scene', callback=validate_scene, required=True,) @pass_dev -def set_scene(dev: mirobo.PhilipsEyecare, scene): +def set_scene(dev: miio.PhilipsEyecare, scene): """Set eyecare scene number.""" click.echo("Eyecare Scene: %s" % dev.set_scene(scene)) @@ -141,49 +141,49 @@ def set_scene(dev: mirobo.PhilipsEyecare, scene): @cli.command() @click.argument('minutes', callback=validate_minutes, required=True,) @pass_dev -def delay_off(dev: mirobo.PhilipsEyecare, minutes): +def delay_off(dev: miio.PhilipsEyecare, minutes): """Set delay off in minutes.""" click.echo("Delay off: %s" % dev.delay_off(minutes)) @cli.command() @pass_dev -def bl_on(dev: mirobo.PhilipsEyecare): +def bl_on(dev: miio.PhilipsEyecare): """Night Light on.""" click.echo("Night Light On: %s" % dev.smart_night_light_on()) @cli.command() @pass_dev -def bl_off(dev: mirobo.PhilipsEyecare): +def bl_off(dev: miio.PhilipsEyecare): """Night Light off.""" click.echo("Night Light off: %s" % dev.smart_night_light_off()) @cli.command() @pass_dev -def notify_on(dev: mirobo.PhilipsEyecare): +def notify_on(dev: miio.PhilipsEyecare): """Eye Fatigue Reminder On.""" click.echo("Eye Fatigue Reminder On: %s" % dev.reminder_on()) @cli.command() @pass_dev -def notify_off(dev: mirobo.PhilipsEyecare): +def notify_off(dev: miio.PhilipsEyecare): """Eye Fatigue Reminder off.""" click.echo("Eye Fatigue Reminder Off: %s" % dev.reminder_off()) @cli.command() @pass_dev -def ambient_on(dev: mirobo.PhilipsEyecare): +def ambient_on(dev: miio.PhilipsEyecare): """Ambient Light on.""" click.echo("Ambient Light On: %s" % dev.ambient_on()) @cli.command() @pass_dev -def ambient_off(dev: mirobo.PhilipsEyecare): +def ambient_off(dev: miio.PhilipsEyecare): """Ambient Light off.""" click.echo("Ambient Light Off: %s" % dev.ambient_off()) @@ -191,7 +191,7 @@ def ambient_off(dev: mirobo.PhilipsEyecare): @cli.command() @click.argument('level', callback=validate_bright, required=True,) @pass_dev -def set_amb_bright(dev: mirobo.PhilipsEyecare, level): +def set_amb_bright(dev: miio.PhilipsEyecare, level): """Set Ambient Light brightness level.""" click.echo("Ambient Light Brightness: %s" % dev.set_ambient_brightness(level)) diff --git a/mirobo/plug.py b/miio/plug.py similarity index 100% rename from mirobo/plug.py rename to miio/plug.py diff --git a/mirobo/plug_cli.py b/miio/plug_cli.py similarity index 89% rename from mirobo/plug_cli.py rename to miio/plug_cli.py index f99e7928b..1113a9e27 100644 --- a/mirobo/plug_cli.py +++ b/miio/plug_cli.py @@ -11,10 +11,10 @@ sys.version_info) sys.exit(1) -import mirobo # noqa: E402 +import miio # noqa: E402 _LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(mirobo.Plug) +pass_dev = click.make_pass_decorator(miio.Plug) def validate_ip(ctx, param, value): @@ -53,7 +53,7 @@ def cli(ctx, ip: str, token: str, debug: int): click.echo("You have to give ip and token!") sys.exit(-1) - dev = mirobo.Plug(ip, token, debug) + dev = miio.Plug(ip, token, debug) _LOGGER.debug("Connecting to %s with token %s", ip, token) ctx.obj = dev @@ -65,12 +65,12 @@ def cli(ctx, ip: str, token: str, debug: int): @cli.command() def discover(): """Search for plugs in the network.""" - mirobo.Plug.discover() + miio.Plug.discover() @cli.command() @pass_dev -def status(dev: mirobo.Plug): +def status(dev: miio.Plug): """Returns the state information.""" res = dev.status() if not res: @@ -83,14 +83,14 @@ def status(dev: mirobo.Plug): @cli.command() @pass_dev -def on(dev: mirobo.Plug): +def on(dev: miio.Plug): """Power on.""" click.echo("Power on: %s" % dev.on()) @cli.command() @pass_dev -def off(dev: mirobo.Plug): +def off(dev: miio.Plug): """Power off.""" click.echo("Power off: %s" % dev.off()) @@ -99,7 +99,7 @@ def off(dev: mirobo.Plug): @click.argument('cmd', required=True) @click.argument('parameters', required=False) @pass_dev -def raw_command(dev: mirobo.Plug, cmd, parameters): +def raw_command(dev: miio.Plug, cmd, parameters): """Run a raw command.""" params = [] # type: Any if parameters: diff --git a/mirobo/plug_v1.py b/miio/plug_v1.py similarity index 100% rename from mirobo/plug_v1.py rename to miio/plug_v1.py diff --git a/mirobo/protocol.py b/miio/protocol.py similarity index 100% rename from mirobo/protocol.py rename to miio/protocol.py diff --git a/mirobo/strip.py b/miio/strip.py similarity index 100% rename from mirobo/strip.py rename to miio/strip.py diff --git a/mirobo/tests/__init__.py b/miio/tests/__init__.py similarity index 100% rename from mirobo/tests/__init__.py rename to miio/tests/__init__.py diff --git a/mirobo/tests/test_protocol.py b/miio/tests/test_protocol.py similarity index 100% rename from mirobo/tests/test_protocol.py rename to miio/tests/test_protocol.py diff --git a/mirobo/vacuum.py b/miio/vacuum.py similarity index 100% rename from mirobo/vacuum.py rename to miio/vacuum.py diff --git a/mirobo/vacuum_cli.py b/miio/vacuum_cli.py similarity index 88% rename from mirobo/vacuum_cli.py rename to miio/vacuum_cli.py index 87b52f5c3..e8d5b4500 100644 --- a/mirobo/vacuum_cli.py +++ b/miio/vacuum_cli.py @@ -15,10 +15,10 @@ sys.version_info) sys.exit(1) -import mirobo # noqa: E402 +import miio # noqa: E402 _LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(mirobo.Device, ensure=True) +pass_dev = click.make_pass_decorator(miio.Device, ensure=True) def validate_ip(ctx, param, value): @@ -75,7 +75,7 @@ def cli(ctx, ip: str, token: str, debug: int, id_file: str): except (FileNotFoundError, TypeError, ValueError) as ex: _LOGGER.error("Unable to read the stored msgid: %s", ex) - vac = mirobo.Vacuum(ip, token, start_id, debug) + vac = miio.Vacuum(ip, token, start_id, debug) vac.manual_seqnum = manual_seq _LOGGER.debug("Connecting to %s with token %s", ip, token) @@ -89,7 +89,7 @@ def cli(ctx, ip: str, token: str, debug: int, id_file: str): @cli.resultcallback() @pass_dev -def cleanup(vac: mirobo.Vacuum, **kwargs): +def cleanup(vac: miio.Vacuum, **kwargs): if vac.ip is None: # dummy Device for discovery, skip teardown return id_file = kwargs['id_file'] @@ -104,14 +104,14 @@ def cleanup(vac: mirobo.Vacuum, **kwargs): def discover(handshake): """Search for robots in the network.""" if handshake: - mirobo.Vacuum.discover() + miio.Vacuum.discover() else: - mirobo.Discovery.discover_mdns() + miio.Discovery.discover_mdns() @cli.command() @pass_dev -def status(vac: mirobo.Vacuum): +def status(vac: miio.Vacuum): """Returns the state information.""" res = vac.status() if not res: @@ -132,7 +132,7 @@ def status(vac: mirobo.Vacuum): @cli.command() @pass_dev -def consumables(vac: mirobo.Vacuum): +def consumables(vac: miio.Vacuum): """Return consumables status.""" res = vac.consumable_status() click.echo("Main brush: %s (left %s)" % (res.main_brush, @@ -146,35 +146,35 @@ def consumables(vac: mirobo.Vacuum): @cli.command() @pass_dev -def start(vac: mirobo.Vacuum): +def start(vac: miio.Vacuum): """Start cleaning.""" click.echo("Starting cleaning: %s" % vac.start()) @cli.command() @pass_dev -def spot(vac: mirobo.Vacuum): +def spot(vac: miio.Vacuum): """Start spot cleaning.""" click.echo("Starting spot cleaning: %s" % vac.spot()) @cli.command() @pass_dev -def pause(vac: mirobo.Vacuum): +def pause(vac: miio.Vacuum): """Pause cleaning.""" click.echo("Pausing: %s" % vac.pause()) @cli.command() @pass_dev -def stop(vac: mirobo.Vacuum): +def stop(vac: miio.Vacuum): """Stop cleaning.""" click.echo("Stop cleaning: %s" % vac.stop()) @cli.command() @pass_dev -def home(vac: mirobo.Vacuum): +def home(vac: miio.Vacuum): """Return home.""" click.echo("Requesting return to home: %s" % vac.home()) @@ -182,7 +182,7 @@ def home(vac: mirobo.Vacuum): @cli.group() @pass_dev # @click.argument('command', required=False) -def manual(vac: mirobo.Vacuum): +def manual(vac: miio.Vacuum): """Control the robot manually.""" command = '' if command == 'start': @@ -196,7 +196,7 @@ def manual(vac: mirobo.Vacuum): @manual.command() # noqa: F811 # redefinition of start @pass_dev -def start(vac: mirobo.Vacuum): +def start(vac: miio.Vacuum): """Activate the manual mode.""" click.echo("Activating manual controls") return vac.manual_start() @@ -204,7 +204,7 @@ def start(vac: mirobo.Vacuum): @manual.command() # noqa: F811 # redefinition of stop @pass_dev -def stop(vac: mirobo.Vacuum): +def stop(vac: miio.Vacuum): """Deactivate the manual mode.""" click.echo("Deactivating manual controls") return vac.manual_stop() @@ -213,7 +213,7 @@ def stop(vac: mirobo.Vacuum): @manual.command() @pass_dev @click.argument('degrees', type=int) -def left(vac: mirobo.Vacuum, degrees: int): +def left(vac: miio.Vacuum, degrees: int): """Turn to left.""" click.echo("Turning %s degrees left" % degrees) return vac.manual_control(degrees, 0) @@ -222,7 +222,7 @@ def left(vac: mirobo.Vacuum, degrees: int): @manual.command() @pass_dev @click.argument('degrees', type=int) -def right(vac: mirobo.Vacuum, degrees: int): +def right(vac: miio.Vacuum, degrees: int): """Turn to right.""" click.echo("Turning right") return vac.manual_control(-degrees, 0) @@ -231,7 +231,7 @@ def right(vac: mirobo.Vacuum, degrees: int): @manual.command() @click.argument('amount', type=float) @pass_dev -def forward(vac: mirobo.Vacuum, amount: float): +def forward(vac: miio.Vacuum, amount: float): """Run forwards.""" click.echo("Moving forwards") return vac.manual_control(0, amount) @@ -240,7 +240,7 @@ def forward(vac: mirobo.Vacuum, amount: float): @manual.command() @click.argument('amount', type=float) @pass_dev -def backward(vac: mirobo.Vacuum, amount: float): +def backward(vac: miio.Vacuum, amount: float): """Run backwards.""" click.echo("Moving backwards") return vac.manual_control(0, -amount) @@ -251,7 +251,7 @@ def backward(vac: mirobo.Vacuum, amount: float): @click.argument('rotation', type=float) @click.argument('velocity', type=float) @click.argument('duration', type=int) -def move(vac: mirobo.Vacuum, rotation: int, velocity: float, duration: int): +def move(vac: miio.Vacuum, rotation: int, velocity: float, duration: int): """Pass raw manual values""" return vac.manual_control(rotation, velocity, duration) @@ -263,7 +263,7 @@ def move(vac: mirobo.Vacuum, rotation: int, velocity: float, duration: int): @click.argument('end_hr', type=int, required=False) @click.argument('end_min', type=int, required=False) @pass_dev -def dnd(vac: mirobo.Vacuum, cmd: str, +def dnd(vac: miio.Vacuum, cmd: str, start_hr: int, start_min: int, end_hr: int, end_min: int): """Query and adjust do-not-disturb mode.""" @@ -285,7 +285,7 @@ def dnd(vac: mirobo.Vacuum, cmd: str, @cli.command() @click.argument('speed', type=int, required=False) @pass_dev -def fanspeed(vac: mirobo.Vacuum, speed): +def fanspeed(vac: miio.Vacuum, speed): """Query and adjust the fan speed.""" if speed: click.echo("Setting fan speed to %s" % speed) @@ -297,7 +297,7 @@ def fanspeed(vac: mirobo.Vacuum, speed): @cli.group(invoke_without_command=True) @pass_dev @click.pass_context -def timer(ctx, vac: mirobo.Vacuum): +def timer(ctx, vac: miio.Vacuum): """List and modify existing timers.""" if ctx.invoked_subcommand is not None: return @@ -318,7 +318,7 @@ def timer(ctx, vac: mirobo.Vacuum): @click.option('--command', default='', required=False) @click.option('--params', default='', required=False) @pass_dev -def add(vac: mirobo.Vacuum, cron, command, params): +def add(vac: miio.Vacuum, cron, command, params): """Add a timer.""" click.echo(vac.add_timer(cron, command, params)) @@ -326,7 +326,7 @@ def add(vac: mirobo.Vacuum, cron, command, params): @timer.command() @click.argument('timer_id', type=int, required=True) @pass_dev -def delete(vac: mirobo.Vacuum, timer_id): +def delete(vac: miio.Vacuum, timer_id): """Delete a timer.""" click.echo(vac.delete_timer(timer_id)) @@ -336,9 +336,9 @@ def delete(vac: mirobo.Vacuum, timer_id): @click.option('--enable', is_flag=True) @click.option('--disable', is_flag=True) @pass_dev -def update(vac: mirobo.Vacuum, timer_id, enable, disable): +def update(vac: miio.Vacuum, timer_id, enable, disable): """Enable/disable a timer.""" - from mirobo.vacuum import TimerState + from miio.vacuum import TimerState if enable and not disable: vac.update_timer(timer_id, TimerState.On) elif disable and not enable: @@ -349,7 +349,7 @@ def update(vac: mirobo.Vacuum, timer_id, enable, disable): @cli.command() @pass_dev -def find(vac: mirobo.Vacuum): +def find(vac: miio.Vacuum): """Find the robot.""" click.echo("Sending find the robot calls.") click.echo(vac.find()) @@ -357,14 +357,14 @@ def find(vac: mirobo.Vacuum): @cli.command() @pass_dev -def map(vac: mirobo.Vacuum): +def map(vac: miio.Vacuum): """Return the map token.""" click.echo(vac.map()) @cli.command() @pass_dev -def info(vac: mirobo.Vacuum): +def info(vac: miio.Vacuum): """Return device information.""" res = vac.info() @@ -374,7 +374,7 @@ def info(vac: mirobo.Vacuum): @cli.command() @pass_dev -def cleaning_history(vac: mirobo.Vacuum): +def cleaning_history(vac: miio.Vacuum): """Query the cleaning history.""" res = vac.clean_history() click.echo("Total clean count: %s" % res.count) @@ -395,14 +395,14 @@ def cleaning_history(vac: mirobo.Vacuum): @cli.command() @pass_dev -def sound(vac: mirobo.Vacuum): +def sound(vac: miio.Vacuum): """Query sound settings.""" click.echo(vac.sound_info()) @cli.command() @pass_dev -def serial_number(vac: mirobo.Vacuum): +def serial_number(vac: miio.Vacuum): """Query serial number.""" click.echo("Serial#: %s" % vac.serial_number()) @@ -410,7 +410,7 @@ def serial_number(vac: mirobo.Vacuum): @cli.command() @click.argument('tz', required=False) @pass_dev -def timezone(vac: mirobo.Vacuum, tz=None): +def timezone(vac: miio.Vacuum, tz=None): """Query or set the timezone.""" if tz is not None: click.echo("Setting timezone to: %s" % tz) @@ -423,7 +423,7 @@ def timezone(vac: mirobo.Vacuum, tz=None): @click.argument('cmd', required=True) @click.argument('parameters', required=False) @pass_dev -def raw_command(vac: mirobo.Vacuum, cmd, parameters): +def raw_command(vac: miio.Vacuum, cmd, parameters): """Run a raw command.""" params = [] # type: Any if parameters: diff --git a/mirobo/vacuumcontainers.py b/miio/vacuumcontainers.py similarity index 100% rename from mirobo/vacuumcontainers.py rename to miio/vacuumcontainers.py diff --git a/mirobo/version.py b/miio/version.py similarity index 100% rename from mirobo/version.py rename to miio/version.py diff --git a/mirobo/waterpurifier.py b/miio/waterpurifier.py similarity index 100% rename from mirobo/waterpurifier.py rename to miio/waterpurifier.py diff --git a/mirobo/yeelight.py b/miio/yeelight.py similarity index 100% rename from mirobo/yeelight.py rename to miio/yeelight.py diff --git a/mirobo/__init__.py b/mirobo/__init__.py index 830c56d95..7ea693cae 100644 --- a/mirobo/__init__.py +++ b/mirobo/__init__.py @@ -1,17 +1,6 @@ -# flake8: noqa -from mirobo.protocol import Message, Utils -from mirobo.vacuumcontainers import (VacuumStatus, ConsumableStatus, - CleaningDetails, CleaningSummary, Timer) -from mirobo.vacuum import Vacuum, VacuumException -from mirobo.plug import Plug -from mirobo.plug_v1 import PlugV1 -from mirobo.airpurifier import AirPurifier -from mirobo.airhumidifier import AirHumidifier -from mirobo.waterpurifier import WaterPurifier -from mirobo.strip import Strip -from mirobo.ceil import Ceil -from mirobo.philips_eyecare import PhilipsEyecare -from mirobo.chuangmi_ir import ChuangmiIr -from mirobo.fan import Fan -from mirobo.device import Device, DeviceException -from mirobo.discovery import Discovery +import warnings +warnings.simplefilter('always', DeprecationWarning) +warnings.warn("Please convert to using 'miio' package, this package will " + "be removed at some point in the future", DeprecationWarning, + stacklevel=2) +from miio import * diff --git a/setup.py b/setup.py index 0fc2e65a1..ca48d187e 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ from setuptools import setup -with open('mirobo/version.py') as f: exec(f.read()) +with open('miio/version.py') as f: exec(f.read()) setup( - name='python-mirobo', + name='python-miio', version=__version__, - description='Python library for interfacing with Xiaomi Vacuum cleaner robot', - url='https://github.com/rytilahti/python-mirobo', + description='Python library for interfacing with Xiaomi smart appliances', + url='https://github.com/rytilahti/python-miio', author='Teemu Rytilahti', author_email='tpr@iki.fi', @@ -21,18 +21,18 @@ 'Programming Language :: Python :: 3', ], - keywords='xiaomi vacuum', + keywords='xiaomi miio vacuum', - packages=["mirobo"], + packages=["miio", "mirobo"], install_requires=['construct', 'click', 'cryptography', 'pretty_cron', 'typing', 'zeroconf'], entry_points={ 'console_scripts': [ - 'mirobo=mirobo.vacuum_cli:cli', - 'miplug=mirobo.plug_cli:cli', - 'miceil=mirobo.ceil_cli:cli', - 'mieye=mirobo.philips_eyecare_cli:cli', - 'miio-extract-tokens=mirobo.extract_tokens:main' + 'mirobo=miio.vacuum_cli:cli', + 'miplug=miio.plug_cli:cli', + 'miceil=miio.ceil_cli:cli', + 'mieye=miio.philips_eyecare_cli:cli', + 'miio-extract-tokens=miio.extract_tokens:main' ], }, ) diff --git a/tox.ini b/tox.ini index 54210fde2..fd022aab0 100644 --- a/tox.ini +++ b/tox.ini @@ -14,16 +14,16 @@ deps= voluptuous coveralls commands= - py.test --cov mirobo + py.test --cov miio coveralls [testenv:flake8] deps=flake8 -commands=flake8 mirobo +commands=flake8 miio [flake8] exclude = .git,.tox,__pycache__ [testenv:typing] deps=mypy -commands=mypy --silent-imports mirobo +commands=mypy --silent-imports miio