Skip to main content

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 token
  • async logout() — Logout and end session (auto-disables tunneling)
  • async enable_tunneling() -> bool — Enable KNX tunneling
  • async disable_tunneling() -> bool — Disable KNX tunneling
  • async get_tunneling_status() -> dict — Get tunneling status
  • is_authenticated — Property: check if client is authenticated
  • get_diagnostics() -> dict — Get diagnostic info

Exceptions

  • AuthenticationError — Login failed or session expired
  • TunnelingError — Tunneling activation failed
  • CircuitBreakerOpenException — 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

References

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

luxorliving_baos-0.0.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

luxorliving_baos-0.0.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

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

Hashes for luxorliving_baos-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3fdee5cb635018ab15a1fe00900c358c428798944b56969e593f2b776dabe2f1
MD5 1f3ce4042b667140ec018034d0cc3029
BLAKE2b-256 5b99335a3b6fc42d0123ac53305e5da21c6c2769161b8a75cfde803bea5e612a

See more details on using hashes here.

File details

Details for the file luxorliving_baos-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for luxorliving_baos-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7dd1228db2ada62042e9ab499adeb9fd0bc0c2d8a05247f1ab6ccaca4e6e163b
MD5 700b6bc0a609001ba0eb6cedecbc2260
BLAKE2b-256 aa29cdc351dc2f03127029b7678e78571d0117d03c148ba85b92fc9b825be1c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page