Skip to main content

Async client for QuickBars TV app

Project description

quickbars-bridge

Async client for the QuickBars for Home Assistant app used by the Home Assistant QuickBars integration.

This library wraps all outbound HTTP calls made from Home Assistant to a QuickBars TV device:

  • Request a pairing code
  • Confirm pairing
  • Send Home Assistant URL + long‑lived token
  • (Optional) Fetch / apply snapshot via HTTP

It is designed to satisfy Home Assistant Core’s guideline: “All communication to external devices or services must be wrapped in an external Python library hosted on PyPI.”


Installation

pip install quickbars-bridge

Import path uses underscore: quickbars_bridge

Supported Python: 3.11+ (matches modern Home Assistant requirements).


Usage

import asyncio
from quickbars_bridge import QuickBarsClient

async def main():
    client = QuickBarsClient(host="192.168.1.50", port=9123, timeout=15.0)

    # 1) Request pairing code
    code_info = await client.get_pair_code()
    print("Pair SID:", code_info.get("sid"))

    # 2) Confirm pairing (values shown are examples)
    confirm = await client.confirm_pair(
        code="123456",
        sid=code_info["sid"],
        ha_instance="192.168.1.10",
        ha_name="Home Assistant",
        ha_url="http://homeassistant.local:8123",
    )
    print("Device ID:", confirm.get("id"))

    # 3) Send HA URL + token to the TV
    result = await client.set_credentials(
        url="http://homeassistant.local:8123",
        token="<LONG_LIVED_TOKEN>"
    )
    print("Creds result:", result)

    # 4) (Optional) Snapshot via HTTP
    snap = await client.get_snapshot()
    await client.post_snapshot(snap)

asyncio.run(main())

All methods raise aiohttp.ClientResponseError for non‑2xx responses and typical network exceptions (asyncio.TimeoutError, aiohttp.ClientConnectorError, etc.). Handle these in your integration tests.


API

class QuickBarsClient:
    def __init__(self, host: str, port: int, *, timeout: float = 15.0) -> None: ...
    async def get_pair_code(self) -> dict: ...
    async def confirm_pair(self, code: str, sid: str, *, ha_instance: str | None = None,
                           ha_name: str | None = None, ha_url: str | None = None) -> dict: ...
    async def set_credentials(self, url: str, token: str) -> dict: ...
    async def get_snapshot(self) -> dict: ...
    async def post_snapshot(self, snapshot: dict) -> dict: ...

Development

# inside the library repo
python -m venv .venv && source .venv/bin/activate
pip install -U pip build twine ruff
ruff format
python -m build  # creates sdist + wheel in ./dist

Test install from TestPyPI

twine upload --repository testpypi dist/*
python -m venv /tmp/qbtest && source /tmp/qbtest/bin/activate
pip install -i https://test.pypi.org/simple/ quickbars-bridge --extra-index-url https://pypi.org/simple
python -c "from quickbars_bridge import QuickBarsClient; print(QuickBarsClient)"

Release to PyPI

twine upload dist/*

If you re‑upload, bump the version in pyproject.toml first.


Versioning

Use semantic versioning. The Home Assistant integration pins an exact version in manifest.json under "requirements": ["quickbars-bridge==X.Y.Z"].


License

MIT – see LICENSE.

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

quickbars_bridge-0.0.6.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

quickbars_bridge-0.0.6-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file quickbars_bridge-0.0.6.tar.gz.

File metadata

  • Download URL: quickbars_bridge-0.0.6.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for quickbars_bridge-0.0.6.tar.gz
Algorithm Hash digest
SHA256 647bea8012a847db6e8c7f3bc14a8f9c757511b0fd3eca73b3da46c741ad8f3e
MD5 c70bd57b45c96b9cca9c1e4df5bcb05b
BLAKE2b-256 3ab05e72937c37226d79fdccdf0304cf7fec39f9859b1438794e0a31f5f8b8ac

See more details on using hashes here.

File details

Details for the file quickbars_bridge-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for quickbars_bridge-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 65072e480d9a0c045e682acb9095666694ecae6f3dc07321ebc52ee0187d53fd
MD5 a1f2cd34b22de3627b5202e86af48c12
BLAKE2b-256 f2a00a8d37d271493ca65a4c2029d892401e8569f40e9098371725fb7aff34a4

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