Microsoft Teams Status

I’m using this too now. Works pretty good. Fiddling a bit with my Windows installation. Sometimes it just doens’t run. I think it is because it wakes from standby.

Just to let you know what I did and some findings.

My prerequisites
Although I do have an open windows work pc I don’t want to install an exe on my work pc. I don’t like the idea of compromising the company I work for. I also wanted to use a tool I’m familier with. Besides that I didn’t want to use a long living token, because it opens up my home assistant instance more then I like. I found many approaches aroud the internet and decided to go the powershell way.

Deadends
Reading the logs does not work any more with new teams. Teams does not log anything of interest anymore. It’s possible to activate debug to extend the logged information, but it’s turned of after 24 hours. Also using the websocket url isn’t possible anymore. Although it can be used from your local machine I think microsoft blocked it when using it over a network. I was able to reach it by localhost with postman but even trying to reach it on the same machine by it’s local ip wasn’t possible.

Trying to use a powershell script that tried to connect to teams websocket by localhost and then sending the data over to home assistant was to complicated (although probably possible). Teams generates a new token after every new query and figuring this out was too much work for me.

My solution
So I decided to look in the windows registry every few seconds for an update on the webcam state. And it works. Using teams>settings>devices and then scrolling down activates the webcam and helped debugging my script without starting an actual call.

Now I just know whether the webcam is in use or not, but for me that is enough. So for all of this I wrote a small script in powershell and send the data over to a home assistant webhook I created in an automation. I put that data into a text helper and everything gets updated when my webcam gets (de)activated. The script starts through task scheduler whenever I logon.

VPN reverse proxy and DNS

Another problem that I tackeled before I wrote my teams script (but also applies here) is that although my work laptop is on the same network it does not use my pi-hole dns which I use to hairpin my external hostname. This is because the machine uses a (split) vpn and DNS traffick goes through the vpn.

I wrote another powershell script that changes the hosts file based on the ip-range that is detected by the script (192.x vs 10.x). The script just adds or removes a line in the hosts file (192.x.x.x my.domain.xy). This is only necessary for the way I set up my instance and not when using nabu casa or when your router for example already addresses hairpining.

Here’s another option which is working great for me:

This is an exe but is stand-alone (doesn’t require installation of any kind). It also can connect to the HA API instead of MQTT (it can do either) which is much easier to handle through a reverse proxy. In fact it doesn’t require doing anything if you already have a public HA address.

2 Likes

I’ve been lurking on this thread for more than an year now and I still don’t really get it - why not raise a feature request with MS? O365 - cloud api for status (like i.e. Zoom), local instance of Teams - local API (like poll your workstation or specified endpoint). Respond with a status. That simple.

Look for Teams2ha, which does the local api.

MS flags this as containing the Wacatac trojan when going to install (Teams2HA)

Erm, doesn’t for me. You sure you get it from GitHub page?

I’m sure I’m missing something but not seeing how to get started with this.

Maintainer of the application here, I do not monitor this thread (though I seem to end up here every now and then) but I would be happy to assist you if you post on my GitHub repo!
Either as a new Issue or a Discussion.
Whenever someone has trouble setting up the application I make changes to the doc so it is easier for the next person as it usually means something is not explained properly.
So feedback and help requests are always appreciated :wink:

@mekaneck Thanks for the referral! :slight_smile:

1 Like

tested as of 4/15/2024:
RogerSelwyn/O365-HomeAssistant: Office 365 integration for Home Assistant (github.com)
Working:
image

That’s my ACTUAL account in that tenant - not my Home Assistant account in that tenant and it is reading live.

Docs here:
Installation and Configuration | O365 Home Assistant (rogerselwyn.github.io)

MUST have a good install working per:
Prerequisites | O365 Home Assistant (rogerselwyn.github.io)

And the account you login to the graph with MUST have permission to read the status of Teams usrs in the tenant.

(read: this isnt easy and wont work for many cases - you have to be able to request / specify some pretty heavy permissions in the O365 graph and be ok with dealing with MFA issues - but if you know the Global Admin… Maybe?) :slight_smile:

Yeah, I had pulled it from github. Didn’t get too much farther into it, just figured I’d share the result of my early attempt at checking it out.

I appreciate the reply. MQTT was problematic, but I was eventually able to get this working via HA Token. Working very well for me. It’s just a shame we aren’t able to get more status changes from Teams. Thanks for your work on this. Huge win after moving to the 'New" Teams.

I purchesed a busylight to warn my wife when I am in a video-call at home. It even seems possible to integrate in HA. However, I do need do login too often to keep this working.
So I just installed the native Home Assistent App on my desktop and made the camera sensor availeble to home assistant. It now indicates flawless if the camera is in use, using Teams but als using others like zoom…

Thanks for all the inspiration for integrating Teams into HA. I couldn’t find a native macOS app that talks to the new local Teams API, so I built one myself.
Please have a look here if you would like to give it a try. Feedback and contributions are welcome.