• Vik Jaswal

Philips Hue as Presence indicator for Microsoft Teams (Zoom, Webex, & everything else)

In these extraordinary times of COVID-19, working from home is becoming a norm. Being a Consultant I have for years worked from home, so this isn’t anything new. My kids are well aware about my home working so generally are respectful, until now!


Well, with kids staying home all day long (with no idea when they are going back) they could only so much respect the rules and started to barge into my office while I am on a video call with customers. Surely, there gotta be a way to tell them do not disturb Daddy esp. when he is on a call 😊


This tweet from @shanselman gave me an idea. I wanted to setup something that was:

  • Relatively quick/easy to setup

  • No IT involvement i.e. setting up API’s, server-side permissions or configuration

  • Should work with any application – Microsoft Teams, Zoom, Webex, etc

Well, the solution turned out to be very simple:

1) Press a shortcut key (for me Ctrl+Shift+B = Busy, and Ctrl+Shift+A = Available). The shortcut keys run a little PowerShell script.

2) The Philips Hue colour outside my office changes to Red (Busy), Green (Available) to indicate my presence. Kids know if its red not to barge in/make less noise.


Curious how it all looks, here is a short video using a virtual keyboard to demonstrate, although you will typically use a physical one.

Now, you could argue you want something automatic i.e. when I get on a call the status should change automatically. Although there are API’s (at least for Microsoft Teams) built to do that (and using Flow, Logic Apps, PowerShell, IFTTT) you can automate it, typically, you need to request IT for certain level of access and technically this can get quite involved. In fact, I seem to have developed a preference for the shortcut key method as that allows me to set my status to Busy not just when I am on call on Microsoft Teams but on a mobile phone, Zoom, Webex or if just wanted some focus time.


For Microsoft Teams, if you want to use Graph API you need to have Presence.Read delegated rights which can only be provided by an administrator! For all of us techies who have our tenants that is great, but you won't easily get any rights in any reasonably sized corporate environment if the justification is- I want my Hue lights to show my presence!


The Setup

When I started, I thought I will need to hook into the Hue API, and it gonna take me few days to get off the ground. Turns out Lewis Roberts have built a PowerShell module to control all things Philips Hue! Thanks to Lewis’s module setting this up took me less than 60 minutes!

I would highly recommend if you want the low down to go through excellent documentation Lewis has got here. Here I will quickly show you how I use it. Before starting off make sure you are connected to the same network as your Philips Hue.

1. Launch PowerShell

2. Enter the command below. This will install the PowerShell module.

Install-Module -Name PoSHue

3. There are 3 key pieces of information we need before we can get started.

  • IP Address of our Philips Hue Hub

  • APIKey

  • Name of the light you want to control

IP Address of Philips Hue

In the PowerShell window you have still open enter the below commands. It can take up to 30 seconds to discover the device. Make note of the IP Address

Import-Module PoSHue
[HueBridge]::FindHueBridge()

API Key

Run the below command in the PowerShell session. Update the IP address to your Hue's:

 $Bridge = [HueBridge]::New('192.168.200.121')

Press the bridge (link) button on your Hue and run the following command. This will

generate the API key required to connect later. Save the API key securely.

$Bridge.GetNewAPIKey()

Name of the light you want to control

In the PowerShell window enter the command below. This will show you name of all the lights you have connected to the Hue Hub.

$Bridge.GetLightNames()

4. With all the above info available create 3 PowerShell script files which can be downloaded here - Available-Green.ps1 to set status of the bulb to Green, Busy-Red.ps1 to set status to Red and lastly ON.ps1 which just toggles the bulb ON/OFF. Although you can tweak these files howsoever you want or create entirely new configurations these seem to suffice what I needed to do for now.

5. The only thing you need to modify in each of the scripts are the 3 variables - $lightname, $HubIPAddress and $Token. The values for these we retrieved above.

6. Now you just need to create a shortcut for each of these files and assign a shortcut key. Right click > New > Shortcut Key and paste the text below (Update the path to where you have saved the files) and give the shortcut an appropriate name e.g. PhilipsHue-Available-Green

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\temp\Hue\PhilipsHue-Available-Green.ps1"


7. Assign the recently created shortcut a keyboard short key. To do this right click on the shortcut > Properties and enter the desired shortcut key Shortcut key field. Hit OK


8. Repeat the same steps to create the shortcut and keyboard shortcut keys for other PowerShell script files as well. This is how it will look like once you have created all the shortcuts.

Testing

To test, its as simple as pressing the shortcut keys we configured earlier to set your presence status. If your shortcuts keys don't work check if the scripts works on their own.


Caveats Please use the scripts at your own risk. There is no error checking, just few lines of code knocked up quickly.


If you have issues make sure you can connect to your Philips Hue. You can try browsing to it e.g. https://192.168.200.121. Also validate the light name and the API password is correct.


I hope you find the Philips Hue presence indicator useful. Massive thanks to Lewis whose awesome PowerShell module allowed me to get this up and running under an hour!

Never Miss a Post. Subscribe Now!

© 2020 by Vik Jaswal @ allthingsUC 

  • Grey Twitter Icon