By Jason Snell
February 21, 2017 4:53 PM PT
Automate this: Holiday lights the hard way
This story starts, as most modern horror stories do, with a text message from Lex Friedman.
I want you to publish a tutorial on how I can use IFTTT applets and a calendar to tell my front lights to change colors depending on the date. So they’re green on St. Patrick’s Day, red on Valentine’s Day, etc.
Leaving aside the big question—what color would Presidents Day be?—my initial response was that this would be easy to accomplish. You’d think so, right? But it’s not. And the difficulty I had trying to figure out how to answer Lex’s question says a lot about just how primitive home-automation technology still is.
Sure, you can now tell Ensign Alexa that there’s a Romulan attack underway, but as Dan found out while working on that project, it’s difficult to wire up smart-home tasks that aren’t much more complex than cause and effect.
In the end, I figured out two possible solutions to Lex’s problem. Neither of them are ideal, and I’m hoping that some savvy Six Colors reader will offer an even more efficient solution. But the two approaches I took do work, with some caveats.
The “simple” approach: Multiple IFTTT applets
The easiest and cheapest approach here is for Lex to use multiple triggers on IFTTT. As I’ve complained about on more than one occasion, IFTTT is a useful but frustrating surface, because it’s incapable of anything but the simplest of cause-and-effect relationships.
That means in order for this system to work, Lex would need to create a whole bunch of separate IFTTT applets—one for every holiday he wants to monitor, as well as a handful more for regular operation.
If you’re like Lex (and me-), you like for your lights to turn on a while before dawn and turn off at sunrise, and turn on at sunset and stay on until some point late in the evening. To do all that via IFTT, you’ll need four separate applets. Two are time-based—at 6 a.m. turn on the front lights, and at 11 p.m. turn off the front lights. The other two use IFTTT’s Weather Underground source to trigger based on sunrise (turn them off) and sunset (turn them back on). For my approach below to work, make sure that these actions are setting the color of the bulb to your normal, non-holiday color.
But now we have to add holidays to the mix. First, Lex will need to create a Google Calendar for the holidays on which he wishes to bestow Geek Nation’s highest honor—the colored Wi-Fi light bulb. Since he’s got two separate periods where the lights are on, he’ll need to create twice as many events in the calendar. Since IFTTT is too stupid to trigger based on two separate factors—i.e., “if my Google Calendar says it’s Presidents Day, do this at 5 p.m.”—Lex will need to create events in both the morning and the evening of every holiday. (For holidays that repeat on a regular schedule, you can set those events to repeat annually and your work is done!)
Be sure to set these times so that they trigger after your regular daily applets, or the color change will be overridden. If your lights come on at 6 a.m., set these events for 6:15 or 6:30. If they come on at sunset, choose a time a little later than local sunset. (Yes, this means your triggers will be fighting each other out. It’s dumb, but the only other option I’ve thought of is to create an additional Google Calendar event on the morning of the next day after each holiday, setting the colors back. That seems even dumber to me.)
Next, create a series of IFTTT applets that are based on the Google Calendar trigger. Choose the trigger type “Event from search starts,” which fires off when an event with a specific keyword or phrase begins on a Google Calendar you specify, such as Presidents Day. Next, choose your light bulb of choice, and tell them to use a specific Presidents Day color. If you’re using Hue bulbs, use the “change color” action, which will also turn on your bulbs. You will need to do this for every single holiday you want to honor, with its own colors.
(If you’re using LIFX bulbs, you can change the color of the bulbs without turning them on. You could combine this approach with a daily command in the middle of the night that sets your bulbs back to the everyday color, then set the Google Calendar holiday events for slightly later in the early morning, and your regular turn-on/turn-off regimen would be undisturbed. Unfortunately, Hue’s “change color” IFTTT action also turns on the bulbs.)
Anyway, if Lex does all of this, it should work. I didn’t say it was easy or good, but…
The harder way: Zapier
I also built a version of this system using Zapier, a web app that lets you create fairly complex interactions between different web services. (If only Zapier attached to smart home stuff itself!)
I created a new app (which Zapier calls “Zaps”) to be triggered by a separate service, and set up a trigger on IFTTT to connect to the Zapier app’s URL every day right after the turn-on times for my lights.
The Zapier app, thus awakened, searches my holiday Google Calendar for the presence of a holiday on the current date. (This approach means my holiday calendar doesn’t need any times, just all-day events with the names of the holidays, preceded by “Holiday:”.) If it finds an event, it filters out the “Holiday:” part of the string, encodes the name of the holiday, and embeds it in a URL that leads back to IFTTT.
Then back on IFTTT, I create a series of applets, all triggered by IFTTT’s Maker channel, an all-purpose trigger that runs whenever anyone accesses a specific URL with a keyword you define. In this case, the keyword is the name of the holiday in question—and each applet is set to look for a specific holiday and turn on my lights with the appropriate color.
Since I have a paid Zapier account, I was able to add all of that text filtering, but this approach should work with a free Zapier account if you named the holidays in your Google Calendar things with URL-safe text that contained both a string that was consistent across all events and another that was unique to the holiday in question. For example, “holidaypresident” or “holidaystpatricks”. That string would be kicked back to the IFTTT Maker channel, and you could use that as the trigger to change the color of your bulbs, just as in the earlier approach.
Ugh ugh ugh
In short: This stuff can be done, but it’s way too complicated. A web service with a little bit of flexibility could handle this in short order:
- When it’s time to turn on the lights
- Check my calendar to see if it’s a holiday
- If it is, set a variable based on what holiday it is – “red” for Valentine’s Day, “green” for St. Patrick’s Day, and so on.
- If it isn’t, set the variable to white.
- Turn on my lights with their color set to the contents of the variable.
That’s not complicated logic, but it seems like it’s logic that’s beyond the tools we currently have access to for things like home automation.
Anyway, Lex, I hope this helps. Everyone drive over to Lex’s house on St. Patrick’s Day and see if the lights on his front porch are green.
If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.