Skip to main content

A client supporting Home Theater Direct's gateway device.

Project description

htd-client-ha

Python async client for Home Theater Direct (HTD) whole-home audio systems. Supports the MCA-66, Lync 6, and Lync 12 over TCP or serial.

This is a maintained fork of hikirsch/python-htd with full Lync support, zone/source naming, DND, and EQ controls.

Supported Hardware

Model Zones Sources Kind
MCA-66 6 6 mca
Lync 6 6 12 lync
Lync 12 12 19 lync

The device model is auto-detected at connection time.

Installation

pip install htd-client-ha

Usage

import asyncio
from htd_client import async_get_client

async def main():
    # Connect over TCP (most common — via the HTD network gateway)
    client = await async_get_client(network_address=("192.168.1.100", 10006))
    await client.async_connect()
    await client.async_wait_until_ready()

    # Query all zone state
    await client.refresh()

    # Control a zone
    await client.async_power_on(zone=1)
    await client.async_set_volume(zone=1, volume=20)
    await client.async_set_source(zone=1, source=1)

    # Subscribe to zone state changes (push model)
    async def on_zone_update(zone):
        print(f"Zone {zone} updated")
    await client.async_subscribe(on_zone_update)

asyncio.run(main())

Zone and Source Names (Lync only)

# Query names from the controller (results cached on client)
await client.async_query_zone_name(zone=1)
await client.async_query_source_name(source=1)

# Read cached names
zone_name = client.get_zone_name(zone=1)
source_name = client.get_source_name(source=1)

# Set names on the controller
await client.async_set_zone_name(zone=1, name="Living Room")
await client.async_set_source_name(source=1, name="Sonos")

EQ Controls

await client.async_set_bass(zone=1, bass=5)
await client.async_set_treble(zone=1, treble=-2)
await client.async_set_balance(zone=1, balance=0)

Do Not Disturb (Lync only)

# Exclude a zone from party mode / all-zone commands
await client.async_set_dnd(zone=1, dnd=True)

API Reference

async_get_client(...) -> BaseClient

Factory function that auto-detects the device model and returns the appropriate client.

Parameter Type Description
network_address (str, int) (host, port) for TCP connection
serial_address str Serial port path for RS-232 connection
retry_attempts int Command retry count (default: 5)

BaseClient methods

Method Description
async_connect() Connect to the device
async_wait_until_ready() Wait for initial handshake to complete
refresh(zone=None) Query zone state (all zones if omitted)
async_subscribe(callback) Register callback for zone state changes
async_power_on(zone) Power on a zone
async_power_off(zone) Power off a zone
power_on_all_zones() Power on all zones
power_off_all_zones() Power off all zones
async_set_source(zone, source) Set active source for a zone
async_set_volume(zone, volume) Set volume (0–60)
async_volume_up(zone) Increment volume
async_volume_down(zone) Decrement volume
async_mute(zone) Mute a zone
async_unmute(zone) Unmute a zone
async_toggle_mute(zone) Toggle mute
async_set_bass(zone, bass) Set bass
async_set_treble(zone, treble) Set treble
async_set_balance(zone, balance) Set balance
async_set_dnd(zone, dnd) Set Do Not Disturb (Lync only)
async_query_zone_name(zone) Query zone name from controller (Lync only)
async_query_source_name(source) Query source name from controller (Lync only)
async_set_zone_name(zone, name) Set zone name on controller (Lync only)
async_set_source_name(source, name) Set source name on controller (Lync only)
get_zone(zone) Return cached ZoneDetail for a zone
get_zone_name(zone) Return cached zone name
get_source_name(source) Return cached source name
get_zone_count() Return number of zones for this model
get_source_count() Return number of sources for this model
disconnect() Close the connection

Contributing

Poetry is used to manage dependencies and run tests.

poetry install
poetry run pytest

License

MIT — see LICENSE for details.

Credits

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

htd_client_ha-0.1.3.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

htd_client_ha-0.1.3-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file htd_client_ha-0.1.3.tar.gz.

File metadata

  • Download URL: htd_client_ha-0.1.3.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for htd_client_ha-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b1c4cd10a231f0a54315b005e8cf575a964ffafafadc306684068b29e10bdd20
MD5 1213437c5810ead68b648bc4ee4f16f9
BLAKE2b-256 ddbc94e48cc69e6dec3f6462f2c455ddb0b5fc375a6c050e077d6ed3ee012ab8

See more details on using hashes here.

File details

Details for the file htd_client_ha-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: htd_client_ha-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for htd_client_ha-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bfdbc4578ce538d0dffd36972b388c567c79d8f95622161a35665fe2afc2f3c6
MD5 802b98f34e98e84cdf361e7f5e638d52
BLAKE2b-256 21e79f7025c49b99d47a1ed8606786ba859a24a2fbed152cfffcdfd1d3c02aa1

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