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
Releases
Merges to main now trigger an automatic release when the version in pyproject.toml
changes. The workflow will:
- run CI
- build the package
- publish it to PyPI
- create and push a matching Git tag
- create a GitHub release with generated notes
To make PyPI publishing work, configure a PyPI trusted publisher for this GitHub repository and environment:
- repository:
imhotep/py-unifi-access - workflow file:
ci.yml - environment:
pypi
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
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.2.tar.gz.
File metadata
- Download URL: py_unifi_access-1.1.2.tar.gz
- Upload date:
- Size: 27.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ba79109b8d0fd97cf2faa741601a108c0ccbd639a9dad333e7ba7c90f826b8
|
|
| MD5 |
87f0c81479b8318bfe8c08303534c309
|
|
| BLAKE2b-256 |
7b76cfd7947f1d698c87926284e0a6051f8a345a38e3a7652578a5f14e726ce8
|
Provenance
The following attestation bundles were made for py_unifi_access-1.1.2.tar.gz:
Publisher:
ci.yml on imhotep/py-unifi-access
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_unifi_access-1.1.2.tar.gz -
Subject digest:
82ba79109b8d0fd97cf2faa741601a108c0ccbd639a9dad333e7ba7c90f826b8 - Sigstore transparency entry: 1153958409
- Sigstore integration time:
-
Permalink:
imhotep/py-unifi-access@6e3e5e852cc7f182f7235f72a14a6c6b1b5b04b5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/imhotep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@6e3e5e852cc7f182f7235f72a14a6c6b1b5b04b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_unifi_access-1.1.2-py3-none-any.whl.
File metadata
- Download URL: py_unifi_access-1.1.2-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f18eefa3539b5f2ebf97f3ccdb11e6712fe0482c60c898a29c7748b0490de411
|
|
| MD5 |
20f54c196d74b008e111df749c0e6487
|
|
| BLAKE2b-256 |
203686feddd51dff06e2805de1d57990fa63dc094b3e9d8c6820458a5c275656
|
Provenance
The following attestation bundles were made for py_unifi_access-1.1.2-py3-none-any.whl:
Publisher:
ci.yml on imhotep/py-unifi-access
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_unifi_access-1.1.2-py3-none-any.whl -
Subject digest:
f18eefa3539b5f2ebf97f3ccdb11e6712fe0482c60c898a29c7748b0490de411 - Sigstore transparency entry: 1153958413
- Sigstore integration time:
-
Permalink:
imhotep/py-unifi-access@6e3e5e852cc7f182f7235f72a14a6c6b1b5b04b5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/imhotep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@6e3e5e852cc7f182f7235f72a14a6c6b1b5b04b5 -
Trigger Event:
push
-
Statement type: