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
- Home Assistant discovers or connects to the bridge
- User enters the LocknAlert bridge serial number
- Bridge validates the serial number against the hardware identity
- Bridge returns MQTT bootstrap credentials
- 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
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 aiolocknalert-0.2.0.tar.gz.
File metadata
- Download URL: aiolocknalert-0.2.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a973f3706735ce92cfbf46f799864fe5d81609a3254bb31a7da6df99da4c302
|
|
| MD5 |
e80126f0622b9eb1df1e2c5125bb84cf
|
|
| BLAKE2b-256 |
0f577df7588c99fd37cdfc648e4baabfa5a3a0f06ed7f49b4e221ef7d1392841
|
File details
Details for the file aiolocknalert-0.2.0-py3-none-any.whl.
File metadata
- Download URL: aiolocknalert-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
845715875dccb69d439c52f9db372e9ececeda6120253bce2a662ad1d39223ff
|
|
| MD5 |
1b0aa53192bb6896a80cb556fb9159d4
|
|
| BLAKE2b-256 |
d7a8536de3ecb7dde8e68931e511646fde044a4de5e22781af5e6be8cd0b5cba
|