Please, Please, Please Do Not Disturb!

It’s 2020. You know, the year with the fires, pandemic, murder hornets, and more fires. There’s a pandemic forcing millions of employees to work from home. I’m fortunate to have a dedicated home office to work out of and various family members are always dropping by to say hi. I love being able to see my family so often! Except when I’m on a work call. And until recently, my family’s way of determining if I was on a call was to barge into my office yelling, “Are you on a call?”. And I would have to gesture off-camera to my headset while maintaining a completely neutral face or fumble for the mute button to answer them that, yes, I am on a call. You’d think the closed door and large Jabra 75 headset covering my ears would be clue enough but, alas, my family requires something a little less subtle. Something along the lines of a flashing, bright red “on-air” sign used by TV studios.

Of course, there’s no way my wife would let me install one of those so it was on to Plan B. I decided to have one of the existing recessed lighting “cans” right outside my office turn red when I’m on a call. This would look like regular light most of the time and blend in with the rest of the house lighting. But when Iz is conducting the biz, the light would become unmistakably red.

Picking the Bulb

My first task was to find a bulb that could turn red. My recessed lighting uses pretty standard Commercial Electric  4” retrofit LEDs (these are the flat bulbs that plug into an adapter that screws into a standard light socket). They have a clean and flat look and are available at most big box hardware stores. I first considered getting a Zigbee RGBW bulb but had 2 issues. First, the only Zigbee bulb I could find to match my existing bulbs was a $60 Philips Hue bulb. No thanks! Also, the entire bank of lights this would be attached to was controlled by a smart switch. I did not want to have a Zigbee bulb constantly falling off my mesh whenever the switch was toggled. Instead, I decided to go with a wifi bulb. “But you said wifi is for chumps!” you ask. To which I say: every device type has its place and scenario in which it works best. In this case, wifi suited my needs. I ended up going with Tuya wifi bulb (that I could in theory flash to a different firmware for true local control someday). I installed the Tuya app on my phone and was able to change my new bulb to any color I wanted… manually.

Connecting to Home Assistant

As I’ve previously mentioned, I’m currently running Home Assistant and Node-RED for my automations so I figured I’d use it for changing my bulb color automatically. Adding the Tuya integration to Home Assistant was a breeze and I was then able to see the bulb in my HA dashboards. However, for some reason, I was only able to change the brightness and warmth of the bulb from HA, not the color! I couldn’t possibly tell my family, “2700 Kelvin is fine but don’t interrupt me when that light is 5000k”. Google to the rescue! After combing through a number of websites and the HA community forums, I discovered that I’d need to add a “Customization” to my light entity and manually change its “supported_features” attribute to 191. Once this was set, a beautiful color picker popped up when I clicked the bulb. 

Customization screen in Home Assistant Settings

The Automation

So now I could programmatically change my bulb color so I moved on to the next problem: how can I have my system detect when I was on a call? I ended up attacking this problem from two sides. First, I remembered a cool feature that my Jabra 75 headset supports. It can pair to both my computer and my phone at the same time. The Home Assistant Android app can expose all types of cool information to HA, including the state of connected bluetooth devices. So when I turned my headset on, even when I was using it with my computer-based video conference software, it would still connect to my phone. This caused the “bluetooth_connected” state to change in Home Assistant and, using a series of Node-RED function nodes, I was able to determine if my headset was actively connected to my phone or not. If the headset was connected, turn the bulb red, if it was not connected, turn it white. This turned out to work quite well as long as I was using my Jabra headset. I'll post the Node-Red flow below.

The other approach came from one of my co-workers. He pointed out that when our corporate telephony software (called BlueJeans for some reason) was running, it made a UDP connection to its server. When it was on a call, it made 3 connections. Armed with this information, I wrote a simple script to check the number of BlueJeans UDP connections every 30 seconds. When a change was detected, it would call out to a Webhook hosted in IFTTT. 

Script to detect UDP connections and fire IFTTT Webhook

We've talked about IFTTT before but to recap, IFTTT is a service that allows simple automations to run when a certain trigger is fired. In this case, I was using my script as the trigger and IFTTT would then make a call to my Home Assistants IFTTT integration to fire my automation. 

Generic IFTTT Automation Handler

I actually used an HA input_boolean toggle as a proxy for my red notification bulb so all my IFTTT automation had to do was turn the input_boolean on or off. From there, a Node-RED sequence detected that change and then changed the bulb color appropriately. One side note about IFTTT: they recently announced a paid version of their service and have limited their free tier to only 3 automations. I used one for turning the bulb red and another for turning it back to white. Finally, I made sure the sequence checked if I was home so that I wasn’t turning the bulb red if I was making a call from the office (assuming I go back some day).

Node-RED flow for both Bluetooth connection and Webhook

Light turning red

Well, there you have it! I now have an unobtrusive, wife-accepted method of telling everyone when I don’t want to be disturbed. Next up, a “please bring me a sandwich” light!

Popular posts from this blog

A Beginner's Guide to Presence Detection

A Beginner's Guide to Smart Switches