Weinzierl BAOS 777 REST API client for Python. Async/await support with circuit breaker resilience.
Project description
luxorliving-baos
Weinzierl BAOS 777 REST API client for Python. Async/await support with circuit breaker resilience.
A standalone Python library for communicating with the Theben LUXORliving KNX system via the IP1 interface's BAOS REST API.
Installation
pip install luxorliving-baos
Quick Start
import asyncio
from luxorliving_baos import BAOSRestClient
async def main():
async with BAOSRestClient("192.168.1.3") as client:
# Login with credentials
token = await client.login("admin", "your_password")
print(f"✅ Logged in. Token: {token[:20]}...")
# Enable KNX tunneling
await client.enable_tunneling()
print("✅ KNX Tunneling enabled")
# Check tunneling status
status = await client.get_tunneling_status()
print(f"📊 Status: {status}")
# Logout (auto-disables tunneling)
await client.logout()
print("✅ Logged out")
if __name__ == "__main__":
asyncio.run(main())
Features
- Async/Await: Fully asynchronous with asyncio
- Session Management: Automatic login/logout with 24-hour session expiry tracking
- KNX Tunneling: Enable/disable KNX tunneling via REST API
- Circuit Breaker: Resilient error handling with automatic recovery
- TLS Legacy Support: Custom SSL context for IP1's legacy TLS requirements
- No Blocking I/O: Pure async, safe for use in Home Assistant and other async frameworks
API Reference
BAOSRestClient
Main client class for BAOS 777 REST API communication.
client = BAOSRestClient(
host="192.168.1.3",
port=443,
use_https=True,
session=None # Optional: provide your own aiohttp.ClientSession
)
Methods
async login(username: str, password: str) -> str— Login and return session tokenasync logout()— Logout and end session (auto-disables tunneling)async enable_tunneling() -> bool— Enable KNX tunnelingasync disable_tunneling() -> bool— Disable KNX tunnelingasync get_tunneling_status() -> dict— Get tunneling statusis_authenticated— Property: check if client is authenticatedget_diagnostics() -> dict— Get diagnostic info
Exceptions
AuthenticationError— Login failed or session expiredTunnelingError— Tunneling activation failedCircuitBreakerOpenException— Circuit breaker is open (service recovering)
Circuit Breaker
The library includes a resilient circuit breaker pattern for REST API calls. It automatically:
- Opens after 3 consecutive failures
- Waits 30 seconds before attempting recovery
- Closes after 2 consecutive successes
- Times out operations after 15 seconds
Using with Home Assistant
The library is designed to work with Home Assistant's async patterns:
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from luxorliving_baos import BAOSRestClient
async def setup(hass, config):
# Use Home Assistant's shared session
session = async_get_clientsession(hass, verify_ssl=False)
client = BAOSRestClient("192.168.1.3", session=session)
await client.login("admin", "password")
# ... rest of setup
Development
Setup
git clone https://github.com/phismith91/luxorliving-baos
cd luxorliving-baos
pip install -e ".[dev]"
pre-commit install
Testing
# Run tests
pytest tests/ -n 1
# With coverage
pytest tests/ --cov=src/luxorliving_baos --cov-report=html
# Type checking
mypy src/
# Linting
flake8 src/ tests/
pylint src/
bandit src/
Pre-commit Hooks
The repo uses pre-commit hooks for code quality (black, isort, flake8, bandit, etc.).
pre-commit run --all-files
Requirements
- Python >= 3.13
- aiohttp >= 3.10.0
License
MIT License - see LICENSE file
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
References
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 luxorliving_baos-0.0.1.tar.gz.
File metadata
- Download URL: luxorliving_baos-0.0.1.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fdee5cb635018ab15a1fe00900c358c428798944b56969e593f2b776dabe2f1
|
|
| MD5 |
1f3ce4042b667140ec018034d0cc3029
|
|
| BLAKE2b-256 |
5b99335a3b6fc42d0123ac53305e5da21c6c2769161b8a75cfde803bea5e612a
|
File details
Details for the file luxorliving_baos-0.0.1-py3-none-any.whl.
File metadata
- Download URL: luxorliving_baos-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dd1228db2ada62042e9ab499adeb9fd0bc0c2d8a05247f1ab6ccaca4e6e163b
|
|
| MD5 |
700b6bc0a609001ba0eb6cedecbc2260
|
|
| BLAKE2b-256 |
aa29cdc351dc2f03127029b7678e78571d0117d03c148ba85b92fc9b825be1c3
|