Automate the Elgato Key Light Air with PowerShell

Elgato, the creator of the WiFi-capable Key Light Air, provides a couple pieces of software that work in tandem to give you remote control over these lights. These two applications are Stream Deck, which interacts with a hardware device, and Control Center, which communicates with the lights.

Every day that I’m recording video training content, or running an online meeting, I need to make sure that these lights are powered on and set to the correct brightness and color temperature. The integration between Stream Deck and Control Center isn’t reliable, however. When my computer resumes from sleep, the connection between Stream Deck and Control Center seems to break unrecoverably, unless I were to reboot my system. Hence, I sought out a more permanent and direct fix.

After doing some exploration, I discovered that the Key Light Air devices actually have a web server built in, exposing a REST API.

  • Key Light Air has an HTTP listener on TCP 9123
  • An HTTP API is available at /elgato/lights
  • The “lights” API accepts a payload (body) with several parameters

Key Light Body Example

Here’s an example of what the JSON payload looks like for controlling the Elgato Key Light Air.

{
  "Lights": [
    {
      "Temperature": 344,
      "Brightness": 100,
      "On": 1
    }
  ],
  "NumberOfLights": 1
}

Through some trial and error, I discovered that:

  • Brightness can only be set to a value between 3 and 100
  • The color temperature field can be 143 (7000K) to 344 (2900K)
  • On is either 0 or 1, depending on whether you want to switch the light on or off

I’m not entirely clear on why the Lights field is an array. Presumably you can control more than one light with a single API call. I’m not sure how you would specify which light receives which properties, as there’s no ID field that I’m aware of.

PowerShell Module

To simplify the process of automating Elgato Key Lights, I decided to wrap the HTTP REST API calls in a user-friendly PowerShell command. It should work on MacOS, Linux, and Windows.

The Elgato PowerShell module contains a single command called Set-KeyLightAir. You can turn the lights on/off, set color temperature, and brightness.

First, install the module on your system:

Install-Module -Name Elgato -Scope CurrentUser -Force

Next, simply configure the lights:

Set-ElgatoKeyLight -On -Brightness 100 -Temperature 143

Conclusion

Thanks to the REST API built into the Elgato Key Light Air, I can forget about the integration between Elgato Control Center and Stream Deck! Instead, I can just configure Stream Deck to trigger a PowerShell script that configures the lights, according to my needs.

In the future, it might be a nice user-friendly enhancement to perform a conversion of the color temperature (7000K to 2900K) over to the integer value expected by the light’s API. For now, this will have to do though.