Metadata-Version: 2.1
Name: awtrix-light-client
Version: 1.0.0
Summary: awtrix-light HTTP client to be used with Ulanzi clock
Home-page: https://github.com/M0NsTeRRR/awtrix-light-client
License: CeCILL
Keywords: awtrix-light,awtrix
Author: Ludovic Ortega
Author-email: ludovic.ortega@adminafk.fr
Requires-Python: >=3.9
Classifier: License :: OSI Approved :: CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Utilities
Requires-Dist: httpx (>=0.25.0,<0.26.0)
Requires-Dist: pydantic (>=2.4.2,<2.5.0)
Requires-Dist: pydantic-extra-types (>=2.1.0,<2.2.0)
Requires-Dist: pydantic-settings (>=2.0.3,<2.1.0)
Project-URL: Repository, https://github.com/M0NsTeRRR/awtrix-light-client
Description-Content-Type: text/markdown

Python async HTTP client for [awtrix-light](https://github.com/Blueforcer/awtrix-light)

[![PyPI](https://img.shields.io/pypi/v/awtrix-light-client.svg)](https://pypi.python.org/pypi/awtrix-light-client)
[![PyPI versions](https://img.shields.io/pypi/pyversions/awtrix-light-client.svg)](https://pypi.python.org/pypi/awtrix-light-client)
[![Python test](https://github.com/napalm-automation-community/awtrix-light-client/actions/workflows/test.yml/badge.svg)](https://github.com/napalm-automation-community/awtrix-light-client/actions/workflows/test.yml)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

# Warning
This client has been tested with awtrix-light v0.90 use with caution as official dev documentation is not fully documented and can cause crash

# Install
```
pip install awtrix-light-client
```

# Dev
Install [Poetry](https://python-poetry.org/docs/master/#installing-with-the-official-installer)

Install and setup dependencies
```
poetry install
poetry shell
```

# Usage
Official project documentation : https://blueforcer.github.io/awtrix-light/#/api

Available environment variables
```
AWTRIX_HTTP_CLIENT_AWTRIX="<AWTRIX CONFIG>"
```

`<AWTRIX CONFIG>` is in JSON and looks like this :
```json
{
    "base_url": "http://192.168.0.1",
    "username": "admin",
    "password": "password",
    "verify_ssl": false,
}
```
`verify_ssl` used to verify https config (if accessing behind an HTTPS reverse proxy), can be `true`, `false`, or can point to a local ca bundle PEM encoded to validate local CA

Example script
```py
import asyncio

from awtrix_light_client.http_client import get_awtrix_http_client, AwtrixLightHttpClientError


async def main():
    try:
        async with get_awtrix_http_client() as client:
            stats = await client.get_stats()
            print(stats)
    except AwtrixLightHttpClientError as e:
        print(f"HTTP code: {e.status_code}, error content: {e.content}")


asyncio.run(main())
```

### Run unit test
```
poetry run pytest --cov
```

### Run black
```
poetry run black .
```

# Licence

The code is under CeCILL license.

You can find all details here: https://cecill.info/licences/Licence_CeCILL_V2.1-en.html

# Credits

Copyright © Ludovic Ortega, 2023

Contributor(s):

-Ortega Ludovic - ludovic.ortega@adminafk.fr
