Philips Hue: Change Hue State if Zoom, Teams or WebEx is Active

This script for MacOS will detect if a Zoom, Teams, or WebEx call is active and if so, turn on a Philips Hue plug, and turn it off when there is no active call. API calls to Hue devices require a Hue Hub.

It can be easily adapted to turn on Hue bulbs or take any other actions. I recommend using launchd to run the script automatically every 60 seconds.
#!/bin/bash

#Script v0.5.1
#Note this uses the Hue v2 API
#Requires Hue v2 hub and up to date firmware

#In this case Im using a hue plug with an "on air" sign, but you can add color, brightness, etc to the API call if you are using a Hue color bulb

##### PRESET SOME STUFF N JUNK #####
hueIp='192.168.1.xxx' # Hue Hub IP
hueApiKey='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' # Hue API Key
v2Id='xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # Hue Plug ID

##### GET ZOOM & TEAMS STATE #####
zoomState=`ps -ax | grep zoom`
teamsState=`ps -ax | grep microsoft.teams`
webexState=`ps -ax | grep webex`

##### IF ZOOM, TEAMS, WEBEX ACTIVE TURN ON, ELSE TURN OFF #####
if [[ "$zoomState" == *"CptHost"* ]] || [[ "$teamsState" == *"com.microsoft.teams"* ]] || [[ "$webexState" == *"webexmta.app"* ]]; then
echo ""; echo "Zoom, MS Teams, or WebEx active, turning ON light"; echo ""

##### ON AIR SIGN, ON #####
huePut=`curl --insecure -X 
PUT "https://$hueIp/clip/v2/resource/light/$v2Id" 
-H "hue-application-key: $hueApiKey" 
-H 'Content-Type: application/json' 
--data-raw 
'{
"on":
{"on":true}
}
'`

else
echo ""; echo "Zoom, MS Teams, or WebEx NOT active, turning OFF light"; echo ""

##### ON AIR SIGN, OFF #####
huePut=`curl --insecure -X 
PUT "https://$hueIp/clip/v2/resource/light/$v2Id" 
-H "hue-application-key: $hueApiKey" 
-H 'Content-Type: application/json' 
--data-raw 
'{
"on":
{"on":false}
}
'`
fi

4/5 : 1 Vote