HTTP Client for Hella's ONYX.CENTER API.
Project description
Onyx Client
This repository contains a Python HTTP client for Hella' s ONYX.CENTER API.
API Versions
It is encouraged to always update Hella devices to the latest software. This will, mostly, also enforce using the newest API. In below table you can find an indication of what Hella API version is supported.
Hella API Version | Client Version |
---|---|
v3 | > = 3.1.0 < 4.0.0 |
v2 | > = 2.5.0 < 3.0.0 |
Installation
The package is published in (Test)PyPi and can be installed via:
pip install onyx-client
Configuration
The configuration defines connection properties as a dict
for the application running.
Attention: make sure to read the Onyx API Access Control description to retrieve the fingerprint and access token!
Option | Description |
---|---|
fingerprint | The fingerprint of the ONYX.CENTER. |
access_token | The permanent access token. |
client_session | The initialized aiohttp.ClientSession . (Default: None , create new session.) |
Access Control Helper
The method onyx_client.authorizer.exchange_code
takes the API code and performs the exchange to a fingerprint
and access token. Please follow the aforementioned documentation to retrieve the code.
Usage
You can instantiate the client using the onyx_client.client.create
method like:
import aiohttp
from onyx_client.client import create
from onyx_client.authorizer import exchange_code
# by providing the fingerprint and access token only
client = create(fingerprint="fingerprint", access_token="access_token")
# by providing the fingerprint, access token and aiohttp client session
client = create(fingerprint="fingerprint", access_token="access_token", client_session=aiohttp.ClientSession())
# by providing the configuration object
client_session = aiohttp.ClientSession()
# e.g. by exchanging the code first
config = exchange_code("code", client_session)
client = create(config=config, client_session=client_session) if client_session is not None else None
An example is shown in the examples
directory.
Development
The project uses poetry and to install all dependencies and the build environment, run:
$ pip install poetry
$ poetry install
Testing
- Install all dependencies as shown above.
- Run
pytest
by:
$ poetry run pytest
# or
$ pytest
Linting and Code Style
The project uses flakehell as a wrapper for flake8, and black for automated code style fixing, also using pre-commit.
- Install all dependencies as shown above.
- (Optional) Install pre-commit hooks:
$ poetry run pre-commit install
- Run black:
$ poetry run black .
- Run flakehell:
$ poetry run flakehell lint
Building
This package uses poetry-dynamic-versioning which infers the version number based on the Git tags. Hence, to have a proper versioning for the distribution, use Python's build system like:
$ pip install build
$ python -m build
Your distribution will be in the dist
directory.
Commit Message
This project follows Conventional Commits, and your commit message must also
adhere to the additional rules outlined in .conform.yaml
.
Release
To draft a release, use standard-version:
$ standard-version
# alternatively
$ npx standard-version
Finally, push with tags:
$ git push --follow-tags
Contributions
Please feel free to contribute, be it with Issues or Pull Requests! Please read the Contribution guidelines
Supporting
If you enjoy the application and want to support my efforts, please feel free to buy me a coffe. :)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for onyx_client-3.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0919f1046d97d99e199141c9f6407f231394e9e99c7e4b6659c42297358828a |
|
MD5 | 5adbf4b4c99d96d9a0db5a91a0137025 |
|
BLAKE2b-256 | eea866cb5fd2c813100067870dbc80e69f8277760d1bf2607d9df2381fcb725b |