How to Run Mix It Up Commands from Up Deck

Date: 15 May 2020

Mix It Up app is a fantastic tool for making streaming easier. It gives you powerful tools for chat, overlays, and the MixPlay board. It even has remote client which works okay but is limited when compared to Up Deck. This is how I was able to combine Up Deck with MIU to get the best of both worlds.

MIU lets you do really complicated things which can be triggered by a single command. You can trigger them from chat, MixPlay boards, or the MIU remote app. This setup doesn’t have a way to pass arguments to the commands.

Note that this is a bit of an advanced topic. I assume that you already have Mix It Up and Up Deck installed and working. Don’t bother with this until you get those tools working.

Turn on the Developer API in MIU

The first thing you need to do is enable the Developer API in Mix It Up. This is what will allow us to run MIU commands from other tools.

Get the Command List

The MIU API is used by making HTTP REST calls to local URL. Every command has a unique identifier which is used to access it. This allows you to rename a command without changing how it’s accessed.

You can open the commands URL in a browser but it’s really messy. Instead, you can download it and examine the file with a JSON editor. Because I’m a Linux guy, I fired up Ubuntu in the WSL to use the handy tools available there.

The first step, is to download the command list. You need to re-download it everytime you add or remove commands to have the most up-to-date command list.

curl http://localhost:8911/api/commands > miu-commands.json

Get the UUID for a Specific Command

Next we have to get the UUID for the command we want to run. In this example, I’m getting the UUID for a command named scene: brb.

jq '.[] | select (.Name == "scene: brb") ' miu-commands.json

This will spit out a nicely formated JSON segment. The UUID is the ugly 16 character string in the ID field.

{
  "ID": "c3173f6c-13e5-4b6a-92c3-95124f9af667",
  "Name": "scene: brb",
  "IsEnabled": true,
  "Category": "ActionGroup",
  "GroupName": "scenes"
}

The Command

PowerShell has some great tools built-in to make POST requests to the API URL. The first thing that we need to do is create a small wrapper to make the REST calls.

param(
    [Parameter(Mandatory=$true)]
    [string]$id,
    [string]$api_url="http://localhost:8911/api/"
    )

$url="$api_url/commands/$id"
Invoke-WebRequest -uri $url -Method POST

Save the file as run-miu-command.ps1.

The cmdlet is really easy to use by hand.

.\run-miu-command.ps1` -id "uuid"

Unfortunately, that doesn’t work well from Up Deck because it doesn’t handle arguments well. To get around that, you have to create batch files for each command. The batch files are all the same except for the ID. Put them in the same directory as the .ps1 file above.

rem
powershell.exe -NoLogo -NonInteractive -WindowStyle Hidden -executionpolicy bypass -File "%~dp0/run-miu-command.ps1" -id "c3173f6c-13e5-4b6a-92c3-95124f9af667"

When you run this from the command line, it will run the MIU command with the give ID. Unfortunately, the flag -WindowStyle Hidden causes problems for Up Deck. The LOVE console is closed prematurely and that prevents UpDeck from closing cleanly. If you try to restart Up Deck, the leaves the main process hanging around listening on the network ports. Future connections then fail. The only fix, at that point, is to log out or reboot. Fortunately, Up Deck handles hiding the window for you so it’s not needed. The fixed batch file looks like this.

rem
powershell.exe -NoLogo -NonInteractive -executionpolicy bypass -File "%~dp0/run-miu-command.ps1" -id "c3173f6c-13e5-4b6a-92c3-95124f9af667"

That funky %~dp0% in the batch file is replaced with the path that contains the .bat file.

You can run those commands from any tool that lets you run commands.

Up Deck Command

Once you have a batch file for your command, you can create a button that run it. In this example the files are stored in C:\Users\you\Documents. Be sure to change the path to the batch file in the command to match your environment.

scene: brb
launch
app=C:\Users\you\Documents\scene-brb.bat

Update your deck and you should be able to press the button and trigger your MIU command.

One might be wondering, “Why didn’t you use the openurl action? Why bother with all of this PowerShell nonsense?” The openurl action would have been a lot simpler. However, it only supports HTTP GET requests and the Mix It Up API requires one to use POST requests to run commands.