Async Typed Python package for the Chemelex (nVent) RAYCHEM SENZ RestAPI
Project description
pysenz package
This repo is based on a fork from https://github.com/milanmeu/aiosenz
An async Python wrapper for the nVent (aka Chemelex) Raychem SENZ RestAPI.
Installation
pip install pysenz
OAuth2
This package offers an AbstractSENZAuth, where you should handle the OAuth2 tokens and provide a valid access token in get_access_token(). You can use SENZAuth if you don't want to handle the OAuth2 tokens yourself.
Grant type
SENZAuth uses the Authorization Code grant type. This requires a Client ID and Client Secret, more information is available in the RestAPI documentation.
Scopes
pysenz uses the restapi, openid, and offline_access scope, this is set as default in SENZAuth and should be set in the OAuth2 client if you are using the AbstractSENZAuth class.
Example
from asyncio import run
from pysenz import SENZAuth, SENZAPI
import httpx
async def main():
async with httpx.AsyncClient() as httpx_client:
senz_auth = SENZAuth(
httpx_client,
"YOUR_CLIENT_ID",
"YOUR_CLIENT_SECRET",
redirect_uri="http://localhost:8080/auth/callback",
)
uri, state = await senz_auth.get_authorization_url()
print("Authorization URI: ", uri)
authorization_response = input("The authorization response URL: ")
await senz_auth.set_token_from_authorization_response(authorization_response)
senz_api = SENZAPI(senz_auth)
thermostats = await senz_api.get_thermostats()
for thermostat in thermostats:
print(f"{thermostat.name} temperature: {thermostat.current_temperatue}")
await senz_auth.close()
run(main())
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysenz-1.0.0.tar.gz.
File metadata
- Download URL: pysenz-1.0.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09e9061940fb5856d6b7e336938d09d87cefbb173e42ece8379d05425dace526
|
|
| MD5 |
3981959b6f4f8611c172421a6786fe08
|
|
| BLAKE2b-256 |
d86bb8f4086114b3a00e076684bae1ab9023ffb49897638dc2b98b7e7d12bc7f
|
File details
Details for the file pysenz-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pysenz-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a0e3e2de012d4774d1299dcfa0648454727a62d4e2f55b274fbbc6b97f8289a
|
|
| MD5 |
bf7201b82d159eed629d37db77f3a6d9
|
|
| BLAKE2b-256 |
3fe45945a37a57594d40e454a92dc6a9d9176bde7365e5493a4a5a1b81af74e9
|