diff --git a/docs/api/miio.ceil_cli.rst b/docs/api/miio.ceil_cli.rst deleted file mode 100644 index a459868af..000000000 --- a/docs/api/miio.ceil_cli.rst +++ /dev/null @@ -1,7 +0,0 @@ -miio.ceil\_cli module -===================== - -.. automodule:: miio.ceil_cli - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/api/miio.philips_eyecare_cli.rst b/docs/api/miio.philips_eyecare_cli.rst deleted file mode 100644 index 4df31d460..000000000 --- a/docs/api/miio.philips_eyecare_cli.rst +++ /dev/null @@ -1,7 +0,0 @@ -miio.philips\_eyecare\_cli module -================================= - -.. automodule:: miio.philips_eyecare_cli - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/api/miio.plug_cli.rst b/docs/api/miio.plug_cli.rst deleted file mode 100644 index a84a7a835..000000000 --- a/docs/api/miio.plug_cli.rst +++ /dev/null @@ -1,7 +0,0 @@ -miio.plug\_cli module -===================== - -.. automodule:: miio.plug_cli - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/api/miio.rst b/docs/api/miio.rst index bc3d92956..870ddee98 100644 --- a/docs/api/miio.rst +++ b/docs/api/miio.rst @@ -34,7 +34,6 @@ Submodules miio.alarmclock miio.aqaracamera miio.ceil - miio.ceil_cli miio.chuangmi_camera miio.chuangmi_ir miio.chuangmi_plug @@ -59,10 +58,8 @@ Submodules miio.miot_device miio.philips_bulb miio.philips_eyecare - miio.philips_eyecare_cli miio.philips_moonlight miio.philips_rwread - miio.plug_cli miio.powerstrip miio.protocol miio.pwzn_relay diff --git a/docs/ceil.rst b/docs/ceil.rst deleted file mode 100644 index 2d338041b..000000000 --- a/docs/ceil.rst +++ /dev/null @@ -1,18 +0,0 @@ -Ceil -==== - -.. todo:: - Pull requests for documentation are welcome! - - -See :ref:`miceil --help ` for usage. - -.. _miceil_help: - - -`miceil --help` -~~~~~~~~~~~~~~~ - -.. click:: miio.ceil_cli:cli - :prog: miceil - :show-nested: diff --git a/docs/eyecare.rst b/docs/eyecare.rst deleted file mode 100644 index 7a45e1978..000000000 --- a/docs/eyecare.rst +++ /dev/null @@ -1,17 +0,0 @@ -Philips Eyecare -=============== - -.. todo:: - Pull requests for documentation are welcome! - - -See :ref:`mieye --help ` for usage. - -.. _mieye_help: - -`mieye --help` -~~~~~~~~~~~~~~~ - -.. click:: miio.philips_eyecare_cli:cli - :prog: mieye - :show-nested: diff --git a/docs/index.rst b/docs/index.rst index 4157e555a..686935c3a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,9 +29,6 @@ who have helped to extend this to cover not only the vacuum cleaner. discovery new_devices vacuum - plug - ceil - eyecare yeelight API troubleshooting diff --git a/docs/plug.rst b/docs/plug.rst deleted file mode 100644 index d93410a94..000000000 --- a/docs/plug.rst +++ /dev/null @@ -1,17 +0,0 @@ -Plug -==== - -.. todo:: - Pull requests for documentation are welcome! - - -See :ref:`miplug --help ` for usage. - -.. _miplug_help: - -`miplug --help` -~~~~~~~~~~~~~~~ - -.. click:: miio.plug_cli:cli - :prog: miplug - :show-nested: diff --git a/miio/ceil_cli.py b/miio/ceil_cli.py deleted file mode 100644 index 1b7da2c62..000000000 --- a/miio/ceil_cli.py +++ /dev/null @@ -1,170 +0,0 @@ -import logging -import sys - -import click - -import miio # noqa: E402 -from miio.click_common import ExceptionHandlerGroup, validate_ip, validate_token -from miio.miioprotocol import MiIOProtocol - -_LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(miio.Ceil) - - -def validate_percentage(ctx, param, value): - value = int(value) - if value < 1 or value > 100: - raise click.BadParameter("Should be a positive int between 1-100.") - return value - - -def validate_seconds(ctx, param, value): - value = int(value) - if value < 0 or value > 21600: - raise click.BadParameter("Should be a positive int between 1-21600.") - return value - - -def validate_scene(ctx, param, value): - value = int(value) - if value < 1 or value > 4: - raise click.BadParameter("Should be a positive int between 1-4.") - return value - - -@click.group(invoke_without_command=True, cls=ExceptionHandlerGroup) -@click.option("--ip", envvar="DEVICE_IP", callback=validate_ip) -@click.option("--token", envvar="DEVICE_TOKEN", callback=validate_token) -@click.option("-d", "--debug", default=False, count=True) -@click.pass_context -def cli(ctx, ip: str, token: str, debug: int): - """A tool to command Xiaomi Philips LED Ceiling Lamp.""" - - if debug: - logging.basicConfig(level=logging.DEBUG) - _LOGGER.info("Debug mode active") - else: - logging.basicConfig(level=logging.INFO) - - _LOGGER.warning( - "This script is deprecated and will be removed soon, use `miiocli ceil` instead" - ) - - # if we are scanning, we do not try to connect. - if ctx.invoked_subcommand == "discover": - return - - if ip is None or token is None: - click.echo("You have to give ip and token!") - sys.exit(-1) - - dev = miio.Ceil(ip, token, debug) - _LOGGER.debug("Connecting to %s with token %s", ip, token) - - ctx.obj = dev - - if ctx.invoked_subcommand is None: - ctx.invoke(status) - - -@cli.command() -def discover(): - """Search for plugs in the network.""" - MiIOProtocol.discover() - - -@cli.command() -@pass_dev -def status(dev: miio.Ceil): - """Returns the state information.""" - res = dev.status() - if not res: - return # bail out - - click.echo(click.style("Power: %s" % res.power, bold=True)) - click.echo("Brightness: %s" % res.brightness) - click.echo("Color temperature: %s" % res.color_temperature) - click.echo("Scene: %s" % res.scene) - click.echo("Smart Night Light: %s" % res.smart_night_light) - click.echo("Auto CCT: %s" % res.automatic_color_temperature) - click.echo( - "Countdown of the delayed turn off: %s seconds" % res.delay_off_countdown - ) - - -@cli.command() -@pass_dev -def on(dev: miio.Ceil): - """Power on.""" - click.echo("Power on: %s" % dev.on()) - - -@cli.command() -@pass_dev -def off(dev: miio.Ceil): - """Power off.""" - click.echo("Power off: %s" % dev.off()) - - -@cli.command() -@click.argument("level", callback=validate_percentage, required=True) -@pass_dev -def set_brightness(dev: miio.Ceil, level): - """Set brightness level.""" - click.echo("Brightness: %s" % dev.set_brightness(level)) - - -@cli.command() -@click.argument("level", callback=validate_percentage, required=True) -@pass_dev -def set_color_temperature(dev: miio.Ceil, level): - """Set CCT level.""" - click.echo("Color temperature level: %s" % dev.set_color_temperature(level)) - - -@cli.command() -@click.argument("seconds", callback=validate_seconds, required=True) -@pass_dev -def delay_off(dev: miio.Ceil, seconds): - """Set delay off in seconds.""" - click.echo("Delay off: %s" % dev.delay_off(seconds)) - - -@cli.command() -@click.argument("scene", callback=validate_scene, required=True) -@pass_dev -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: 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: 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: 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: miio.Ceil): - """Auto CCT on.""" - click.echo("Auto CCT Off: %s" % dev.automatic_color_temperature_off()) - - -if __name__ == "__main__": - cli() diff --git a/miio/philips_eyecare_cli.py b/miio/philips_eyecare_cli.py deleted file mode 100644 index c725df8f9..000000000 --- a/miio/philips_eyecare_cli.py +++ /dev/null @@ -1,200 +0,0 @@ -import logging -import sys - -import click - -import miio # noqa: E402 -from miio.click_common import ExceptionHandlerGroup, validate_ip, validate_token -from miio.miioprotocol import MiIOProtocol - -_LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(miio.PhilipsEyecare) - - -def validate_brightness(ctx, param, value): - value = int(value) - if value < 1 or value > 100: - raise click.BadParameter("Should be a positive int between 1-100.") - return value - - -def validate_minutes(ctx, param, value): - value = int(value) - if value < 0 or value > 60: - raise click.BadParameter("Should be a positive int between 1-60.") - return value - - -def validate_scene(ctx, param, value): - value = int(value) - if value < 1 or value > 3: - raise click.BadParameter("Should be a positive int between 1-3.") - return value - - -@click.group(invoke_without_command=True, cls=ExceptionHandlerGroup) -@click.option("--ip", envvar="DEVICE_IP", callback=validate_ip) -@click.option("--token", envvar="DEVICE_TOKEN", callback=validate_token) -@click.option("-d", "--debug", default=False, count=True) -@click.pass_context -def cli(ctx, ip: str, token: str, debug: int): - """A tool to command Xiaomi Philips Eyecare Smart Lamp 2.""" - - if debug: - logging.basicConfig(level=logging.DEBUG) - _LOGGER.info("Debug mode active") - else: - logging.basicConfig(level=logging.INFO) - - _LOGGER.warning( - "This script is deprecated and will be removed soon, use `miiocli philipseyecare` instead" - ) - - # if we are scanning, we do not try to connect. - if ctx.invoked_subcommand == "discover": - return - - if ip is None or token is None: - click.echo("You have to give ip and token!") - sys.exit(-1) - - dev = miio.PhilipsEyecare(ip, token, debug) - _LOGGER.debug("Connecting to %s with token %s", ip, token) - - ctx.obj = dev - - if ctx.invoked_subcommand is None: - ctx.invoke(status) - - -@cli.command() -def discover(): - """Search for plugs in the network.""" - MiIOProtocol.discover() - - -@cli.command() -@pass_dev -def status(dev: miio.PhilipsEyecare): - """Returns the state information.""" - res = dev.status() - if not res: - return # bail out - - click.echo(click.style("Power: %s" % res.power, bold=True)) - click.echo("Brightness: %s" % res.brightness) - click.echo("Eye Fatigue Reminder: %s" % res.reminder) - click.echo("Ambient Light: %s" % res.ambient) - click.echo("Ambient Light Brightness: %s" % res.ambient_brightness) - click.echo("Eyecare Mode: %s" % res.eyecare) - click.echo("Eyecare Scene: %s" % res.scene) - click.echo("Night Light: %s " % res.smart_night_light) - click.echo( - "Countdown of the delayed turn off: %s minutes" % res.delay_off_countdown - ) - - -@cli.command() -@pass_dev -def on(dev: miio.PhilipsEyecare): - """Power on.""" - click.echo("Power on: %s" % dev.on()) - - -@cli.command() -@pass_dev -def off(dev: miio.PhilipsEyecare): - """Power off.""" - click.echo("Power off: %s" % dev.off()) - - -@cli.command() -@pass_dev -def eyecare_on(dev: miio.PhilipsEyecare): - """Turn eyecare on.""" - click.echo("Eyecare on: %s" % dev.eyecare_on()) - - -@cli.command() -@pass_dev -def eyecare_off(dev: miio.PhilipsEyecare): - """Turn eyecare off.""" - click.echo("Eyecare off: %s" % dev.eyecare_off()) - - -@cli.command() -@click.argument("level", callback=validate_brightness, required=True) -@pass_dev -def set_brightness(dev: miio.PhilipsEyecare, level): - """Set brightness level.""" - click.echo("Brightness: %s" % dev.set_brightness(level)) - - -@cli.command() -@click.argument("scene", callback=validate_scene, required=True) -@pass_dev -def set_scene(dev: miio.PhilipsEyecare, scene): - """Set eyecare scene number.""" - click.echo("Eyecare Scene: %s" % dev.set_scene(scene)) - - -@cli.command() -@click.argument("minutes", callback=validate_minutes, required=True) -@pass_dev -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: miio.PhilipsEyecare): - """Night Light on.""" - click.echo("Night Light On: %s" % dev.smart_night_light_on()) - - -@cli.command() -@pass_dev -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: miio.PhilipsEyecare): - """Eye Fatigue Reminder On.""" - click.echo("Eye Fatigue Reminder On: %s" % dev.reminder_on()) - - -@cli.command() -@pass_dev -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: miio.PhilipsEyecare): - """Ambient Light on.""" - click.echo("Ambient Light On: %s" % dev.ambient_on()) - - -@cli.command() -@pass_dev -def ambient_off(dev: miio.PhilipsEyecare): - """Ambient Light off.""" - click.echo("Ambient Light Off: %s" % dev.ambient_off()) - - -@cli.command() -@click.argument("level", callback=validate_brightness, required=True) -@pass_dev -def set_ambient_brightness(dev: miio.PhilipsEyecare, level): - """Set Ambient Light brightness level.""" - click.echo("Ambient Light Brightness: %s" % dev.set_ambient_brightness(level)) - - -if __name__ == "__main__": - cli() diff --git a/miio/plug_cli.py b/miio/plug_cli.py deleted file mode 100644 index d2edd5945..000000000 --- a/miio/plug_cli.py +++ /dev/null @@ -1,96 +0,0 @@ -import ast -import logging -import sys -from typing import Any # noqa: F401 - -import click - -import miio # noqa: E402 -from miio.click_common import ExceptionHandlerGroup, validate_ip, validate_token -from miio.miioprotocol import MiIOProtocol - -_LOGGER = logging.getLogger(__name__) -pass_dev = click.make_pass_decorator(miio.ChuangmiPlug) - - -@click.group(invoke_without_command=True, cls=ExceptionHandlerGroup) -@click.option("--ip", envvar="DEVICE_IP", callback=validate_ip) -@click.option("--token", envvar="DEVICE_TOKEN", callback=validate_token) -@click.option("-d", "--debug", default=False, count=True) -@click.pass_context -def cli(ctx, ip: str, token: str, debug: int): - """A tool to command Xiaomi Smart Plug.""" - if debug: - logging.basicConfig(level=logging.DEBUG) - _LOGGER.info("Debug mode active") - else: - logging.basicConfig(level=logging.INFO) - - _LOGGER.warning( - "This script is deprecated and will be removed soon, use `miiocli chuangmiplug` instead" - ) - - # if we are scanning, we do not try to connect. - if ctx.invoked_subcommand == "discover": - return - - if ip is None or token is None: - click.echo("You have to give ip and token!") - sys.exit(-1) - - dev = miio.ChuangmiPlug(ip, token, debug) - _LOGGER.debug("Connecting to %s with token %s", ip, token) - - ctx.obj = dev - - if ctx.invoked_subcommand is None: - ctx.invoke(status) - - -@cli.command() -def discover(): - """Search for plugs in the network.""" - MiIOProtocol.discover() - - -@cli.command() -@pass_dev -def status(dev: miio.ChuangmiPlug): - """Returns the state information.""" - res = dev.status() - if not res: - return # bail out - - click.echo(click.style("Power: %s" % res.power, bold=True)) - click.echo("Temperature: %s" % res.temperature) - - -@cli.command() -@pass_dev -def on(dev: miio.ChuangmiPlug): - """Power on.""" - click.echo("Power on: %s" % dev.on()) - - -@cli.command() -@pass_dev -def off(dev: miio.ChuangmiPlug): - """Power off.""" - click.echo("Power off: %s" % dev.off()) - - -@cli.command() -@click.argument("cmd", required=True) -@click.argument("parameters", required=False) -@pass_dev -def raw_command(dev: miio.ChuangmiPlug, cmd, parameters): - """Run a raw command.""" - params = [] # type: Any - if parameters: - params = ast.literal_eval(parameters) - click.echo("Sending cmd %s with params %s" % (cmd, params)) - click.echo(dev.raw_command(cmd, params)) - - -if __name__ == "__main__": - cli() diff --git a/pyproject.toml b/pyproject.toml index ac16ed469..a52240d45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,9 +14,6 @@ keywords = ["xiaomi", "miio", "miot", "smart home"] [tool.poetry.scripts] 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" miiocli = "miio.cli:create_cli"