DIY: Integrating Trådfri lights with Teams presence
By Anatoly Mironov
It seems that Work from Home (WFH) is here to stay, it’s okay. I’d say, Work from a Smart Home is even more okay. To me, Home Automation (HA) and Work from Home (WFH) are really two peas in a pod.
Today’s “guest” is a tiny application that I’ve set up on my raspberry pi to listen to my presence (status) in Teams and show it with colors of my smart RGB light (IKEA Trådfri).
The code
You can find the application on github:
I’ll try to provide the needed documentation on the github repo and focus more on the story part in this blog post.
The story
I stumbled upon Elio Struyf’s blog post and I was amazed:
Wow! I thought immediately: that would be a cool challenge, I wanted to set up this, too. Although, with some adjustments for _my smart hom_e:
- I wanted to run the whole application on one raspberry pi only, because I don’t have the second one, neither I have HomeBridge installation (maybe something for future projects, though).
- I wanted to have as little code as possible, maintenance should be kept to minimal.
- I wanted to use python in order to learn more python and because python seems to be the most supported language on the pi.
- I wanted to use IKEA Trådfri lights (with a gateway and a remote) that I already have invested into.
I omit the configuration steps for Trådfri lights and Raspberry Pi, you can see them in my previous blog post:
Why show Teams presence with a smart light
Elio wrote his blog post in April this year - in the times of the lockdown in Belgium. In Sweden, we hadn’t a real lockdown, but it seems that it might come times when my children would need to be at home more while I work. In that case a superclear system that shows when I have important meetings is just awesome. Maybe, with that I am prepared for such times.
But to be really honest, the main driving factor is the fact that it is very satisfying to tinker around with this DIY stuff 😜😎
Lessons learned
There is a python wrapper for MSGraph which is awesome, but it needs more contributors:
In your Azure AD App Registration you can specify auth flow type as public, with that you don’t need to store a client secret for delegated access. That was a kind of a new thing to me.
Presence endpoint in MSGraph is in beta, make sure you call the beta endpoint. The scope is ‘https://graph.microsoft.com/Presence.Read' and you need an admin consent for that permission grant.
- api
- ikea
- msgraph
- o365
- Office 365
- office365
- presence
- programming
- python
- python3
- raspberrypi
- status
- teams
- tradfri