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.1.0.tar.gz
(27.4 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.1.0.tar.gz.
File metadata
- Download URL: py_unifi_access-1.1.0.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bda2cc5f6aa3487de3227acb7299da64fd8c0b954e0bbe5c0da37266098c956
|
|
| MD5 |
dea41d2541c23fb3fce5c45df1e7e22f
|
|
| BLAKE2b-256 |
b4c9858b2d496459077ff7e4222f6bd125d721cbc7c0ece41014898471c60587
|
File details
Details for the file py_unifi_access-1.1.0-py3-none-any.whl.
File metadata
- Download URL: py_unifi_access-1.1.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6760bc09d34342b79a12d4341bb3e318566f54e738de0619a4d230bae94aa98
|
|
| MD5 |
92f0b4dbeed2f216c9360d50bbca57da
|
|
| BLAKE2b-256 |
1d99d076e9284f229f212dae894d1b49a4c4e7eafdd94cd31ec8e370fdc1da53
|