Skip to content

Commit

Permalink
tapo-py: Fix sdist
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed Jan 27, 2024
1 parent 1449fa6 commit ac3bccd
Show file tree
Hide file tree
Showing 15 changed files with 1,038 additions and 996 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ file. This change log follows the conventions of

- Added support for the L530, L630, and L900 color light bulbs.

### Fixed

- Fixed a misconfiguration that was preventing the sdist package from working properly.

## [Rust v0.7.8][v0.7.8] - 2024-01-22

### Added
Expand Down
1 change: 1 addition & 0 deletions tapo-py/CHANGELOG.md
Empty file added tapo-py/py.typed
Empty file.
3 changes: 2 additions & 1 deletion tapo-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.maturin]
python-source = "tapo-py"
bindings = 'pyo3'
features = ["pyo3/extension-module"]
sdist-include = ["README.md", "CHANGELOG.md", "LICENSE"]
include = ["README.md", "CHANGELOG.md", "LICENSE", "tapo-py/tapo-py/tapo/*"]
5 changes: 5 additions & 0 deletions tapo-py/tapo-py/tapo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .tapo import *

__doc__ = tapo.__doc__
if hasattr(tapo, "__all__"):
__all__ = tapo.__all__
7 changes: 7 additions & 0 deletions tapo-py/tapo-py/tapo/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .api_client import *
from .color_light_handler import *
from .generic_device_handler import *
from .light_handler import *
from .plug_energy_monitoring_handler import *
from .plug_handler import *
from .types import *
269 changes: 269 additions & 0 deletions tapo-py/tapo-py/tapo/api_client.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
"""Tapo API Client.
Tested with light bulbs (L510, L520, L610) and plugs (P100, P105, P110, P115).
Example:
```python
import asyncio
from tapo import ApiClient
async def main():
client = ApiClient("[email protected]", "tapo-password")
device = await client.l530("192.168.1.100")
await device.on()
if __name__ == "__main__":
asyncio.run(main())
```
See [more examples](https://github.com/mihai-dinculescu/tapo/tree/main/tapo-py/examples).
"""

from .generic_device_handler import GenericDeviceHandler
from .light_handler import LightHandler
from .color_light_handler import ColorLightHandler
from .plug_handler import PlugHandler
from .plug_energy_monitoring_handler import PlugEnergyMonitoringHandler

class ApiClient:
"""Tapo API Client.
Tested with light bulbs (L510, L520, L610) and plugs (P100, P105, P110, P115).
Example:
```python
import asyncio
from tapo import ApiClient
async def main():
client = ApiClient("[email protected]", "tapo-password")
device = await client.l530("192.168.1.100")
await device.on()
if __name__ == "__main__":
asyncio.run(main())
```
See [more examples](https://github.com/mihai-dinculescu/tapo/tree/main/tapo-py/examples).
"""

