IFTTT lets you create applets that let you control things like web services with custom triggers (eg. Create a To Do Item if you receive an email). I’ve been using it to control the lighting in my house based on triggers I’ve put on my Touch Bar.

This guide goes through setting up IFTTT with my Xiaomi Yee Lights and then adding triggers for them on my MacBook’s Touch Bar.

IFTTT Setup

Before you start this step, you’ll want to make sure you’ve got what you want to trigger already configured. In my case, it’s my Yee Lights that I’ve configured via the Yeelight app. I set mine up in Scenes.

In my examples, I’m using a scene I created called Chillflow (dim lighting that slowly flows through pastel green/blues).

You’ll also need an IFTTT account setup.

First, create a new Applet on IFTTT. For the service select Webhooks.

For the trigger, pick “Receive a web request”

Now give it a trigger name.

For the second part, pick what service you want to use, I’m using the Yeelight service.

Pick your action, I’m using “Set Scene” then “chillflow”

Next up, go to the webhooks settings here: https://ifttt.com/services/maker_webhooks/settings

(You can also get there by clicking on the webhooks icon in the top right of the applet, then clicking on settings)

Copy down the URL they give you, you’ll need the last bit which is your Key.

Now you can test it out in the Terminal by pasting the following line (replace {event} with the trigger name (in my case: “timeToChill”) and the {yourKey} part with the key from the step above):

curl -X POST https://maker.ifttt.com/trigger/{event}/with/key/{yourKey}

eg. Here’s mine:

curl -X POST https://maker.ifttt.com/trigger/timeToChill/with/key/asdadasdasdasd213980

All work? Great! Now to make the buttons appear on your touch bar.

Touch Bar Setup

With BTT installed, go to the Touch Bar section and add a Touch Bar Button.

Give it a name and then go to Predefined Action -> Controlling Other Applications -> Run Apple Script in Background.

In the box, enter the following text (don’t forget to replace {event} and {yourKey} as you did above.

return do shell script "curl -X POST https://maker.ifttt.com/trigger/{event}/with/key/{yourKey}"

Hit save and push that button!

My Setup

On my Touch Bar I set up a Group for all my lights, so I tap the Light button, then pick a light setting (picking a setting will close the group too using the “Add Additional Action” thing in BTT).