File: README.md

package info (click to toggle)
python-hdfury 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 140 kB
  • sloc: python: 503; makefile: 3
file content (174 lines) | stat: -rw-r--r-- 6,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# HDFury API Client

An **asynchronous Python client** for communicating with **HDFury devices** via their HTTP API.
This lightweight library provides methods for fetching device information, configuration, and issuing control commands such as reboot, hotplug, and mode changes.

## Features

* Asynchronous communication using `aiohttp`
* Fetch device information and configuration
* Issue control commands (reboot, hotplug, relay, mute, etc.)
* Built-in error handling for connection and parsing failures
* Designed for easy integration into automation tools or async workflows

## Requirements

* Python **3.11+**
* `aiohttp` library

## Usage Example

```python
import asyncio
from hdfury import HDFuryAPI, HDFuryError

async def main():
    client = HDFuryAPI("192.168.1.100")  # Replace with your device IP

    try:
        info = await client.get_info()
        print("Device Info:", info)

        board = await client.get_board()
        print("Board Info:", board)

        config = await client.get_config()
        print("Configuration:", config)

        # Example command: reboot the device
        await client.issue_reboot()
        print("Reboot command sent!")

    except HDFuryError as err:
        print(f"Error communicating with HDFury device: {err}")

    finally:
        await client.close()

asyncio.run(main())
```

## API Reference

### Class: `HDFuryAPI`

#### Initialization

```python
HDFuryAPI(host: str, session: aiohttp.ClientSession | None = None)
```

* **host** – IP address or hostname of the HDFury device.
* **session** *(optional)* – existing `aiohttp.ClientSession` to reuse.

#### Fetch Methods

| Method         | Description                                                                                  |
|----------------|----------------------------------------------------------------------------------------------|
| `get_board()`  | Get board information (`/ssi/brdinfo.ssi`)                                                   |
| `get_info()`   | Get general device info (`/ssi/infopage.ssi`)                                                |
| `get_config()` | Get configuration data (`/ssi/confpage.ssi`) and CEC data (if provided) (`/ssi/cecpage.ssi`) |

#### Command Methods

| Method                                                    | Description                                |
|-----------------------------------------------------------|--------------------------------------------|
| `issue_reboot()`                                          | Reboot the device                          |
| `issue_hotplug()`                                         | Trigger HDMI hotplug                       |
| `set_operation_mode(mode)`                                | Set device operation mode                  |
| `set_port_selection(tx0, tx1)`                            | Set HDMI input routing for TX0/TX1         |
| `set_auto_switch_inputs(state)`                           | Toggle auto input switching                |
| `set_htpc_mode_rx0(state)` → `set_htpc_mode_rx3(state)`   | Enable/disable HTPC mode per input         |
| `set_mute_tx0_audio(state)` → `set_mute_tx1_audio(state)` | Mute/unmute TX audio                       |
| `set_audio_unmute(value)`                                 | Set SINK audio unmute delay (milliseconds) |
| `set_earc_unmute(value)`                                  | Set eARC audio unmute delay (milliseconds) |
| `set_tx0_force_5v(state)` → `set_tx1_force_5v(state)`     | Force +5V output on TX ports               |
| `set_oled(state)`                                         | Enable/disable OLED display                |
| `set_oled_fade(value)`                                    | Set OLED fade timeout (seconds)            |
| `set_ir_active(state)`                                    | Enable/disable IR receiver                 |
| `set_relay(state)`                                        | Enable/disable relay state                 |
| `set_cec(state)`                                          | Enable/disable global CEC                  |
| `set_cec_rx0(state)` → `set_cec_rx3(state)`               | Enable/disable CEC per input               |
| `set_reboot_timer(value)`                                 | Set reboot timer (hours)                   |

#### Cleanup

```python
await client.close()
```

Closes any open HTTP sessions.

## Exception Handling

All exceptions inherit from `HDFuryError`.

| Exception               | Description                                               |
|-------------------------|-----------------------------------------------------------|
| `HDFuryError`           | Base exception for the HDFury client                      |
| `HDFuryConnectionError` | Connection-related errors (timeouts, bad responses, etc.) |
| `HDFuryParseError`      | Raised when JSON decoding fails                           |

## Constants

### `OPERATION_MODES`

Defined in [`const.py`](src/hdfury/const.py), this dictionary maps known operation mode identifiers to their human-readable descriptions.

```python
from hdfury import OPERATION_MODES

for mode, description in OPERATION_MODES.items():
    print(f"{mode}: {description}")
```

| Key   | Description                            |
|-------|----------------------------------------|
| `"0"` | Mode 0 - Splitter TX0/TX1 FRL5 VRR     |
| `"1"` | Mode 1 - Splitter TX0/TX1 UPSCALE FRL5 |
| `"2"` | Mode 2 - Matrix TMDS                   |
| `"3"` | Mode 3 - Matrix FRL→TMDS               |
| `"4"` | Mode 4 - Matrix DOWNSCALE              |
| `"5"` | Mode 5 - Matrix RX0:FRL5 + RX1-3:TMDS  |

These can be used to display or interpret the current operating mode returned by the device.

### `TX0_INPUT_PORTS`

Maps available **TX0** input port IDs to human-readable labels.

```python
from hdfury import TX0_INPUT_PORTS

print(TX0_INPUT_PORTS["1"])  # Output: Input 1
```

| Key   | Description |
|-------|-------------|
| `"0"` | Input 0     |
| `"1"` | Input 1     |
| `"2"` | Input 2     |
| `"3"` | Input 3     |
| `"4"` | Copy TX1    |

### `TX1_INPUT_PORTS`

Maps available **TX1** input port IDs to human-readable labels.

```python
from hdfury import TX1_INPUT_PORTS

print(TX1_INPUT_PORTS["3"])  # Output: Input 3
```

| Key   | Description |
|-------|-------------|
| `"0"` | Input 0     |
| `"1"` | Input 1     |
| `"2"` | Input 2     |
| `"3"` | Input 3     |
| `"4"` | Copy TX0    |

## License

MIT