Table of Contents
Introduction
If you’re anything like me, you’ve probably joined a video call only to realise your lighting isn’t quite right. I use an Elgato Key Light Air, and I wanted it to turn on automatically when I joined a Microsoft Teams meeting—and off when I left. No more fumbling for the app or a physical button. While there are some Microsoft Store apps that offer similar automation, as a Mac user, those were not an option for me. So I built a Linux-based automation that does exactly that.
Why Automate Your Lighting?
Lighting matters. Whether you’re presenting, collaborating, or just catching up, good lighting helps you look professional and feel confident. Automating your Key Light Air means:
- You’ll never forget to turn it on or off
- You’ll always look your best on camera
- Your workflow stays smooth and hands-free
Why Linux?
You might be wondering—why not run this on Windows? Fair question.
I’ve got a dedicated Ubuntu server at home that already handles a few key tasks:
– It runs StrongSwan for my site-to-site VPN setup, and also acts as a point-to-site VPN client for a location where I can’t open ports 4500 and 500. This way, it initiates the connection like any client would, but also serves as a gateway for locally connected devices.
- It hosts my AzureDNSSync service to keep DNS records in sync with Azure.
- And now, it also runs this automation script as a systemd service.
Using Linux keeps things lightweight, reliable, and centralised—perfect for a headless setup that just works.
How It Works
This project combines a few powerful tools:
- This project combines a few powerful tools:
- A Python service running on Linux (as a systemd service)
- Microsoft Graph API to detect Teams presence (calls and meetings)
- Secure authentication via Azure App Registration and certificate
- Elgato Key Light Air’s local API to control the light
The script polls your Teams presence. When you enter a meeting, the light turns on. When you leave, it turns off. Simple, elegant, and effective.
Prerequisites
You’ll need:
- Entra access to register an app
- A Debian/Ubuntu-based Linux system
- Python 3.x
- An Elgato Key Light Air on your local network
Installation
You can install this simply by running the following command:
curl -fsSL https://raw.githubusercontent.com/andrew-kemp/TeamsPresence/main/install.sh -o install.sh
chmod +x install.sh
sudo ./install.sh
What the Installer Does
Running install.sh automates the entire setup process. Here’s what it does:
- Checks and Installs Dependencies
Ensures required packages are installed: python3, python3-venv, curl, and openssl. - Sets Up Project Directory
Creates /opt/teams-keylight and sets appropriate permissions. - Downloads the Application
Fetches the latest teams_presence.py and requirements.txt from the GitHub repo. - Sets Up Python Environment
Creates a virtual environment in /opt/teams-keylight/venv and installs dependencies. - Generates a Self-Signed Certificate
Creates a private key and public certificate for Azure authentication.
Saves:- Combined PEM file
- Standalone .crt file for Azure upload
- Displays Certificate Block
Shows the public certificate in the terminal.
You’ll need to:- Copy the block
- Paste it into a file named keylight.crt
- Upload it to your Azure App Registration
- Prompts for Configuration
Asks for:- Azure Tenant ID
- Azure Client ID
- Teams User ID (Object ID)
- Elgato Key Light IP
Saves these to /opt/teams-keylight/teams-keylight.conf.
- Creates a systemd Service
Installs a unit file at /etc/systemd/system/teams-keylight.service.
Configures it to run at boot and restart on failure. - Enables and Starts the Service
Reloads systemd, enables the service, and starts it immediately. - Prints Final Instructions
Reminds you to upload the certificate and provides commands to check service status and logs.
Entra Setup: App Registration & Enterprise Application
To securely access your Teams presence via Microsoft Graph, you’ll need to set up an App Registration in Microsoft Entra and configure certificate-based authentication.
Step 1: Create an App Registration
- Go to Microsoft Entra → App registrations → New registration.
- Name your app (e.g. TeamsPresenceKeyLight).
- Set Supported account types to Single tenant.
- Leave the redirect URI blank.
- Click Register.
Step 2: Upload the Certificate
- During installation, you’ll be presented with a certificate block in the terminal—this is your public certificate.
- Copy the entire certificate block, including the —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—– lines.
- Paste it into a new text file and save it as keylight.crt.
- In your App Registration, go to Certificates & secrets → Certificates → Upload certificate.
- Upload the keylight.crt file.
Step 3: Assign Microsoft Graph Permissions
- In the App Registration, go to API permissions → Add a permission.
- Choose Microsoft Graph → Application permissions.
- Search for and select Presence.Read.
- Click Add permissions.
- Back on the API permissions page, click Grant admin consent for your organisation.
Step 4: Locate Required IDs
- You’ll need the following values during setup:
- Tenant ID: Found in your App Registration → Overview.
- Client ID: Found in your App Registration → Overview.
- User Object ID: Go to Entra → Users → (your user) → Overview → copy the Object ID.
Configuration
Once installed you’ll then be asked for the following:
- Tenant ID
- Client ID
- The Object ID of the user you want to get the status for
- The IP address of the Elgato Keylight Air
This info is saved to /opt/teams-keylight/teams-keylight.conf.
Managing the Service
The installer sets up a systemd service. You can manage it with:
sudo systemctl status teams-keylight
sudo journalctl -u teams-keylight -f
sudo systemctl restart teams-keylight
Troubleshooting Tips
Authentication issues? Double-check the certificate upload.
Permission errors? Ensure the correct Graph API scope and admin consent.
Light not responding? Verify the IP and network reachability.
Conclusion
This automation has genuinely improved the quality and ease of my video calls. No more scrambling to adjust lighting before a meeting—my Elgato Key Light Air just works when I need it to. It’s a small change, but one that adds polish and professionalism to every interaction.
While there are other tools available—some even in the Microsoft Store—they’re often Windows-only. As a Mac user with a home Ubuntu server already running key services like StrongSwan VPN and AzureDNSSync, building a lightweight, Linux-native solution made perfect sense.
This project is designed to be secure, efficient, and easy to deploy. It uses certificate-based authentication with Microsoft Graph, integrates cleanly with systemd, and respects the boundaries of your network and device setup.
If you want to dig into the code, adapt it to your own environment, or contribute improvements, check out the GitHub repo:
🔗 https://github.com/andrew-kemp/TeamsPresence
Feel free to open an issue or drop a comment—I’d love to hear how you’re using it, what you’ve built on top of it, or any ideas you have for making it even better.