Skip to content

Commit

Permalink
tapo-py: Add black formatter config
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed Mar 29, 2024
1 parent 9b535e5 commit 8568e7d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tapo-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ python-source = "tapo-py"
bindings = 'pyo3'
features = ["pyo3/extension-module"]
include = ["README.md", "CHANGELOG.md", "LICENSE", "tapo-py/tapo-py/tapo/*"]

[tool.black]
line-length = 100
26 changes: 20 additions & 6 deletions tapo-py/tapo-py/tapo/color_light_handler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ class ColorLightHandler:
"""Private constructor.
It should not be called from outside the tapo library.
"""

async def refresh_session(self) -> None:
"""Refreshes the authentication session."""

async def on(self) -> None:
"""Turns *on* the device."""

async def off(self) -> None:
"""Turns *off* the device."""

async def device_reset(self) -> None:
"""*Hardware resets* the device.
Expand All @@ -26,6 +30,7 @@ class ColorLightHandler:
This feature is especially useful when the device is difficult to access
and requires reconfiguration.
"""

async def get_device_info(self) -> DeviceInfoColorLightResult:
"""Returns *device info* as `DeviceInfoColorLightResult`.
It is not guaranteed to contain all the properties returned from the Tapo API.
Expand All @@ -36,19 +41,22 @@ class ColorLightHandler:
DeviceInfoColorLightResult: Device info of Tapo L530, L630 and L900.
Superset of `GenericDeviceInfoResult`.
"""

async def get_device_info_json(self) -> dict:
"""Returns *device info* as json.
It contains all the properties returned from the Tapo API.
Returns:
dict: Device info as a dictionary.
"""

async def get_device_usage(self) -> DeviceUsageResult:
"""Returns *device usage* as `DeviceUsageResult`.
Returns:
DeviceUsageResult: Contains the time usage.
"""

def set(self) -> ColorLightSetDeviceInfoParams:
"""Returns a `ColorLightSetDeviceInfoParams` builder that allows
multiple properties to be set in a single request.
Expand All @@ -58,25 +66,29 @@ class ColorLightHandler:
ColorLightSetDeviceInfoParams: Builder that is used by the
`ColorLightHandler.set` API to set multiple properties in a single request.
"""

async def set_brightness(self, brightness: int) -> None:
"""Sets the *brightness* and turns *on* the device.
Args:
brightness (int): between 1 and 100
"""

async def set_color(self, color: Color) -> None:
"""Sets the *color* and turns *on* the device.
Args:
color (Color): one of `tapo.Color` as defined in the Google Home app.
"""

async def set_hue_saturation(self, hue: int, saturation: int) -> None:
"""Sets the *hue*, *saturation* and turns *on* the device.
Args:
hue (int): between 1 and 360
saturation (int): between 1 and 100
"""

async def set_color_temperature(self, color_temperature: int) -> None:
"""Sets the *color temperature* and turns *on* the device.
Expand Down Expand Up @@ -154,10 +166,12 @@ class ColorLightSetDeviceInfoParams:
"""Turns *on* the device.
`ColorLightSetDeviceInfoParams.send` must be called at the end to apply the changes.
"""

def off(self) -> ColorLightSetDeviceInfoParams:
"""Turns *off* the device.
`ColorLightSetDeviceInfoParams.send` must be called at the end to apply the changes.
"""

def brightness(self, brightness: int) -> ColorLightSetDeviceInfoParams:
"""Sets the *brightness*.
`ColorLightSetDeviceInfoParams.send` must be called at the end to apply the changes.
Expand All @@ -166,6 +180,7 @@ class ColorLightSetDeviceInfoParams:
Args:
brightness (int): between 1 and 100
"""

def color(self, color: Color) -> ColorLightSetDeviceInfoParams:
"""Sets the *color*.
`ColorLightSetDeviceInfoParams.send` must be called at the end to apply the changes.
Expand All @@ -174,9 +189,8 @@ class ColorLightSetDeviceInfoParams:
Args:
color (Color): one of `tapo.Color` as defined in the Google Home app.
"""
def hue_saturation(
self, hue: int, saturation: int
) -> ColorLightSetDeviceInfoParams:

def hue_saturation(self, hue: int, saturation: int) -> ColorLightSetDeviceInfoParams:
"""Sets the *hue* and *saturation*.
`ColorLightSetDeviceInfoParams.send` must be called at the end to apply the changes.
The device will also be turned *on*, unless `ColorLightSetDeviceInfoParams.off` is called.
Expand All @@ -185,9 +199,8 @@ class ColorLightSetDeviceInfoParams:
hue (int): between 1 and 360
saturation (int): between 1 and 100
"""
def color_temperature(
self, color_temperature: int
) -> ColorLightSetDeviceInfoParams:

def color_temperature(self, color_temperature: int) -> ColorLightSetDeviceInfoParams:
"""
Sets the *color temperature*.
`ColorLightSetDeviceInfoParams.send` must be called at the end to apply the changes.
Expand All @@ -196,5 +209,6 @@ class ColorLightSetDeviceInfoParams:
Args:
color_temperature (int): between 2500 and 6500
"""

async def send(self) -> None:
"""Performs a request to apply the changes to the device."""
5 changes: 5 additions & 0 deletions tapo-py/tapo-py/tapo/generic_device_handler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ class GenericDeviceHandler:
"""Private constructor.
It should not be called from outside the tapo library.
"""

async def refresh_session(self) -> None:
"""Refreshes the authentication session."""

async def on(self) -> None:
"""Turns *on* the device."""

async def off(self) -> None:
"""Turns *off* the device."""

async def get_device_info(self) -> DeviceInfoGenericResult:
"""Returns *device info* as `DeviceInfoGenericResult`.
It is not guaranteed to contain all the properties returned from the Tapo API.
Expand All @@ -24,6 +28,7 @@ class GenericDeviceHandler:
Returns:
DeviceInfoGenericResult: Device info of a Generic Tapo device.
"""

async def get_device_info_json(self) -> dict:
"""Returns *device info* as json.
It contains all the properties returned from the Tapo API.
Expand Down
8 changes: 8 additions & 0 deletions tapo-py/tapo-py/tapo/light_handler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ class LightHandler:
"""Private constructor.
It should not be called from outside the tapo library.
"""

