📚 Matrix API Commands

TMRemote Documentation

OREI HDMI Matrix - HTTP JSON API Reference

This document describes the OREI HDMI Matrix HTTP JSON API used by TMRemote.

API Endpoint

All commands are sent via HTTP POST to:

POST http://{matrix-ip}/cgi-bin/instr
Content-Type: application/json

Default Matrix IP: 192.168.0.100

Power Control

Power On

{
  "comhead": "set poweronoff",
  "language": 0,
  "power": 1
}

Power Off (Standby)

{
  "comhead": "set poweronoff",
  "language": 0,
  "power": 0
}

Preset Management

Recall Preset

Load a saved preset configuration (1-8):
{
  "comhead": "preset set",
  "language": 0,
  "index": 1
}
Parameters: Example - Load Preset 3:
{
  "comhead": "preset set",
  "language": 0,
  "index": 3
}

Save Preset

Save current routing to a preset slot:
{
  "comhead": "preset save",
  "language": 0,
  "index": 1
}
Note: This command is not currently implemented in TMRemote but can be added if needed.

Video Routing

Set Single Output

Route a specific input to a specific output:
{
  "comhead": "video switch",
  "language": 0,
  "source": [2, 1]
}
Parameters: - First element: Input number (1-8) - Second element: Output number (1-8) Example - Route Input 2 to Output 1:
{
  "comhead": "video switch",
  "language": 0,
  "source": [2, 1]
}
Windows Command:
curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"video switch\",\"language\":0,\"source\":[2,1]}"

Set All Outputs

Route inputs to all outputs at once:
{
  "comhead": "set allsource",
  "language": 0,
  "source": [1, 2, 3, 4, 5, 6, 7, 8]
}
Parameters: - Position 0 = Output 1 - Position 1 = Output 2 - ... - Position 7 = Output 8 Example - Set custom routing:
{
  "comhead": "set allsource",
  "language": 0,
  "source": [3, 3, 1, 1, 5, 5, 2, 2]
}

This routes:


Status Queries

Get System Status

Query power status and system information:
{
  "comhead": "get system status",
  "language": 0
}
Response:
{
  "comhead": "get system status",
  "power": 1,
  "baudrate": 6,
  "beep": 0,
  "lock": 0,
  "mode": 3,
  "version": "v1.0.0"
}
Fields:

Get Video Status

Query current routing and preset information:
{
  "comhead": "get video status",
  "language": 0
}
Response:
{
  "comhead": "get video status",
  "allsource": [1, 2, 3, 4, 5, 6, 7, 8],
  "presetname": ["Atom-4", "Gaming", "Movies", "Sports", "", "", "", ""]
}
Fields: Example Response - Custom Routing:
{
  "allsource": [3, 3, 1, 1, 5, 5, 2, 2],
  "presetname": ["Atom-4", "Gaming", "", "", "", "", "", ""]
}

This shows:

Get Output Status

Query output port configuration:
{
  "comhead": "get output status",
  "language": 0
}
Response:
{
  "comhead": "get output status",
  "name": ["TV1", "TV2", "Projector", "Monitor", "Output5", "Output6", "Output7", "Output8"]
}
Fields:

Get Input Status

Query input port configuration:
{
  "comhead": "get input status",
  "language": 0
}
Response:
{
  "comhead": "get input status",
  "inname": ["PC", "Xbox", "PS5", "Apple TV", "Input5", "Input6", "Input7", "Input8"]
}
Fields:

External Audio Control

Set External Audio Output

Route audio from a specific input to external audio output:
{
  "comhead": "set extaudio",
  "language": 0,
  "source": 3
}
Parameters: Example - Route Input 3 audio to external:
{
  "comhead": "set extaudio",
  "language": 0,
  "source": 3
}

Disable External Audio

{
  "comhead": "set extaudio",
  "language": 0,
  "source": 0
}
Note: Setting source to 0 disables external audio output.

EDID Management

Set EDID Mode

{
  "comhead": "set edid",
  "language": 0,
  "edid": [input, mode]
}
Parameters: EDID Mode Values:
Value EDID Mode
1 1080P, Stereo Audio 2.0
2 1080P, Dolby/DTS 5.1
3 1080P, HD Audio 7.1
10 4K60(444), Stereo Audio 2.0
21 4K60(420)_HDR, HD Audio 7.1
36 FRL12G_8K_HDR, HD Audio 7.1
24 COPY_FROM_OUTPUT_1
25 COPY_FROM_OUTPUT_2
26 COPY_FROM_OUTPUT_3
27 COPY_FROM_OUTPUT_4
28 COPY_FROM_OUTPUT_5
29 COPY_FROM_OUTPUT_6
30 COPY_FROM_OUTPUT_7
31 COPY_FROM_OUTPUT_8
Example - Set Input 1 to 4K HDR 7.1:
{
  "comhead": "set edid",
  "language": 0,
  "edid": [1, 21]
}
Windows Command:
curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"set edid\",\"language\":0,\"edid\":[1,21]}"
Example - Set Input 2 to copy EDID from Output 1:
{
  "comhead": "set edid",
  "language": 0,
  "edid": [2, 24]
}
Windows Command:
curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"set edid\",\"language\":0,\"edid\":[2,24]}"

