Skip to main content

awtrix-light HTTP client to be used with Ulanzi clock

Project description

Python async HTTP client for awtrix-light

PyPI PyPI versions Python test Code Style

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

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 :

{
    "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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awtrix_light_client-1.0.1.tar.gz (23.9 kB view hashes)

Uploaded Source

Built Distribution

awtrix_light_client-1.0.1-py3-none-any.whl (42.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page