Metadata-Version: 2.4
Name: pytewke
Version: 0.4.1
Summary: A Python client for LAN communications with Tewke devices
Project-URL: Homepage, https://gitlab.com/tewke/open-source/pytewke/
Author-email: Kanishkavikram Purohit <kpurohit@tewke.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Home Automation
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: aiocoap>=0.4.17
Requires-Dist: cbor2>=5.8.0
Requires-Dist: pydantic<3.0,>=2.0
Description-Content-Type: text/markdown

[![ci](https://gitlab.com/tewke/open-source/pytewke/badges/main/pipeline.svg?ignore_skipped=true)](https://gitlab.com/tewke/open-source/pytewke/-/pipelines)

# pytewke

A Python client for local CoAP communications with Tewke devices

**This library is under development**

## Usage

### Install

```bash
pip install pytewke
```

### Examples

#### Discovering Scenes and Targets

```python
import asyncio
from pprint import pprint

from pytewke import Tap
from pytewke.error import PyTewkeDiscoveryError


async def test_device():
    """Test Tap Panel device."""
    # Replace with your device's IP address
    host = "w.x.y.z"

    tap = Tap(host)
    try:
        await tap.discover()
    except PyTewkeDiscoveryError as err:
        print(f"Error connecting to {host}, error: {repr(err)}")
        return

    print("Targets:")
    targets = await tap.get_targets()
    pprint(targets)

    print("Scenes:")
    scenes = await tap.get_scenes()
    pprint(scenes)


if __name__ == "__main__":
    asyncio.run(test_device())
```

#### Example script

The repository includes an example script to quickly try it out.

Uncomment the relevant lines in `example.py` to run different examples like
discovering resources, reading config, observing state, etc.

```bash
python3 example.py
```

Note: if you have not installed pytewke but have cloned the library instead,
you will need to add the `src` folder to your `PYTHONPATH`:

```bash
PYTHONPATH="${PYTHONPATH}:/path/to/pytewke/src" python3 example.py
```

## Development

### Requirements

- aiocoap
- cbor2
- pydantic

Note: Python versions older than 3.12 have not been tested.

### Development requirements

Run the following command inside this folder

```bash
pip install .[dev]
```

Note: You will need to add the `src` folder to your `PYTHONPATH` when using
the example script or while running tests.