cli: add human-friendly printout when calling temperature on non-supported devices (#196)

* Bug Fix

Temperature is not supported on plugs

* Efficiency on support errors

* Update kasa/cli.py

Co-authored-by: Teemu R. <tpr@iki.fi>

Co-authored-by: Teemu R. <tpr@iki.fi>
This commit is contained in:
JaydenRA 2021-09-04 01:18:21 +01:00 committed by GitHub
parent 7c9d21af7a
commit f8e7258b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -345,6 +345,9 @@ async def brightness(dev: SmartBulb, brightness: int, transition: int):
async def temperature(dev: SmartBulb, temperature: int, transition: int): async def temperature(dev: SmartBulb, temperature: int, transition: int):
"""Get or set color temperature.""" """Get or set color temperature."""
await dev.update() await dev.update()
if not dev.is_variable_color_temp:
click.echo("Device does not support color temperature")
return
if temperature is None: if temperature is None:
click.echo(f"Color temperature: {dev.color_temp}") click.echo(f"Color temperature: {dev.color_temp}")
valid_temperature_range = dev.valid_temperature_range valid_temperature_range = dev.valid_temperature_range