Skip to main content

Async Python client for LocknAlert bridge onboarding

Project description

aiolocknalert

Async Python client for LocknAlert bridge onboarding and MQTT bootstrap.

This library is used by the Home Assistant LocknAlert integration to securely retrieve MQTT connection details from a LocknAlert bridge over HTTPS during onboarding.


Features

  • Async aiohttp-based API client
  • HTTPS bridge communication
  • MQTT bootstrap credential retrieval
  • Simple onboarding flow
  • Typed exceptions for Home Assistant config flows
  • Lightweight with minimal dependencies

Installation

pip install aiolocknalert

Example

from aiohttp import ClientSession

from aiolocknalert import (
    LocknAlertBridgeApi,
    LocknAlertCannotConnect,
    LocknAlertInvalidAuth,
)

async def main() -> None:
    api = LocknAlertBridgeApi("192.168.1.50")

    async with ClientSession() as session:
        try:
            bootstrap = await api.async_bootstrap(
                session,
                serial_number="LNA123456",
            )

            print(bootstrap)

        except LocknAlertCannotConnect:
            print("Bridge unreachable")

        except LocknAlertInvalidAuth:
            print("Invalid serial number")

Bridge Onboarding Flow

  1. Home Assistant discovers or connects to the bridge
  2. User enters the LocknAlert bridge serial number
  3. Bridge validates the serial number against the hardware identity
  4. Bridge returns MQTT bootstrap credentials
  5. Home Assistant stores the credentials securely

Security Notes

The bridge never exposes stored MQTT credentials publicly.

MQTT bootstrap credentials are only returned when:

  • The provided serial number matches the physical bridge identity
  • The bridge onboarding window is active

All bridge communication occurs over HTTPS.


Requirements

  • Python 3.12+
  • aiohttp 3.9+

Development

Clone the repository:

git clone https://github.com/LocknAlert-Pty-LTD/aiolocknalert.git
cd aiolocknalert

Install development dependencies:

pip install -e .
pip install pytest pytest-asyncio

Run tests:

pytest

Build package:

python -m build

License

MIT License

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

aiolocknalert-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

aiolocknalert-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file aiolocknalert-0.1.1.tar.gz.

File metadata

  • Download URL: aiolocknalert-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aiolocknalert-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c9cb5169e22daa2df55c7109c0b5fbadaad33cb95c2b9f4a81737eca7da5c27d
MD5 2d06f2953249cfdf28ef77447dc5629c
BLAKE2b-256 f9a1868f224b6b5a0fb565235f41c97e25f064431ed599921916bc8ef001dbd2

See more details on using hashes here.

File details

Details for the file aiolocknalert-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aiolocknalert-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for aiolocknalert-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 126b2c2e1ce91d764625cbcafa05959fc2ff4d6ea8d9be33a40fcf9b0f19c3a8
MD5 13e6891eb2a7e6bb9186b0a4762b67df
BLAKE2b-256 95af3fa082e2c621fec102ade550cb3090b8f2a47f91942b43f9ba6ec1f70b8a

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