async def refresh_session(self) -> None:
"""Refreshes the authentication session."""

async def on(self) -> None:
"""Turns *on* the device."""

async def off(self) -> None:
"""Turns *off* the device."""

async def device_reset(self) -> None:
"""*Hardware resets* the device.
Expand All @@ -31,6 +35,7 @@ class LightHandler:
This feature is especially useful when the device is difficult to access
and requires reconfiguration.
"""

async def get_device_info(self) -> DeviceInfoLightResult:
"""Returns *device info* as `DeviceInfoLightResult`.
It is not guaranteed to contain all the properties returned from the Tapo API.
Expand All @@ -41,19 +46,22 @@ class LightHandler:
DeviceInfoLightResult: Device info of Tapo L510, L520 and L610.
Superset of `GenericDeviceInfoResult`.
"""

async def get_device_info_json(self) -> dict:
"""Returns *device info* as json.
It contains all the properties returned from the Tapo API.
Returns:
dict: Device info as a dictionary.
"""

async def get_device_usage(self) -> DeviceUsageResult:
"""Returns *device usage* as `DeviceUsageResult`.
Returns:
DeviceUsageResult: Contains the time usage.
"""

async def set_brightness(self, brightness: int) -> None:
"""Sets the *brightness* and turns *on* the device.
Expand Down
10 changes: 10 additions & 0 deletions tapo-py/tapo-py/tapo/plug_energy_monitoring_handler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ class PlugEnergyMonitoringHandler:
"""Private constructor.
It should not be called from outside the tapo library.
"""

async def refresh_session(self) -> None:
"""Refreshes the authentication session."""

async def on(self) -> None:
"""Turns *on* the device."""

async def off(self) -> None:
"""Turns *off* the device."""

async def device_reset(self) -> None:
"""*Hardware resets* the device.
Expand All @@ -29,6 +33,7 @@ class PlugEnergyMonitoringHandler:
This feature is especially useful when the device is difficult to access
and requires reconfiguration.
"""

async def get_device_info(self) -> DeviceInfoPlugResult:
"""Returns *device info* as `DeviceInfoPlugResult`.
It is not guaranteed to contain all the properties returned from the Tapo API.
Expand All @@ -39,33 +44,38 @@ class PlugEnergyMonitoringHandler:
DeviceInfoPlugResult: Device info of Tapo P100, P105, P110 and P115.
Superset of `GenericDeviceInfoResult`.
"""

async def get_device_info_json(self) -> dict:
"""Returns *device info* as json.
It contains all the properties returned from the Tapo API.
Returns:
dict: Device info as a dictionary.
"""

async def get_device_usage(self) -> DeviceUsageEnergyMonitoringResult:
"""Returns *device usage* as `DeviceUsageResult`.
Returns:
DeviceUsageEnergyMonitoringResult:
Contains the time usage, the power consumption, and the energy savings of the device.
"""

async def get_current_power(self) -> CurrentPowerResult:
"""Returns *current power* as `CurrentPowerResult`.
Returns:
CurrentPowerResult: Contains the current power reading of the device.
"""

async def get_energy_usage(self) -> EnergyUsageResult:
"""Returns *energy usage* as `EnergyUsageResult`.
Returns:
EnergyUsageResult:
Contains local time, current power and the energy usage and runtime for today and for the current month.
"""

async def get_energy_data(
self,
interval: EnergyDataInterval,
Expand Down
7 changes: 7 additions & 0 deletions tapo-py/tapo-py/tapo/plug_handler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ class PlugHandler:
"""Private constructor.
It should not be called from outside the tapo library.
"""

async def refresh_session(self) -> None:
"""Refreshes the authentication session."""

async def on(self) -> None:
"""Turns *on* the device."""

async def off(self) -> None:
"""Turns *off* the device."""

async def device_reset(self) -> None:
"""*Hardware resets* the device.
Expand All @@ -25,6 +29,7 @@ class PlugHandler:
This feature is especially useful when the device is difficult to access
and requires reconfiguration.
"""

async def get_device_info(self) -> DeviceInfoPlugResult:
"""Returns *device info* as `DeviceInfoPlugResult`.
It is not guaranteed to contain all the properties returned from the Tapo API.
Expand All @@ -35,13 +40,15 @@ class PlugHandler:
DeviceInfoPlugResult: Device info of Tapo P100, P105, P110 and P115.
Superset of `GenericDeviceInfoResult`.
"""

async def get_device_info_json(self) -> dict:
"""Returns *device info* as json.
It contains all the properties returned from the Tapo API.
Returns:
dict: Device info as a dictionary.
"""

async def get_device_usage(self) -> DeviceUsageResult:
"""Returns *device usage* as `DeviceUsageResult`.
Expand Down

0 comments on commit 8568e7d

Please sign in to comment.