Skip to main content

Onyx Client

Buy Me A Coffee

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
v2 >= 2.5.0 < 3.0.0

Installation

The package is published in 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.
local_address The local address to use (default: None).
client_session The initialized aiohttp.ClientSession. (Default: None, create new session.)

Local Access

The local address can be used to access the ONYX.CENTER API from within the local network. If set, the client will use this address for all API requests.

Access Control Helper

The method onyx_client.authorizer.exchange_code takes the API code and an optional local API address, and performs the exchange to a fingerprint and access token. Please follow the aforementioned documentation to retrieve the code.

Usage

Initalization

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 fingerprint, access token and local API address
client = create(
    fingerprint="fingerprint", access_token="access_token", local_address="localhost"
)

# 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
)

Events

You can register a event callback which will be triggered if the client receives a device update:

# all imports and a client exists...


def received_update(device):
    print(device)


client.set_event_callback(received_update)
client.start()

# you can stop the client listening for updates using:
client.stop()

Each device update will be pushed to your callback and will create an event loop in the background.

Streaming

You can stream device updates directly and process them through, e.g., an async for loop:

# all imports and a client exists...

async for device in client.events():
    print(device)

Examples

The following examples are available in the examples directory:

  • events: uses the callback mechanism (start(), stop())
  • streaming: uses the streaming mechanism (events())

Development

The project uses poetry and to install all dependencies and the build environment, run:

pip install poetry
poetry install

Testing

  1. Install all dependencies as shown above.
  2. Run pytest by:
poetry run pytest
# or
pytest

Linting and Code Style

The project uses ruff for automated code linting and fixing, also using pre-commit.

  1. Install all dependencies as shown above.
  2. (Optional) Install pre-commit hooks:
poetry run pre-commit install
  1. Run ruff:
poetry run ruff check .
# poetry run ruff format .

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.


Contributors

Thanks goes to these wonderful people (emoji key):

Daniel Mühlbachler-Pietrzykowski
Daniel Mühlbachler-Pietrzykowski

🚧 💻 📖
Mathias Mitterdorfer
Mathias Mitterdorfer

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Supporting

If you enjoy the application and want to support my efforts, please feel free to buy me a coffe. :)

Buy Me A Coffee

Download files

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

Source Distribution

onyx_client-11.0.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onyx_client-11.0.1-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file onyx_client-11.0.1.tar.gz.

File metadata

  • Download URL: onyx_client-11.0.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for onyx_client-11.0.1.tar.gz
Algorithm Hash digest
SHA256 b62463c4c9fd4f0dce82224811d53f287ac2a64d872779cd63356a02b5daa7da
MD5 6c4b888af97b91d09d6c52036e560362
BLAKE2b-256 d6da164be7758271a044974c4103e4c4cd840d5de0995c52c1eba006155de8eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for onyx_client-11.0.1.tar.gz:

Publisher: release.yml on muhlba91/onyx-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onyx_client-11.0.1-py3-none-any.whl.

File metadata

  • Download URL: onyx_client-11.0.1-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for onyx_client-11.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77a05d016af860e1883dd8b039ca2166896b3cd6296fbb122bbdb03ccb51f61e
MD5 b543ebe904e3f608a0748ce993ecd852
BLAKE2b-256 711832cc3d925cb6e12b489b9da9a30a49db0a748ecd35b144ce5b8d15c60992

See more details on using hashes here.

Provenance

The following attestation bundles were made for onyx_client-11.0.1-py3-none-any.whl:

Publisher: release.yml on muhlba91/onyx-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

11.1.0

2 files

This release

11.0.1 This release

2 files

11.0.0

2 files

10.1.3

2 files

10.1.2

2 files

10.1.1

2 files

10.1.0

2 files

10.0.0

2 files

9.3.0

2 files

9.2.1

2 files

9.2.0

2 files

9.1.1

2 files

9.1.0

2 files

9.0.0

2 files

8.3.4

2 files

8.3.3

2 files

8.3.2

2 files

8.3.1

2 files

8.3.0

2 files

8.2.0

2 files

8.1.3

2 files

8.1.2

2 files

8.1.1

2 files

8.1.0

2 files

8.0.2

2 files

8.0.1

2 files

8.0.0

2 files

7.2.1

2 files

7.2.0

2 files

7.1.1

2 files

7.1.0

2 files

7.0.0

2 files

6.1.0

2 files

6.0.0

2 files

5.0.1

2 files

4.0.1

2 files

4.0.0

2 files

3.1.2

2 files

3.1.1

2 files

3.1.0

2 files

3.0.4

2 files

3.0.3

2 files

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.5.0

2 files

2.4.0

2 files

2.3.1

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page