Async Python client for the UniFi Access local API with WebSocket event support
Project description
py-unifi-access
Async Python client for the UniFi Access local API with WebSocket event support. Designed for Home Assistant Core integrations.
Features
- Async REST client (
aiohttp) for doors, lock rules, emergency status - WebSocket with auto-reconnect and exponential backoff
- Typed Pydantic v2 models for all API responses and 13 WebSocket event types
- Stateless design for Home Assistant's
DataUpdateCoordinatorpattern
Installation
pip install py-unifi-access
Usage
import aiohttp
from unifi_access_api import UnifiAccessApiClient
async with aiohttp.ClientSession() as session:
client = UnifiAccessApiClient("192.168.1.1", "your-api-token", session)
# Authenticate
await client.authenticate()
# Get all doors (keyed by ID for quick lookup)
doors = {d.id: d for d in await client.get_doors()}
for door in doors.values():
print(f"{door.name}: {door.door_position_status}")
# Unlock a specific door by ID
await client.unlock_door("your-door-id")
# WebSocket for real-time events
ws = client.start_websocket({
"access.data.device.update": lambda msg: print(msg),
})
Development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install
pytest tests/ --cov
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
py_unifi_access-1.0.0.tar.gz
(26.3 kB
view details)
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 py_unifi_access-1.0.0.tar.gz.
File metadata
- Download URL: py_unifi_access-1.0.0.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9285ac0645c5e9b42c269fbcc87be4930645869e07616f1a8c91fa240e225b1
|
|
| MD5 |
5d06634d81f1e6d9a9cd981f72ce71a0
|
|
| BLAKE2b-256 |
20cb06cc83ca6c06a4ae61554d461607afe9e631b95b8cc96989d183b072157c
|
File details
Details for the file py_unifi_access-1.0.0-py3-none-any.whl.
File metadata
- Download URL: py_unifi_access-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
773ab7a07038792412f80ad5db0ca36003ddd5ce0f69bca8bb2976026436fdae
|
|
| MD5 |
ce5ada70047699c4ec0af8c1d1b66fab
|
|
| BLAKE2b-256 |
782e7502a6ddd77a2fea2aeaae6892a9b02ad53cfbcbbdd08ea67cac7f4c73ee
|