An open source python script to display your Microsoft Teams presence to an RGB LED panel. This project uses an Unicorn pHAT for Raspberry Pi Zero combined with the latest version of the Microsoft Graph API. It supports a variety of presence types, eg.
The Python script pulls the Microsoft Teams presence by using the Microsoft Graph API every 30 seconds and prints the result to console. The presence object will then be converted to a color, which is displayed with the pHAT.
The script includes the checked features, while others are planned:
- Display the current Microsoft Teams presence as RGB
- Update the status every 30 seconds
- Turn off LEDs at night
- Start script with arguments
- Check for version number
- Check for weekdays
The difference of this solution in comparison to my original inspiration is that my app
- has no heavy web servers running in the background
- no need for installing homebridge
- no need for writing custom plugins
- has a simple download and registration process.
- Get Rasbian running with the latest version of Python3
- Solder your Unicorn pHAT with your Raspberry Pi
- Optionally use a diffuser to make the result more attractive
To install the script and all the according libraries, clone the repository and run the sudo ./install.sh
command.
This will install the UNICORN library, install python-dev
and update your packages.
Also, you will need to create your own Azure AD app. You will probably need permissions from your Azure administrator. As an alternative use the ids from the original project.
To run the script, simply execute the main file with sudo python3 teams-presence.py
. If you start the script the first time, it will ask you for your Azure Tenant ID and Azure Client ID.
Next it will ask you to register the app with your Azure Active Directory by following the displayed URL and logging in with your Microsoft work credentials. These will be stored in a cache file.
Note: The script requires sudo, elsewise it will fail to run.
Get all options with the sudo python3 teams-presence.py --help
command. Included is:
--help
Prints the help dialog--version
Prints the version number of the script--refresh
Sets the refresh value in seconds. Must be greater than 10 seconds.--brightness
Sets the brightness of your pHAT. Must be between 0.1 and 1.--afterwork
Check for presence after working hours.--nopulse
Disables pulsing, if after work hours.
This project is inspired by the original project back from April 2020 by Elio Struyf. He did an awesome job with his project, but it felt strange on how complicated everything was by setting up a local webserver and adding homebridge to update a presence light. Therefore I took the idea from pulling the presence status, but removing all the web service and homebridge parts. My version of the Teams presence status indicator simply pulls the Microsoft Graph API every 30 seconds and converts the result into a color, which will be displayed by the RGBs.
The script uses the presence object from the Microsoft Graph API. Implemented types are:
- Available
- Away
- BeRightBack
- Busy
- DoNotDisturb
- InACall
- InAConferenceCall
- Inactive
- InAMeeting
- Offline
- OffWork
- OutOfOffice
- PresenceUnknown
- Presenting
- UrgentInterruptionsOnly