Skip to main content

Async Typed Python package for the Chemelex (nVent) RAYCHEM SENZ RestAPI

Project description

pysenz package

PyPI PyPI - Downloads PyPI - License

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


Download files

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

Source Distribution

pysenz-1.0.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

pysenz-1.0.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

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

Hashes for pysenz-1.0.0.tar.gz
Algorithm Hash digest
SHA256 09e9061940fb5856d6b7e336938d09d87cefbb173e42ece8379d05425dace526
MD5 3981959b6f4f8611c172421a6786fe08
BLAKE2b-256 d86bb8f4086114b3a00e076684bae1ab9023ffb49897638dc2b98b7e7d12bc7f

See more details on using hashes here.

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

Hashes for pysenz-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a0e3e2de012d4774d1299dcfa0648454727a62d4e2f55b274fbbc6b97f8289a
MD5 bf7201b82d159eed629d37db77f3a6d9
BLAKE2b-256 3fe45945a37a57594d40e454a92dc6a9d9176bde7365e5493a4a5a1b81af74e9

See more details on using hashes here.

Supported by

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