Python HDMI Matrix control library for AVGear and possibly other HDMI matrix controllers
Project description
AVGear HDMI Matrix Python Library
Python library to control AVGear HDMI Matrix switches (tested with TMX44PRO AVK, may work with others). Both synchronous and asynchronous APIs are provided. Contributions for other models are welcome!
This is used for the AVGear Matrix integration for homeassistant.
Inspired by pyblackbird.
Features
- TCP/IP control: Communicate with the matrix over the network
- Sync & Async APIs: Use either blocking or asyncio-based methods
- Device info: Query device name, type, version, and status
- Routing control: Route HDMI inputs to outputs programmatically
- Video status parsing: Parse and display current input/output routing
- Context manager support: Use with
withorasync withfor auto-connect/disconnect - Logging: Built-in debug/info/error logging
Installation
Clone the repo and install dependencies (if any):
git clone https://github.com/marklynch/hdmimatrix.git
cd hdmimatrix
# Optionally: pip install .
Usage
Synchronous Example
from hdmimatrix import HDMIMatrix
matrix = HDMIMatrix("192.168.0.178", 4001)
with matrix:
print(matrix.get_device_name())
print(matrix.get_device_status())
matrix.route_input_to_output(1, 1)
Asynchronous Example
import asyncio
from hdmimatrix import AsyncHDMIMatrix
async def main():
matrix = AsyncHDMIMatrix("192.168.0.178", 4001)
async with matrix:
print(await matrix.get_device_name())
print(await matrix.get_device_status())
await matrix.route_input_to_output(1, 1)
asyncio.run(main())
Video Status Parsing
with matrix:
routing = matrix.get_video_status_parsed()
print(routing) # {1: 1, 2: 3, 3: 2, 4: 4}
# Show which input is connected to each output
for output, input_num in sorted(routing.items()):
print(f" Output {output} <- Input {input_num}")
Power and Output Control
with matrix:
matrix.power_on()
matrix.power_off()
# Enable/disable individual outputs
matrix.output_on(2)
matrix.output_off(2)
API Overview
HDMIMatrix(sync) andAsyncHDMIMatrix(async) classes- Connection:
connect()disconnect()- Context manager support (
with/async with)
- Info:
is_powered_on()get_device_name()get_device_status()get_device_type()get_device_version()get_video_status()get_video_status_parsed()get_hdbt_power_status()get_input_status()get_output_status()get_hdcp_status()get_downscaling_status()
- Control:
power_on()power_off()route_input_to_output(input, output)output_on(output)output_off(output)
Development
Install with dev dependencies:
pip install -e ".[dev]"
Running Tests
# Run all tests
python3 -m pytest tests/
# Run with coverage report
python3 -m pytest tests/ --cov=hdmimatrix --cov-report=term-missing
# Generate HTML coverage report
python3 -m pytest tests/ --cov=hdmimatrix --cov-report=html
# Then open htmlcov/index.html in your browser
Contributing
Pull requests for new features, bug fixes, and support for other AVGear models are welcome!
License
MIT
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 hdmimatrix-0.3.0.tar.gz.
File metadata
- Download URL: hdmimatrix-0.3.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da164ebd189c39adc5faaf291bb6d1972b1ba98cd6453266d3aa72bc584ff345
|
|
| MD5 |
261e42a1fbd74291a0f06942d04deeb0
|
|
| BLAKE2b-256 |
b0b7e675066c9ec8a2bb1645bd409eecb8a6aeac495816d1ccff25bc906c3a9a
|
File details
Details for the file hdmimatrix-0.3.0-py3-none-any.whl.
File metadata
- Download URL: hdmimatrix-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc2228d8c63459e7fff8fe86e2051ffdd297c190628ef7510211810cc581bebd
|
|
| MD5 |
10d7458490797f081191570d878d7db6
|
|
| BLAKE2b-256 |
bfcf42ac717c8dc7cd8ced3dd5403878135149a9c6770786957da06f6771cecd
|