As|you|probably know,we recently movedfromNJ to Austin,TX. In our new place,my office space is challenging as it's located next to a very strategic place...the kitchen!
So,yes,you will find me closer to the refrigerator. (I do maintain my running routine, so I should be fine.)However, the kitchen is a central place which means that I am more accessible for my family.
Usually, the following happens...
Yes, I did ask them (many times) to be more mindful/considerable and check if I'm on a call before approaching these super-important questions.
Then I asked my son the following:
Well, he is right. He didn't know that I was on a video call. So... How can I "better educate" my family to know when I'm on a call and prefernotto be disturbed?
My options:
Let's integrate Webex (status indication) with Philips Hue! That way, they will know (see! ?) my availability status!
As both Webex and Philips Hue expose their APIs, that shouldn't be complicated. Right?
To constantly tail the Mac OS "log stream" log (to track if the video is on/off), and at the same time, run the Webex API code portion, I created a multithreaded python script. One thread is dedicated to tail the "log stream", while the second thread is dedicated to the Webex API integration code.
Step#1 -Import the required python modules.
importrequestsfrom phue importBridgefrom threading importThreadfrom time importsleepimportsubprocess
Step#2 -Define Webex and Philips Hue variables.
#Webex variablesmyID ="xxx"url ="https://webexapis.com/v1/people/"+ myIDtoken ="xxx"?#pHue variablesbridgeIpAddress ='x.x.x.x'
Step#3-Define the Philips Hue connectivity function(Note: the first connection will require authentication using: "b.connect()").
def access_lights(bridgeIpAddress): b=Bridge(bridgeIpAddress)#b.connect()light_names =b.get_light_objects('name')returnlight_names
Step#4 -Define the five availability options/functions.
def active():lights=access_lights(bridgeIpAddress)forlightin['Office Lightstrip']:lights[light].on=Truelights[light].hue=25500 #Greenlights[light].saturation=254lights[light].brightness=254?def call(): lights=access_lights(bridgeIpAddress)for light in['Office Lightstrip']:lights[light].on=Truelights[light].hue=46920 #Bluelights[light].saturation=254lights[light].brightness=254?def meeting_without_video(): lights=access_lights(bridgeIpAddress)for light in['Office Lightstrip']:lights[light].on=Truelights[light].hue=7000 #Orangelights[light].saturation=254lights[light].brightness=254?def meeting_with_video(): lights=access_lights(bridgeIpAddress)for light in['Office Lightstrip']:lights[light].on=Truelights[light].hue=65535 #Redlights[light].saturation=254 lights[light].brightness = 254?def DoNotDisturb(): lights = access_lights(bridgeIpAddress)for light in['Office Lightstrip']: lights[light].on = True lights[light].hue = 12750 #Yellow lights[light].saturation = 254 lights[light].brightness = 254
Step#5 -Define the function to check if the is video is on/off.
def func1(): f =open("output.txt", "w") subprocess.call(['/usr/bin/log', 'stream','--info', '--debug', '--predicate','(process == "VDCAssistant") and (eventMessage contains "Post event kCameraStream")'], stdout=f)return f
Step#6 -Check the Webex status indication AND the video status to determine the Philips Hue light color.
def func2(): while True: sleep(5) headers = {'Authorization':'Bearer '+ token } response = requests.request("GET", url, headers=headers) r_json = response.json() myStatus = r_json["status"]with open("output.txt", "r") asfile: result= (list(file)[-1])if "kCameraStreamStart" inresultandmyStatus =="meeting":#print("Meeting is ON and Video is ON") meeting_with_video()elif "kCameraStreamStart" not inresultandmyStatus =="meeting":#print("Meeting is ON and Video is OFF") meeting_without_video()elif "kCameraStreamStart" inresultandmyStatus =="active":#print("Available") active()elif "kCameraStreamStart" not inresultandmyStatus =="active":#print("Available") active()elif "kCameraStreamStart" inresultandmyStatus =="call":#print("On a Call") call()elif "kCameraStreamStart" not inresultandmyStatus =="call":#print("On a Call") call()elif "kCameraStreamStart" inresultandmyStatus =="DoNotDisturb":#print("DoNotDisturb") DoNotDisturb()elif "kCameraStreamStart" not in result andmyStatus =="DoNotDisturb":#print("DoNotDisturb") DoNotDisturb() ?if__name__ =='__main__': Thread(target = func1).start() Thread(target = func2).start()
We'd love to hear what you think. Ask a question or leave a comment below.
And stay connected with Cisco DevNet on social!
Twitter @CiscoDevNet | Facebook | LinkedIn
Visit the new Developer Video Channel