neon.ninja

Sharing enlightening moments of home automation

Working from Home – Native macOS app

With the addition of a local websocket API to Microsoft Teams new opportunities opened up to share my meeting status with Home Assistant. And because I couldn’t find a native app for macOS, I decided to build my own called Teams Connex.

Teams Connex

Run this native macOS app to connect to Microsoft Teams through its local API and share meeting status updates to Home Assistant.

Previous Attempts

My first integration between Microsoft Teams and Home Assistant was based on the PresenceLight application running natively on my old Windows laptop. This was working fine until I refreshed my work laptop and moved a Macbook instead where the PresenceLight application is not supported.

My most recent attempt to share my meeting status from Microsoft Teams with Home Assistant was using server-based application PresenceLight. Unfortunately the setup had been a bit cumbersome, and the container has failed for me altogether a couple of weeks ago and I couldn’t get it back to work.

Microsoft Teams API

Microsoft Teams has a local API for some time now, and it has been reversed engineered and documented. In a nutshell the API allows for a local websocket connection to Teams, includes a pairing process where the user has to confirm that the app is allowed to access Teams, regular status updates during a meeting, and the ability to send certain commands to Teams to remote control your meeting experience.

Sharing the meeting status information with Home Assistant would be a nice first step because that information can then be used to for example control lighting in your office, or implement a status light for your family or housemates to always know if you are in a meeting or not, and if you are unmuted or not.

Building a native macOS app

After looking at some open-source apps made for Windows for inspiration (like TEAMS2HA written in C# and providing a Windows executable, or Teams monitor written in C# and providing a .NET based command-line tool) I decided to build my own native macOS app. Luckily there are plenty of Python libraries available that helped, including rumps which provides a simple framework to build status menu apps for macOS and PyInstaller which creates a native app for distribution.

The first version of the app connects to the Microsoft Teams instance running on the same computer. It opens a websocket connection and handles the pairing process as soon as it is initiated by making a Teams call. Any meeting updates received from Teams are directly shared with Home Assistant as soon as a valid webhook URL is configured. The setup of entities in Home Assistant needs to be done manually.

Compatibility
At the time of writing this post, I used:
* Home Assistant 2024.7.2
* Microsoft Teams 24165.1406.2974.9471 on macOS Sonoma 14.5

* Teams Connex 2024.7.1

Working from home series

  1. Working from Home – Teams Availability
  2. Working from Home – Migrate to Docker
  3. Working from Home – Native macOS app

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *