Skip to main content
  1. posts/

Automating Elgato Key Lights From macOS Touch Bar

·446 words·3 mins·
Christian Mohn
elgato macOS Automator
Author
Christian Mohn
IT veteran, podcaster, author, and blogger from Bergen, Norway.

Since I recently got an Elgato Key Light Air for the Home Office of Isolation™, I’ve been playing around with how to automate it. I’ve seen a lot of people using Elgato Stream Decks for automating these lights, but I don’t really have the need for a dedicated device for this. At least not yet.

As it turns out, it’s actually pretty easy to automate these lights via other means. The light itself runs a http server on port 9123, and via /elgato/lights it’s possible to connect to it’s internal API for remote control.

There is even a Postman Collection available, which makes it very easy to get started with connecting and changing settings around.

Postman connected to Elgato Key Light

Since Postman also allows you to export your API calls as a curl command, building the query in Postman is very handy

Postman export curl

Once I had two working commands, one for turning the light on with my preferred settings, and one for turning it off, I saved those as two different shell scripts:

elgato-on.sh
#

#!/bin/bash
curl --location --request PUT 'http://<your lights ip>:9123/elgato/lights' \
--header 'Content-Type: application/json' \
--data-raw '{"lights":[{"brightness":10,"temperature":162,"on":1}],"numberOfLights":1}'
view raw elgato-on.sh hosted with ❤ by GitHub

This script turns the light on, sets the brightness to 10 and the temperature to 162. Pretty straight forward.

elgato-off.sh
#

#!/bin/bash
curl --location --request PUT 'http://<your lights ip>:9123/elgato/lights' \
--header 'Content-Type: application/json' \
--data-raw '{"lights":[{"on":0}],"numberOfLights":1}'
view raw elgato-off.sh hosted with ❤ by GitHub

This script is even simpler, it just turns the light off.

If you decide to use these, be sure to replace <your lights ip> with your Elgato lights actual IP-address in your own network

All this is well and fine, and running these scripts does the job nicely. By using iCanHazShortcut, and have added keyboard shortcuts for triggering them:

iCanHazShortcut settings

But then it dawned on me, my MacBook has this pretty Touch Bar that seldom gets any love, or usage for that matter. There had to be a way of creating something for this there as well, right? Turns out, there is, and it’s actually pretty simple to add your own actions to the macOS Touch Bar.

Adding Custom Quick Actions to the macOS Touch Bar
#

  1. First off, open System Preferences -> Keyboard -> Customize Control Strip and drag the Quick Actions button to your Touch Bar

Customize Control Strip

  1. Create Quick Action in Automator

Automator Quick Action

  1. Find Run Shell Script and double click it.

Automator Run Shell Script 1

  1. Set Workflow receives to no input and put in the details for your script in the Run Shell Script window.

Automator Run Shell Script 2

  1. Set the color you want to have for your Touch Bar button and save the Quick Action with your preferred name, I used Key Light On and Key Light Off for mine.

  2. Repeat steps 1-5 for the second script. Once saved, they should appear under the Quick Actions button on the Touch Bar (added in step 1)

Touch Bar Quick Actions for Key Light

Now I can control turning the light on and off, both from my Touch Bar and via keyboard shortcuts!

Related

Issues Connecting Elgato Key Light Air to Ubiquiti UniFi Wireless Networks
·547 words·3 mins
Christian Mohn
networking ubiquiti USG UniFi WiFi elgato
macOS: Aggregate Device for Teams - Fixing Auto-Adjusting Mic Level
·331 words·2 mins
Christian Mohn
macOS Audio Teams
macOS: Hiding Menu Bar Icons With Dozer
·223 words·2 mins
Christian Mohn
macOS