Microsoft Teams Status

HKCU still works for me, my code is still running with CU. That said, seems it’s also under HKLM for me. Different stop times, though…

If you tested it in PowerShell console, make sure you replace $UserName with your actual username on the machine, OR set the variable first. Otherwise it’ll fail.

1 Like

just got mine working a couple of days ago with a Hue light showing stutus.

I first tried the PowerShell task scheduler way, but the thing wanted a password (in Windows) that I had no clue what it was, so I couldn’t make the task. Then I tried the API way using PresenceLight and got this to work via Nabu Casa.

I don’t know what is better, but the API/PresensceLight works even if you sign on another computer or use the Teams app on your phone.

If anyone is interested I have copied over the seemingly abandoned project for to: https://github.com/AntoineGS/TeamsStatusV2

I have applied most of the recommendations from the Issues and Pull Requests, including support for camera detection.
The only “issue” I am aware of right now is that the icons will be the default sensor icon if the service has not sent an update to HA yet, but I preferred that over having unneeded input boxes which is what seemed to be used to get icons to show up.

Pull Requests are welcomed off course!

6 Likes

I opened 2 issues on your github. Works great, just some minor issues to smoothen things out.

image

would it be possible to create an ENV var for language too? You think this is nice addition?

Woups I was not watching this thread, I can most definitely add an environment variable for the language!
If you have other requests I created a Feature Request label in the issues.

1 Like

Seems like there is official support from Microsoft and there is a websocket

Microsoft Teams WebSocket API (notion.site)

2 Likes

The Web Socket API seems to be released officially now (it was pulled almost immediately after the first appearance). I wrote a Windows service that connects with the Teams Web Socket API and pushes the information to Home Assistant using MQTT. I published the tool on GitHub and maybe it’s useful for someone else as well. I currently have labeled the release as “pre-relase”, so it does not appear directly on the front page of the repository, but you can access it through the “Releases” link.

Right now, I have automations that switch on/off my Key Lights when a meeting starts/ends and also pauses Spotify if I join a meeting.

2 Likes

If it helps, I hooked it up using Graph and have it controlling my desk, a screen outside my study door, and my LED light strip.
I’ve got the write-up and code here: A smarter way to integrate your standing desk with Microsoft Teams – Loryan Strant, Microsoft 365 MVP

1 Like

It is unfortunate one needs an AppReg, otherwise this would be a really cool solution for me too. Love to see this kind of howto’s though!

I’ve been working on my first integration the past couple of days, using the new websocket API listed above.

Because it works from HA over the network, it is platform and OS agnostic.

Currently I have only implemented the is in meeting sensor, but I will do the rest soon.

Please take into account it is very immature and may change frequently whilst I battle test it.

7 Likes

Very cool! As somebody who contributed to various iterations of code for the script-based solutions, I’ll be watching this - seems much cleaner!

Hopefully the API exposes whether the webcam is on or not? For the various scripts out there I added a way to scan the registry for the camera turning on but it’s… clunky.

It does indeed provide a sensor whether or not the camera is on, though tbf I tend to exclusively camera on in a meeting so I may not have tested it all that well.

That being said, it flicks on whilst I’m in a meeting as expected and comes from the websockets API so I’m guessing it will work correctly.

I’ve now implemented all 6 sensors (should probably update the github to reflect that)

6 sensors in home assistant

I’ve been testing for a couple of weeks now and pretty happy with the results, allowing me to control sound notifications based on meeting status. There’s a couple of intricacies to iron out but I’m imagining their due to my lack of experience in integration development.

2 Likes

Hi, I’m just giving this a go, it looks great, I get an unexpected error when I’m trying to set up the integration though? I get an unexpected error if I leave my host as local host and put in the API token or if I change the host IP to my laptop with teams on, it thinks about it for 5 seconds and then I get an unexpected error. Hoping you can point me in the right direction please?

@malkstar - any ideas on the “unexpected error” error? Does your code require HASS server and Teams to be running on the same server?

Hi both,

Apologies, I haven’t had a great deal of computer time outside of work the past couple of weeks.

The host should indeed be the machine where the teams client is, so I have my HA server on my NAS and use the local IP of my teams client when setting up the integration.

Are you guys on Windows? I need to set up a windows machine to test with, I should get chance Monday.

Yes, I am using Windows. I assume you are running Teams on MacOS? This appears to be a Windows Firewall issue? I can use a websocket test successfully locally (browser and TEAMs on same machine) and it works. However, if run the websocket from a remote machine (such as a HA server), it fails. I don’t have admin priviledges on my laptop to open any firewall ports.

Yes also using windows, it’s my work laptop so admin permissions and firewall issues might be tricky to overcome. I have a personal laptop with windows on so could always try that as well

Pretty certain it’s a firewall issue, can set up the integration on macOS and my own windows laptop fine but it keeps failing with an unexpected error on my work laptop….need to speak nicely to IT….

That’s a shame, I was hoping it would overcome the need to speak to IT. I’ll investigate further to see if there’s any non-privileged work around.

Not sure if you are still looking for a solution, but I just created one for MacOS.

2 Likes