mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
fix pre-commit issues
This commit is contained in:
parent
1779e6e122
commit
e39c6dbfa2
@ -6,13 +6,14 @@ from pprint import pformat as pf
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
from pyHS100 import Discover, SmartBulb, SmartDevice, SmartStrip
|
||||||
|
|
||||||
|
from pyHS100 import SmartPlug # noqa: E402; noqa: E402
|
||||||
|
|
||||||
if sys.version_info < (3, 6):
|
if sys.version_info < (3, 6):
|
||||||
print("To use this script you need Python 3.6 or newer! got %s" % sys.version_info)
|
print("To use this script you need Python 3.6 or newer! got %s" % sys.version_info)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
from pyHS100 import SmartPlug # noqa: E402
|
|
||||||
from pyHS100 import Discover, SmartBulb, SmartDevice, SmartStrip
|
|
||||||
|
|
||||||
|
|
||||||
pass_dev = click.make_pass_decorator(SmartDevice)
|
pass_dev = click.make_pass_decorator(SmartDevice)
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ def state(ctx, dev: SmartDevice):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if dev.is_strip:
|
if dev.is_strip:
|
||||||
for plug in range(dev.plugs):
|
for plug in dev.plugs: # type: ignore
|
||||||
is_on = plug.sync.get_is_on()
|
is_on = plug.sync.get_is_on()
|
||||||
alias = plug.sync.get_alias()
|
alias = plug.sync.get_alias()
|
||||||
click.echo(
|
click.echo(
|
||||||
|
@ -46,16 +46,16 @@ class SmartBulb(SmartDevice):
|
|||||||
if p.sync.is_variable_color_temp():
|
if p.sync.is_variable_color_temp():
|
||||||
# set the color temperature in Kelvin
|
# set the color temperature in Kelvin
|
||||||
p.sync.set_color_temp(3000)
|
p.sync.set_color_temp(3000)
|
||||||
|
|
||||||
# get the current color temperature
|
# get the current color temperature
|
||||||
print(p.sync.get_color_temp())
|
print(p.sync.get_color_temp())
|
||||||
|
|
||||||
# check whether the bulb is dimmable
|
# check whether the bulb is dimmable
|
||||||
if p.sync.is_dimmable():
|
if p.sync.is_dimmable():
|
||||||
|
|
||||||
# set the bulb to 50% brightness
|
# set the bulb to 50% brightness
|
||||||
p.sync.set_brightness(50)
|
p.sync.set_brightness(50)
|
||||||
|
|
||||||
# check the current brightness
|
# check the current brightness
|
||||||
print(p.sync.get_brightness())
|
print(p.sync.get_brightness())
|
||||||
```
|
```
|
||||||
@ -146,7 +146,6 @@ class SmartBulb(SmartDevice):
|
|||||||
:return: hue, saturation and value (degrees, %, %)
|
:return: hue, saturation and value (degrees, %, %)
|
||||||
:rtype: tuple
|
:rtype: tuple
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not await self.is_color():
|
if not await self.is_color():
|
||||||
raise SmartDeviceException("Bulb does not support color.")
|
raise SmartDeviceException("Bulb does not support color.")
|
||||||
|
|
||||||
@ -269,7 +268,7 @@ class SmartBulb(SmartDevice):
|
|||||||
info: Dict[str, Any] = {
|
info: Dict[str, Any] = {
|
||||||
"Brightness": await self.get_brightness(),
|
"Brightness": await self.get_brightness(),
|
||||||
"Is dimmable": await self.is_dimmable(),
|
"Is dimmable": await self.is_dimmable(),
|
||||||
} # type: Dict[str, Any]
|
}
|
||||||
if await self.is_variable_color_temp():
|
if await self.is_variable_color_temp():
|
||||||
info["Color temperature"] = await self.get_color_temp()
|
info["Color temperature"] = await self.get_color_temp()
|
||||||
info["Valid temperature range"] = await self.get_valid_temperature_range()
|
info["Valid temperature range"] = await self.get_valid_temperature_range()
|
||||||
|
@ -480,7 +480,7 @@ class SmartDevice:
|
|||||||
|
|
||||||
return {entry["month"]: entry[key] for entry in response}
|
return {entry["month"]: entry[key] for entry in response}
|
||||||
|
|
||||||
async def erase_emeter_stats(self) -> bool:
|
async def erase_emeter_stats(self):
|
||||||
"""Erase energy meter statistics.
|
"""Erase energy meter statistics.
|
||||||
|
|
||||||
:return: True if statistics were deleted
|
:return: True if statistics were deleted
|
||||||
@ -491,7 +491,7 @@ class SmartDevice:
|
|||||||
|
|
||||||
await self._query_helper(self.emeter_type, "erase_emeter_stat", None)
|
await self._query_helper(self.emeter_type, "erase_emeter_stat", None)
|
||||||
|
|
||||||
async def current_consumption(self) -> Optional[float]:
|
async def current_consumption(self) -> float:
|
||||||
"""Get the current power consumption in Watt.
|
"""Get the current power consumption in Watt.
|
||||||
|
|
||||||
:return: the current power consumption in Watts.
|
:return: the current power consumption in Watts.
|
||||||
@ -588,6 +588,7 @@ class SmartDevice:
|
|||||||
|
|
||||||
class SyncSmartDevice:
|
class SyncSmartDevice:
|
||||||
"""A synchronous SmartDevice speaker class.
|
"""A synchronous SmartDevice speaker class.
|
||||||
|
|
||||||
This has the same methods as `SyncSmartDevice`, however, it wraps all async
|
This has the same methods as `SyncSmartDevice`, however, it wraps all async
|
||||||
methods and call them in a blocking way.
|
methods and call them in a blocking way.
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class SmartStrip(SmartPlug):
|
|||||||
:return: Strip information dict, keys in user-presentable form.
|
:return: Strip information dict, keys in user-presentable form.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
state: Dict[str, Any] = {"LED state": self.led}
|
state: Dict[str, Any] = {"LED state": await self.get_led()}
|
||||||
for plug in self.plugs:
|
for plug in self.plugs:
|
||||||
if await plug.is_on():
|
if await plug.is_on():
|
||||||
state["Plug %s on since" % str(plug)] = await plug.get_on_since()
|
state["Plug %s on since" % str(plug)] = await plug.get_on_since()
|
||||||
|
Loading…
Reference in New Issue
Block a user