hegel-ip-client
Python client library for Hegel amplifiers with async support and push notifications.
Features
- Async/await support - Built on asyncio for non-blocking I/O
- Push notifications - Real-time state updates from the amplifier
- Automatic reconnection - Resilient connection management with exponential backoff
- Command queuing - FIFO queue for command responses
- Full protocol support - Power, volume, mute, input selection, and more
Installation
pip install hegel-ip-client
Quick Start
import asyncio
from hegel_ip_client import HegelClient, COMMANDS
async def main():
# Create client
client = HegelClient("192.168.1.100", 50001)
# Register callback for push messages
def on_push(message):
print(f"Received push: {message}")
client.add_push_callback(on_push)
# Start connection manager
await client.start()
# Send commands
power_state = await client.send(COMMANDS["power_query"])
print(f"Power state: {power_state.power}")
# Set volume
await client.send(COMMANDS["volume_set"](50), expect_reply=False)
# Stop client when done
await client.stop()
asyncio.run(main())
API Reference
HegelClient
__init__(host: str, port: int = 50001)
Create a new Hegel client.
async start()
Start the connection manager. Automatically handles reconnection.
async stop()
Stop the client and close the connection.
async send(command: str, expect_reply: bool = True, timeout: float = 5.0) -> Optional[HegelStateUpdate]
Send a command to the amplifier.
command: Command string (useCOMMANDSdict for convenience)expect_reply: Whether to wait for a replytimeout: Maximum time to wait for reply- Returns:
HegelStateUpdatewith parsed state changes, orNoneifexpect_reply=False
add_push_callback(callback: Callable[[str], None])
Register a callback for push messages from the amplifier.
HegelStateUpdate
Dataclass representing state changes from the amplifier:
power: Optional[bool]- Power state (True=on, False=off)volume: Optional[float]- Volume level (0.0 to 1.0)mute: Optional[bool]- Mute state (True=muted)input: Optional[int]- Selected input number (1-20)reset: Optional[str]- Reset/heartbeat message
COMMANDS
Dictionary of pre-defined commands:
power_on,power_off,power_queryvolume_set(level),volume_query,volume_up,volume_downmute_on,mute_off,mute_queryinput_set(idx),input_queryreset_query
Protocol Details
The Hegel TCP protocol uses carriage return (\r) as the line terminator. Commands and replies are text-based.
Example Commands
-p.?- Query power state-p.1- Power on-p.0- Power off-v.?- Query volume-v.50- Set volume to 50-v.u- Volume up-v.d- Volume down-m.1- Mute on-m.0- Mute off-i.?- Query input-i.1- Select input 1
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and feature requests, please use the GitHub issue tracker.
Metadata
Release files for hegel-ip-client 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hegel_ip_client-0.1.4.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hegel_ip_client-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / hegel_ip_client-0.1.4.tar.gz
| Download URL | hegel_ip_client-0.1.4.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
566293211fc0ecdf9845e55c5bc0b6ae8348678031b49776889605fd628db65e
|
|
BLAKE2b-256 checksum How to use checksums |
8c12528a5ea6319a42a5e815d3cbd1110f0408ad5afe92e7b2906a1ae20258c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / hegel_ip_client-0.1.4-py3-none-any.whl
| Download URL | hegel_ip_client-0.1.4-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11ff755d6d937d04b06f88be1e39bc74d2d392639b5c4ed530b89c7722446bbb
|
|
BLAKE2b-256 checksum How to use checksums |
de5e9ed120ae88f022b08933a0bdd674a5a1cc6dfb83594e2bb73a87b3bffa65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|