Microsoft Teams + Home Assistant + Graph = take your presence to the next level

If you’re unfamiliar with Home Assistant, it is an open-source home automation platform with A LOT of integrations and extensibility.

I’ve previously written about being able to integrate Microsoft Teams with Alexa for changing your status, using Power Apps to display my current presence and calendar, Power Automate to change your Teams status message, using a Kuando Busylight to indicate whether you’re on a call, and I also have call indicators built into my Jabra Evolve 2 85 headset, but all of these only go so far due to their level of integration.

While Home Assistant offers a number of simple integrations out of the box, the real power is when you start adding in custom components and getting under the hood.

Since my blog post about creating a Power App that displayed my calendar and call presence, I’ve actually replaced that system with DAKboard as it’s much simpler, feature-rich, and prettier than attempting to offer the same functionality in Power Apps. I’m sure it could be done, but at $5pm that’s a better use of my time.

To make this DAKboard experience work well I use an app called Fully Kiosk Browser on Android to manage the screen sleep time, refresh, display, etc. Because Fully Kiosk Browser can be integrated into Home Assistant – that means I can set the URL it loads via workflow. As a result, I have weekday automations that loads my calendar and presence information in DAKboard at the start of the day, as well as turning on the LED strip in the cabinet behind me. At the end of the day a workflow runs to switch the URL to display temperature around the house, and to turn off the LED strip.

What does any of this have to do with Microsoft Teams you ask? Well, the LED strip was my segway – so just deal with my rambling, please!

There are already a few solutions for changing your Microsoft Teams presence in Home Assistant, but these require something to run on the client side such as an application or even a PowerShell script. I’m not a fan of adding more dependencies onto my computer, especially as I often switch between two of them (sometimes using both at the same time in different rooms).

I wanted something to integrate with my presence in real time, which is where I came across the O365-HomeAssistant custom component by Roger Selwyn. The solution is itself a fork of a previously created integration that used Graph but has since been archived. Roger’s primary purpose for creating and maintaining this fork is simply to keep it alive for his own usage – so I don’t think he expected me to come along and start offering tweaks and feedback.

Tips for integration

Because the solution requires the registration of an app in your Azure AD environment – you need to have Global Admin privileges. As this is not exactly something an end-user would have, however I have worked with Roger to reduce the level of permissions required for it to run – in the scenario where a non-admin may be requesting this of their tenant admins.

Additionally, the installation instructions recommend creating an app registration with the default authentication flow and specifying the redirect URI to be your Home Assistant instance. In my organisation, there are actually a few of us that use Home Assistant – so instead I recommend using the alternative authentication method as it allows you to use a generic URL and supports Multi-Factor Authentication, but then supports each user entering their own authentication URL when integrating for the first time.

The integration itself is capable of reading & writing emails, calendar, files, and other items your account has access to as it uses the Delegated permission model and requests access to those.

For my setup, I’ve only granted it access to the following permissions:

Workflows

I created three workflows that are triggered based on my presence for: Away, Available, in a call or meeting.

I added two main conditions to each workflow:

  • That my phone (which has the Home Assistant mobile app installed) must be at home as well, to prevent the workflows from running when I’m in the office
  • Only run during business hours (which is a bit fluid as I sometimes have meetings with international colleagues in the evenings)

Presence change: Away

Now, this one is really superfluous. There’s no need for it to exist, because if my wife walks or kids in the room and I’m not there – they don’t need a LED light status to show that I’m away. However, I felt it needed to be created for the purpose of having a complete solution. So, let’s start with that.

The trigger

The condition

Even though the condition for the time includes every day, the workflow won’t work unless the first condition (that my phone is in the house) is met.

The action

Here I simply change the colour of the LED strip.

Fairly straight forward.

The result

Presence change: Available

The trigger

For this I have two triggers to determine what status I’m coming from. I chose not to set a trigger for when my status is set to Available because it may be that I’m coming back to a presence of Busy or Focusing.

The condition

The screenshot is the same as the previous step – my phone should be home and that it’s a weekday.

The actions

Here I change the colour to blue. Yes, technically it should be green because that’s the colour of the presence indicator in Microsoft Teams, but it blue looks much better against a white wall and furniture.

Additionally, I change the URL in Fully Kiosk Browser to go back to showing my DAKboard screen.

Why you ask? Shouldn’t it already be showing my calendar? No, and you’ll see why in the final section.

The result

Presence change: in a call or meeting

The presence status for when you are in a call or have joined meeting is the same: InACall which makes things simple.

The trigger

I chose to add Presenting as a status option, as I do that quite a lot – so didn’t want my workflows misfiring if my status changed away from being InACall.

The condition

Again, same condition as previously.

The actions

Here I change the LED strip to be red. In my first iteration I had it set to pulsate, but people on the call found that distracting so I removed it and now just have a solid colour.

For the next action, I created a separate dashboard in Home Assistant with a couple of cards that you’ll see in the video below. I additionally added a custom component which allows me to maximise the viewable area by hiding the side navigation and overflow areas.

The result

Final thoughts

There is a short delay from the presence change to when the workflows fire, anywhere from about 12-20 seconds – which is quite reasonable.

Is this a mission-critical function? No. Is it useful? Yes.

I’d be keen to see what other Home Assistant users within the Microsoft 365 community can think up using this for.


Also published on Medium.

10 comments

  1. Thanks for sharing this! I have tried this but unfortunately even with the limited permissions as you showed above I still get ‘need admin approval’. I am using the alternate auth flow. Is there any way I can add the app without admin approval that you know of?

    1. Unfortunately not. Do you know who your admin is?
      If you point them to this article it might give them some comfort.

      1. That’s a shame. You don’t think your IT department would allow it for read only?
        I get that it’s not exactly work purpose, but surely they could appreciate it. I’m a M365 governance guy, so am very wary of what can read accounts. Originally the permissions for this component wanted to read/write mailbox & calendar, as well as access shared calendars – so I’ve been chatting with the dev on cutting that down to the basics.
        To be honest, if they don’t restrict what apps you can install on your machine, then this is actually safer. 🙂

  2. (commenting again as I don’t see my first comment showing up) thanks for sharing this! I have tried to set this up with the permissions you mentioned above, but still getting the ‘admin approval required’ when going through the auth flow. I am using the alternate auth flow. Is this expected? Any idea on how I can make this work without requiring admin approval (which I will never get)?

    1. Sorry I didn’t see this one. Unfortunately there will be no way to get around this without admin approval – as IT need to give you permission to connect to the Graph.
      The only other way I could think of achieving this outcome is a different method, using an unsupported Teams presence endpoint (I refer to it in my blog about showing what you’re listening to on Spotify in your Teams presence.

  3. First of all great read!

    I’m actually the original creator of the O365 integration that Roger Selwyn forked and now maintains, and imagine my surprise stumbling onto it here.
    And i just wanted to say how happy i am that it still lives on after my unfortunate inability to keep the integration maintained.

    Sometimes life just gets in the way, and this is a prime example of why open source projects like Home Assistant are so wonderful.
    I’ll definitely keep an eye on your blog in the future.

    Keep up the good work!

    1. Hey Patrick, thanks for the feedback!
      I’m so glad you created the original solution, and that others have kept your work and efforts alive. I’m very appreciative of what you created and what they’ve added on, as I live in Office 365 all day (it’s my job) – so it makes a huge difference to my day that I can connect it to my house.
      Thanks again!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: