

Microsoft Teams + Home Assistant + Graph = take your presence to the next level
source link: https://www.loryanstrant.com/2022/03/04/microsoft-teams-home-assistant-graph-take-your-presence-to-the-next-level/?utm_campaign=microsoft-teams-home-assistant-graph-take-your-presence-to-the-next-level
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.
Like this:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK