Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rfleming71/pyapcsc

Python Client for APC Smart connect
https://github.com/rfleming71/pyapcsc

apc apc-smartconnect asyncio hacktoberfest home-assistant python

Last synced: about 1 month ago
JSON representation

Python Client for APC Smart connect

Awesome Lists containing this project

README

        

# pyapcsc
Python Client for APC Smart connect

# Usage
The library offers two class for interacting with the API.

## API
Provides direct access to the API. Return types are the deserialized json objects.
```
async with aiohttp.ClientSession() as websession:
websession._default_headers = MappingProxyType({}) # type: ignore
client = pyapcsc.ApcSmartConnectApi(websession)
await client.login("username", "password")
gateways = await client.gateways()
await websession.close()
```

## Client
The client class offers a typed abstraction over the API. Also the client will handle reauthenticating when the existing cookie expires.
```
async with aiohttp.ClientSession() as websession:
websession._default_headers = MappingProxyType({}) # type: ignore
client = pyapcsc.ApcSmartConnectClient(websession)
await client.login("username", "password")
gateways = await client.gateways()
await websession.close()
```