def __init__(self, tapo_username: str, tapo_password: str) -> None:
"""Returns a new instance of `ApiClient`.
Args:
tapo_username (str): The Tapo username
tapo_password (str): The Tapo password
Returns:
ApiClient: Tapo API Client.
Example:
```python
import asyncio
from tapo import ApiClient
async def main():
client = ApiClient("[email protected]", "tapo-password")
device = await client.l530("192.168.1.100")
await device.on()
if __name__ == "__main__":
asyncio.run(main())
```
See [more examples](https://github.com/mihai-dinculescu/tapo/tree/main/tapo-py/examples).
"""
async def generic_device(self, ip_address: str) -> GenericDeviceHandler:
"""Specializes the given `ApiClient` into an authenticated `GenericDeviceHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
GenericDeviceHandler: Handler for generic devices. It provides the
functionality common to all Tapo [devices](https://www.tapo.com/en/).
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.generic_device("192.168.1.100")
await device.on()
```
"""
async def l510(self, ip_address: str) -> LightHandler:
"""Specializes the given `ApiClient` into an authenticated `LightHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
LightHandler: Handler for the [L510](https://www.tapo.com/en/search/?q=L510), [L520](https://www.tapo.com/en/search/?q=L520) and [L610](https://www.tapo.com/en/search/?q=L610) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.l510("192.168.1.100")
await device.on()
```
"""
async def l520(self, ip_address: str) -> LightHandler:
"""Specializes the given `ApiClient` into an authenticated `LightHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
LightHandler: Handler for the [L510](https://www.tapo.com/en/search/?q=L510), [L520](https://www.tapo.com/en/search/?q=L520) and [L610](https://www.tapo.com/en/search/?q=L610) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.l520("192.168.1.100")
await device.on()
```
"""
async def l530(self, ip_address: str) -> ColorLightHandler:
"""Specializes the given `ApiClient` into an authenticated `ColorLightHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
ColorLightHandler: Handler for the [L530](https://www.tapo.com/en/search/?q=L530), [L630](https://www.tapo.com/en/search/?q=L630) and [L900](https://www.tapo.com/en/search/?q=L900) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.l530("192.168.1.100")
await device.on()
```
"""
async def l610(self, ip_address: str) -> LightHandler:
"""Specializes the given `ApiClient` into an authenticated `LightHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
LightHandler: Handler for the [L510](https://www.tapo.com/en/search/?q=L510), [L520](https://www.tapo.com/en/search/?q=L520) and [L610](https://www.tapo.com/en/search/?q=L610) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.l610("192.168.1.100")
await device.on()
```
"""
async def l630(self, ip_address: str) -> ColorLightHandler:
"""Specializes the given `ApiClient` into an authenticated `ColorLightHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
ColorLightHandler: Handler for the [L530](https://www.tapo.com/en/search/?q=L530), [L630](https://www.tapo.com/en/search/?q=L630) and [L900](https://www.tapo.com/en/search/?q=L900) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.l630("192.168.1.100")
await device.on()
```
"""
async def l900(self, ip_address: str) -> ColorLightHandler:
"""Specializes the given `ApiClient` into an authenticated `ColorLightHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
ColorLightHandler: Handler for the [L530](https://www.tapo.com/en/search/?q=L530), [L630](https://www.tapo.com/en/search/?q=L630) and [L900](https://www.tapo.com/en/search/?q=L900) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.l900("192.168.1.100")
await device.on()
```
"""
async def p100(self, ip_address: str) -> PlugHandler:
"""Specializes the given `ApiClient` into an authenticated `PlugHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
PlugHandler: Handler for the [P100](https://www.tapo.com/en/search/?q=P100) & [P105](https://www.tapo.com/en/search/?q=P105) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.p100("192.168.1.100")
await device.on()
```
"""
async def p105(self, ip_address: str) -> PlugHandler:
"""Specializes the given `ApiClient` into an authenticated `PlugHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
PlugHandler: Handler for the [P100](https://www.tapo.com/en/search/?q=P100) & [P105](https://www.tapo.com/en/search/?q=P105) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.p105("192.168.1.100")
await device.on()
```
"""
async def p110(self, ip_address: str) -> PlugEnergyMonitoringHandler:
"""Specializes the given `ApiClient` into an authenticated `PlugEnergyMonitoringHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
PlugEnergyMonitoringHandler: Handler for the [P110](https://www.tapo.com/en/search/?q=P110) & [P115](https://www.tapo.com/en/search/?q=P115) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.p110("192.168.1.100")
await device.on()
```
"""
async def p115(self, ip_address: str) -> PlugEnergyMonitoringHandler:
"""Specializes the given `ApiClient` into an authenticated `PlugEnergyMonitoringHandler`.
Args:
ip_address (str): The IP address of the device
Returns:
PlugEnergyMonitoringHandler: Handler for the [P110](https://www.tapo.com/en/search/?q=P110) & [P115](https://www.tapo.com/en/search/?q=P115) devices.
Example:
```python
client = ApiClient("[email protected]", "tapo-password")
device = await client.p115("192.168.1.100")
await device.on()
```
"""
Loading

0 comments on commit ac3bccd

Please sign in to comment.