From 02a3d1316ed7dfa4f4e77c428955c9d1dd846c29 Mon Sep 17 00:00:00 2001 From: JaydenRA Date: Fri, 3 Sep 2021 16:33:50 +0100 Subject: [PATCH 1/3] Bug Fix Temperature is not supported on plugs --- kasa/cli.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/kasa/cli.py b/kasa/cli.py index 0473dc97b..c23824e9a 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -345,19 +345,22 @@ async def brightness(dev: SmartBulb, brightness: int, transition: int): async def temperature(dev: SmartBulb, temperature: int, transition: int): """Get or set color temperature.""" await dev.update() - if temperature is None: - click.echo(f"Color temperature: {dev.color_temp}") - valid_temperature_range = dev.valid_temperature_range - if valid_temperature_range != (0, 0): - click.echo("(min: {}, max: {})".format(*valid_temperature_range)) + if not dev.is_plug: + if temperature is None: + click.echo(f"Color temperature: {dev.color_temp}") + valid_temperature_range = dev.valid_temperature_range + if valid_temperature_range != (0, 0): + click.echo("(min: {}, max: {})".format(*valid_temperature_range)) + else: + click.echo( + "Temperature range unknown, please open a github issue" + f" or a pull request for model '{dev.model}'" + ) else: - click.echo( - "Temperature range unknown, please open a github issue" - f" or a pull request for model '{dev.model}'" - ) + click.echo(f"Setting color temperature to {temperature}") + await dev.set_color_temp(temperature, transition=transition) else: - click.echo(f"Setting color temperature to {temperature}") - await dev.set_color_temp(temperature, transition=transition) + print("This device does not support temperature.") @cli.command() From 3e579eadbc6e26c7e57c31d8e09aba4f6b63c180 Mon Sep 17 00:00:00 2001 From: JaydenRA Date: Sat, 4 Sep 2021 00:31:18 +0100 Subject: [PATCH 2/3] Efficiency on support errors --- kasa/cli.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kasa/cli.py b/kasa/cli.py index c23824e9a..d019b6b54 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -345,22 +345,22 @@ async def brightness(dev: SmartBulb, brightness: int, transition: int): async def temperature(dev: SmartBulb, temperature: int, transition: int): """Get or set color temperature.""" await dev.update() - if not dev.is_plug: - if temperature is None: - click.echo(f"Color temperature: {dev.color_temp}") - valid_temperature_range = dev.valid_temperature_range - if valid_temperature_range != (0, 0): - click.echo("(min: {}, max: {})".format(*valid_temperature_range)) - else: - click.echo( - "Temperature range unknown, please open a github issue" - f" or a pull request for model '{dev.model}'" - ) + if not dev.is_variable_color_temp: + click.echo(f"Device does not support color temperature") + return + if temperature is None: + click.echo(f"Color temperature: {dev.color_temp}") + valid_temperature_range = dev.valid_temperature_range + if valid_temperature_range != (0, 0): + click.echo("(min: {}, max: {})".format(*valid_temperature_range)) else: - click.echo(f"Setting color temperature to {temperature}") - await dev.set_color_temp(temperature, transition=transition) + click.echo( + "Temperature range unknown, please open a github issue" + f" or a pull request for model '{dev.model}'" + ) else: - print("This device does not support temperature.") + click.echo(f"Setting color temperature to {temperature}") + await dev.set_color_temp(temperature, transition=transition) @cli.command() From e6dd95ffc5992308087859e87a7d0927bbb491b6 Mon Sep 17 00:00:00 2001 From: JaydenRA <75145665+JaydenRA@users.noreply.github.com> Date: Sat, 4 Sep 2021 00:44:49 +0100 Subject: [PATCH 3/3] Update kasa/cli.py Co-authored-by: Teemu R. --- kasa/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kasa/cli.py b/kasa/cli.py index d019b6b54..f9f17bceb 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -346,7 +346,7 @@ async def temperature(dev: SmartBulb, temperature: int, transition: int): """Get or set color temperature.""" await dev.update() if not dev.is_variable_color_temp: - click.echo(f"Device does not support color temperature") + click.echo("Device does not support color temperature") return if temperature is None: click.echo(f"Color temperature: {dev.color_temp}")