WFH DIY Meeting Light Bulb

Honey, are you on the phone?

When working from home, interruptions are a given. Sometimes its fine and other times I’m in a customer meeting and need privacy, but my family never knows which. My schedule changes during the day as meetings get created or cancelled and having my headphones on doesn’t necessarily mean I’m in a meeting.

To prevent the pop your head into my office and mime “are you on the phone?” routine, I decided to put a signal outside my workspace and synchronize it with my O365 work calendar. A simple lamp – if the light is on, I’m in a scheduled meeting. When the meeting finishes I want the lamp to turn off.

I wanted to trigger this with little to no code (something like Azure Logic Apps or Power Automate). That means I need a bulb that can be controlled remotely from the cloud. After a short search I found the LIFX Mini White Wi-Fi Smart LED Light Bulb. It connects to your home wifi and LIFX provides an API to control it.

Keep in mind there are lots of home automation solutions – this is just the one I chose.

The Solution

LIFX provides an API which I could call directly using an Azure function, but I wanted to do this with as little code as possible. Azure Logic Apps has integration to my O365 calendar, but doesn’t have any default connectors to LIFX. IFTTT supports LIFX connectors but only supports “when an O365 event is about to start” which helps me turn on the bulb, but not turn it off when the meeting finishes.

The end solution is a combination of all three

I worked backwards from the light bulb so I could test each stage.

IFTTT

I created two applets. One to turn the light on and one to turn it off. For the trigger, I used a webhook and named the event “turn_off_lights.” For the action I used the LIFX action and configured it to “Turn lights off”. Then I set which bulb to turn off and set it to a 2 second fade.

ifttlightsoff

Then I created another similar applet except for “lights on”.

Now I have two separate webhooks I can invoke that will turn my light on or off on demand. I can test it by hitting webhook which looks something like this

https://maker.ifttt.com/trigger/<YOUREVENT>/with/key/<YOURKEYHERE>

You can get your exact URL and key from https://ifttt.com/maker_webhooks and clicking on Documentation.

Now to scheduling it.

Azure Logic Apps

Logic apps provides a trigger for “event starting soon” but that only helps with the “turn on” aspect. I also need to know when the meeting ends so I can turn off the bulb. Also, if there is another meeting starting immediately, I don’t want to turn it off. This means I’ll just have to poll my calendar and turn the light on/off if there is a current meeting or not.

Fortunately the Recurrence Trigger is extremely flexible. I set mine up like this

recurrencescheduler

This way it will run Mon-Fri on the hours of 6am-10pm central time and only trigger every 15 minutes plus the minute before and after. My meetings usually start on 15 minute intervals, so the trigger will run just before and after the start and end of every possible meeting.

Next I need to check for the status of the calendar events. I need to query for any “show as busy” meetings at the scheduled times. Use the Get Calendar View of Events for this

getcalendarviewofevents

Whenever invoked, get the events for only now and filer them based on the showAs property.

Next I need to just call either the lights on webhook or the lights off webhook based on whether we got any results from the calendar query

isbusycondition

The condition is whether the expression

length(body(‘Get_calendar_view_of_events_(V3)’)?[‘value’])

is greater than 0. If it is, that means we found a busy calendar event happening right now and we turn the light on. If not, we turn the light off. The two HTTP activities simply POST to my webhooks I created earlier.

In the end the workflow looks like this

workflow

Final words

Now that this is all set up, I have a lamp which turns on and off based on my meetings in my outlook calendar. We’ll see if its actually useful this week or if it needs some tweaks.

In my github there is a simple click to deploy ARM deployment template for the logic app if you want to try it out and/or point it to different light bulb solution.

FYI – I’m exploring synchronizing it to my Teams presence since that switches to “busy” automatically when I join a call, but the Teams API for getting your presence is currently in beta and so may require permissions I don’t have in my org.

[UPDATE]

It seems the IFTTT webhooks have not been reliable in their timing. While working fine during initial testing, some are responding hours after getting invoked. So I have updated the Azure Logic App to call the LIFX API directly and removed IFTTT as a middleman. I should have done that in the first place but hadn’t looked at the LIFX API yet. The github repo deploy reflects the new change.

About Negative Eddy

Professional Geek - I work for Microsoft
This entry was posted in automation, Azure, Tinkering. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s