Usage in TMRemote

Implemented Commands

CLI:
<h1>Power</h1>
TMRemote.exe MATRIX_ON
TMRemote.exe MATRIX_OFF

<h1>Video Routing</h1> TMRemote.exe SWITCH 2 5

<h1>Presets</h1> TMRemote.exe PRESET1 TMRemote.exe PRESET8

<h1>EDID Configuration</h1> TMRemote.exe SET_EDID 1 21 TMRemote.exe SET_EDID 2 24

<h1>Status</h1> TMRemote.exe CHECK_POWER TMRemote.exe CHECK_VIDEO TMRemote.exe CHECK_OUTPUT TMRemote.exe CHECK_INPUT
GUI:

Not Yet Implemented

The following API commands are not currently implemented in TMRemote but can be added:

# Proposed CLI syntax:
TMRemote.exe SET_EXTAUDIO 3  # Route Input 3 audio to external
# Proposed CLI syntax:
TMRemote.exe SAVE_PRESET 1  # Save current routing to Preset 1

Adding New Commands to TMRemote

To add video routing or other commands to TMRemote:

1. Add to CommandControl.cs

For Matrix Commands (GetCommandPayload method):

// Set single output
if (command == "SET_OUTPUT" && modifier != null)
{
    var parts = modifier.Split(',');
    if (parts.Length == 2 &&
        int.TryParse(parts[0], out int output) &&
        int.TryParse(parts[1], out int input))
    {
        return JsonSerializer.Serialize(new
        {
            comhead = "set video",
            language = 0,
            index = output,
            source = input
        });
    }
}

// Set all outputs
if (command == "SET_ALL" && modifier != null)
{
    var parts = modifier.Split(',');
    if (parts.Length == 8)
    {
        var sources = new int[8];
        for (int i = 0; i < 8; i++)
        {
            if (!int.TryParse(parts[i], out sources[i]))
                return null;
        }
        return JsonSerializer.Serialize(new
        {
            comhead = "set allsource",
            language = 0,
            source = sources
        });
    }
}

2. Add to s_staticCommands Dictionary

{ "SET_OUTPUT", "set video" },
{ "SET_ALL", "set allsource" },
{ "SET_EXTAUDIO", "set extaudio" },
{ "SAVE_PRESET", "preset save" },

3. Update Help Text (Program.cs)

Console.WriteLine("Video Routing:");
Console.WriteLine("  SET_OUTPUT <out> <in>  Route input to output");
Console.WriteLine("  SET_ALL <1,2,3...>     Set all outputs");
Console.WriteLine();
Console.WriteLine("External Audio:");
Console.WriteLine("  SET_EXTAUDIO <input>   Route input to ext audio");

4. Add GUI Controls (Optional)

Create a routing matrix UI in RemoteForm.cs with:


Testing API Commands (Windows)

Using curl (Windows Command Prompt):

curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"set poweronoff\",\"language\":0,\"power\":1}"

curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"get video status\",\"language\":0}"

curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"video switch\",\"language\":0,\"source\":[3,1]}"

curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"set allsource\",\"language\":0,\"source\":[1,2,3,4,5,6,7,8]}"

Using PowerShell:

Invoke-RestMethod -Uri "http://192.168.0.100/cgi-bin/instr" -Method POST -ContentType "application/json" -Body '{"comhead":"set poweronoff","language":0,"power":1}'

Invoke-RestMethod -Uri "http://192.168.0.100/cgi-bin/instr" -Method POST -ContentType "application/json" -Body '{"comhead":"get video status","language":0}'

Invoke-RestMethod -Uri "http://192.168.0.100/cgi-bin/instr" -Method POST -ContentType "application/json" -Body '{"comhead":"video switch","language":0,"source":[3,1]}'

Invoke-RestMethod -Uri "http://192.168.0.100/cgi-bin/instr" -Method POST -ContentType "application/json" -Body '{"comhead":"set allsource","language":0,"source":[1,2,3,4,5,6,7,8]}'

Common Patterns (Windows)

Query Before Change

REM 1. Query current routing
curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"get video status\",\"language\":0}"

REM 2. Make changes - Route Input 3 to Output 1 curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"video switch\",\"language\":0,\"source\":[3,1]}"

REM 3. Verify change curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"get video status\",\"language\":0}"

Save Custom Routing as Preset

REM 1. Set desired routing
curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"set allsource\",\"language\":0,\"source\":[3,3,1,1,5,5,2,2]}"

REM 2. Save to preset curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"preset save\",\"language\":0,\"index\":1}"

REM 3. Test recall curl -X POST http://192.168.0.100/cgi-bin/instr -H "Content-Type: application/json" -d"{\"comhead\":\"preset set\",\"language\":0,\"index\":1}"

Notes


Last Updated: 2025 TMRemote Version: 1.0 Target Device: OREI HDMI Matrix (HTTP JSON API)
↑ Top