Package: onyx-client
Onyx ClientThis repository contains aPython HTTP clientforHella'
sONYX.CENTER API.API VersionsIt 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 VersionClient Versionv3>= 3.1.0v2>= 2.5.0 < 3.0.0InstallationThe package is published in(Test)PyPiand can be installed via:pipinstallonyx-clientConfigurationThe configuration definesconnection propertiesas adictfor the application running.Attention: make sure toreadtheOnyx API Access Controldescription toretrieve the
fingerprint and access token!OptionDescriptionfingerprintThe fingerprint of the ONYX.CENTER.access_tokenThe permanent access token.client_sessionThe initializedaiohttp.ClientSession. (Default:None, create new session.)Access Control HelperThe methodonyx_client.authorizer.exchange_codetakes theAPI codeand performs the exchange to afingerprint
and access token. Please follow theaforementioned documentationto retrieve the code.UsageInitalizationYou can instantiate the client using theonyx_client.client.createmethod like:importaiohttpfromonyx_client.clientimportcreatefromonyx_client.authorizerimportexchange_code# by providing the fingerprint and access token onlyclient=create(fingerprint="fingerprint",access_token="access_token")# by providing the fingerprint, access token and aiohttp client sessionclient=create(fingerprint="fingerprint",access_token="access_token",client_session=aiohttp.ClientSession())# by providing the configuration objectclient_session=aiohttp.ClientSession()# e.g. by exchanging the code firstconfig=exchange_code("code",client_session)client=create(config=config,client_session=client_session)ifclient_sessionisnotNoneelseNoneEventsYou can register a event callback which will be triggered if the client receives a device update:# all imports and a client exists...defreceived_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 yourcallbackand will create an event loop in the background.StreamingYou can stream device updates directly and process them through, e.g., anasync forloop:# all imports and a client exists...asyncfordeviceinclient.events():print(device)ExamplesThe following examples are available in theexamplesdirectory:events: uses the callback mechanism (start(),stop())streaming: uses the streaming mechanism (events())DevelopmentThe project usespoetryand to install all dependencies and the build environment, run:pipinstallpoetry
poetryinstallTestingInstall all dependencies as shown above.Runpytestby:poetryrunpytest# orpytestLinting and Code StyleThe project usesrufffor automated code linting and fixing, also usingpre-commit.Install all dependencies as shown above.(Optional) Install pre-commit hooks:poetryrunpre-commitinstallRun ruff:poetryrunruffcheck.# poetry run ruff format .BuildingThis package usespoetry-dynamic-versioningwhich infers the
version number based on the Git tags. Hence, to have a proper versioning for the distribution, use Python's build system
like:pipinstallbuild
python-mbuildYour distribution will be in thedistdirectory.Commit MessageThis project followsConventional Commits, and your commit message must also
adhere to the additional rules outlined in.conform.yaml.ContributorsThanks goes to these wonderful people (emoji key):Daniel Mühlbachler-Pietrzykowski🚧💻📖Mathias Mitterdorfer💻This project follows theall-contributorsspecification. Contributions of any kind welcome!SupportingIf you enjoy the application and want to support my efforts, please feel free to buy me a coffe. :)