Microsoft Teams Presence

Since 2019 my partner and I have been 100% work from home. It's been great, but I needed a way to show if I was in a meeting and couldn't be interrupted. The solution was an RGB light that indicates my presence in Microsoft Teams.

I first found the EBOOZ/TeamsStatus project and got it up and running. The TeamsStatus PowerShell script uses the Home Assistant API to provide a couple of entities indicating user status (offline, busy, available, etc) and activity (in a call/not in a call). This solution mostly worked for me, but there were a couple issues with reliability. TeamsStatus will do a tail of the last 1000 lines of the Teams log file on an interval and parse out any status and activity changes.

I ended up porting/tweaking the script over to a .NET command line application called TeamsPresence. My version makes a few tweaks to improve reliability. TeamsPresence relies on file watching. As soon as the log file is updated, the application will update the entity via the Home Assistant API.

Initial Configuration

When you run the application for the first time it will create a sample config.json file. To get up an running right away, update the HomeAssistantUrl and HomeAssistantToken values.

Note: You can set the AppDataRoamingPath to hard code which user profile is used for %appdata%

Some changes to Home Assistant's config is also needed. Add the following to your configuration.yaml:

sensor:
    - platform: template
      sensors:
        teams_status:
            friendly_name: "Microsoft Teams status"
            value_template: "{{states('input_text.teams_status')}}"
            icon_template: "{{state_attr('input_text.teams_status','icon')}}"
            unique_id: sensor.teams_status
        teams_activity:
            friendly_name: "Microsoft Teams activity"
            value_template: "{{states('input_text.teams_activity')}}"
            unique_id: sensor.teams_activity

input_text:
    teams_status:
        name: Microsoft Teams Status
        icon: mdi:microsoft-teams
    teams_activity:
        name: Microsoft Teams Activity
        icon: mdi:phone-off

Once these steps are completed, you should be able to start the application and see changes to your Teams status and call activity get updated both in the console and in Home Assistant.

Example Automation

Integrating TeamsPresence into a real world scenario is pretty simple. Here is the actual automation I use in Node-RED:

chrome_A7abydEbkV Click the image to get the JSON export for the flow

In my office I have the room lights on a Z-Wave switch and a HUGOAI RGBW table lamp to act as my "office indicator". The automation will change the office indicator to red when the "Teams Activity" entity changes to "In a call". When the entity changes back to "Not in a call", it will set the indicator to full white if the office lights are already on. Otherwise, it just turns off. This way the lamp adds a bit of light to the office as a bonus.

Previous Post Next Post