By Jason Snell
November 25, 2015 4:00 PM PT
How many scripts does it take to color a light bulb?
Note: This story has not been updated for several years.
The past few days I’ve spent some time fiddling with IFTTT, the service that lets you connect different actions, devices, or web services that don’t need to know about one another to interoperate.
Lately I’ve resumed my quest—abandoned a few months ago—to set up the lights in the front of my house to come on at sunset and go off about the time that I go to bed. All of the smart and dumb light switches I bought failed me, probably because my house’s wiring just isn’t up to this challenge.
Instead, this week I put two LIFX smart light bulbs into the two outside light sockets and hooked them up to IFTTT via a recipe that triggers based on IFTTT’s Weather channel, which can perform an action based on local sunrise or sunset data. A second recipe slowly fades the lights off at a time of my choosing.1
It worked pretty well, so I began considering how I might press my WeMo switch into service as well, which led me to discover the very clever IFTTT Maker channel.
The Maker channel is basically an interface for any device or script that can ping a URL. I decided to experiment with whether I could have my weather station turn my outside lights blue if the temperature got near freezing.
Sure enough, the weather station software I use, Trixology’s WeatherCat, has an Alerts feature that will send an email or launch an application based on specific conditions. I just needed to write an application that will ping the URL of my IFTTT Maker channel.
Easy enough. It’s a single line:
do shell script "curl -X POST https://maker.ifttt.com/trigger/nearfreezing/with/key/abc123"
My trigger for this particular event is named
nearfreezing and the custom key IFTTT has assigned to my Maker channel replaces
abc123 in this case.
curl is the command-line command to ping a web URL, and it’s all wrapped in a
do shell script statement because that’s how AppleScript rolls.
I saved that script as an Application, told WeatherCat to trigger it when the temperature conditions were met, and just like that, my Mac weather station is controlling my Wi-Fi-enabled light bulbs. What a funny world.
- Yes, LIFX has a built-in scheduling function, but I wanted to see if I could trigger this schedule via IFTTT instead. ↩
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.