Mini-project: “On Air” During Zoom Calls

My Setup

Detecting if Video is Turned On/Off

% log show — last 2m — predicate ‘(sender == “VDCAssistant”)’ | grep kCameraStream2021–10–07 10:40:54.892531–0400 0xe7dcf2 Default 0x0 48943 0 VDCAssistant: [com.apple.VDCAssistant:device] [guid:0x1130000046d0892] Post event kCameraStreamStart2021–10–07 10:40:54.892540–0400 0xe7dcf2 Default 0x0 48943 0 VDCAssistant: [com.apple.VDCAssistant:device] [guid:0x1130000046d0892] Init -> Streaming on event kCameraStreamStart2021–10–07 10:40:57.851867–0400 0xe7dcf2 Default 0x1f8015d 48943 0 VDCAssistant: [com.apple.VDCAssistant:device] [guid:0x1130000046d0892] Post event kCameraStreamStop2021–10–07 10:40:57.851874–0400 0xe7dcf2 Default 0x1f8015d 48943 0 VDCAssistant: [com.apple.VDCAssistant:device] [guid:0x1130000046d0892] Streaming -> Init on event kCameraStreamStop

Controlling Lights From a Script

 % pip install phue
% python>>> from phue import Bridge
>>> b = Bridge(‘10.0.0.2’)
>>> b.connect()
# Turn on
b.set_light('OnAir', 'on', True)
# Turn off
b.set_light('OnAir', 'on', False)

Putting it Together

#/bin/zshwhile true
do
log show --last 5m --predicate '(sender == "VDCAssistant")' | grep kCameraStream > camera.log
python on-air.py
sleep 5
done
import subprocess
from phue import Bridge
import time
# Find your IP from your Hue app
BRIDGE_IP = '10.0.0.2'
# Light is named using the Hue app ahead of time
LIGHT_NAME = 'OnAir'
# Log file dumped from the shell script
LOG = "./camera.log"
# isCameraOn returns True if we think the camera is currently
# on, False if not. We're trying to find if the last line was
# kCameraStreamStart (True) or kCameraStreamStop (False); no match
# is False.
def isCameraOn():
camera_is_on = False
with open(LOG, "r") as a_file:
for line in a_file:
if 'kCameraStreamStart' in line:
camera_is_on = True
elif 'kCameraStreamStop' in line:
camera_is_on = False
return camera_is_on
def setLight(bridge, is_on):
bridge.set_light(LIGHT_NAME, 'on', is_on)
# Note that the first time you run this, you'll
# need to first press the button on the hue bridge
# before running this application
b = Bridge(BRIDGE_IP)
b.connect()
camera_on = isCameraOn()
setLight(b, camera_on)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store