Async WebSocket and HTTP client for Level Lock API
Project description
level-ws-client
Async WebSocket and HTTP client for the Level Lock API.
Installation
pip install level-ws-client
Usage
HTTP Client
import asyncio
from aiohttp import ClientSession
from level_ws_client import Client
async def main():
async def get_token() -> str:
return "your-api-token"
async with ClientSession() as session:
client = Client(session, "https://api.level.co", get_token)
locks = await client.async_list_locks()
print(locks)
asyncio.run(main())
WebSocket Client
import asyncio
from aiohttp import ClientSession
from level_ws_client import LevelWebsocketManager
async def on_state_update(device_uuid: str, is_locked: bool | None, state: dict | None):
print(f"Device {device_uuid}: locked={is_locked}")
async def main():
async def get_token() -> str:
return "your-api-token"
async with ClientSession() as session:
ws = LevelWebsocketManager(
session,
"https://api.level.co",
get_token,
on_state_update,
)
await ws.async_start()
devices = await ws.async_get_devices()
print(devices)
await ws.async_stop()
asyncio.run(main())
Development
uv sync --all-extras --dev
uv run ruff check .
uv run black .
License
MIT
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 level_ws_client-0.1.0.tar.gz.
File metadata
- Download URL: level_ws_client-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a176e978f89d33d289173b8fde764b7c78e403d236bfdb04ca52b20b9fe0a24c
|
|
| MD5 |
0cd3fc96b0cb155fe5b37ca76c84f94a
|
|
| BLAKE2b-256 |
87fa80c89e5a246be25bd289214cb386e919499dd3c36c15bafe2550d2600c64
|
Provenance
The following attestation bundles were made for level_ws_client-0.1.0.tar.gz:
Publisher:
publish.yml on LevelHome/level-ws-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
level_ws_client-0.1.0.tar.gz -
Subject digest:
a176e978f89d33d289173b8fde764b7c78e403d236bfdb04ca52b20b9fe0a24c - Sigstore transparency entry: 831817649
- Sigstore integration time:
-
Permalink:
LevelHome/level-ws-client@887b62732109716922fd8668fa77005f82fb4c01 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LevelHome
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@887b62732109716922fd8668fa77005f82fb4c01 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file level_ws_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: level_ws_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bdc18b0f0a430f1a923a4cb4d867be278eda5b6ef9fd955cd2b0d09a6901dfc
|
|
| MD5 |
a446fb5c39b13a336ef0eaae8f8437f9
|
|
| BLAKE2b-256 |
4eae21261b079f1c96369de512df1f9a3b04240bb54e8c238b734590e141b68e
|
Provenance
The following attestation bundles were made for level_ws_client-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on LevelHome/level-ws-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
level_ws_client-0.1.0-py3-none-any.whl -
Subject digest:
1bdc18b0f0a430f1a923a4cb4d867be278eda5b6ef9fd955cd2b0d09a6901dfc - Sigstore transparency entry: 831817653
- Sigstore integration time:
-
Permalink:
LevelHome/level-ws-client@887b62732109716922fd8668fa77005f82fb4c01 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LevelHome
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@887b62732109716922fd8668fa77005f82fb4c01 -
Trigger Event:
workflow_dispatch
-
Statement type: