Skip to main content

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


Download files

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

Source Distribution

level_ws_client-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

level_ws_client-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

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

Hashes for level_ws_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a176e978f89d33d289173b8fde764b7c78e403d236bfdb04ca52b20b9fe0a24c
MD5 0cd3fc96b0cb155fe5b37ca76c84f94a
BLAKE2b-256 87fa80c89e5a246be25bd289214cb386e919499dd3c36c15bafe2550d2600c64

See more details on using hashes here.

Provenance

The following attestation bundles were made for level_ws_client-0.1.0.tar.gz:

Publisher: publish.yml on LevelHome/level-ws-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file level_ws_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for level_ws_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bdc18b0f0a430f1a923a4cb4d867be278eda5b6ef9fd955cd2b0d09a6901dfc
MD5 a446fb5c39b13a336ef0eaae8f8437f9
BLAKE2b-256 4eae21261b079f1c96369de512df1f9a3b04240bb54e8c238b734590e141b68e

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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