IFTTT / BTT Controlling Smart Lights/Garage Door from Touch Bar using IFTTT

Its very easy to add a button on your Touch Bar to control (Toggle) your "smart" lights, or anything IFTTT can control. Im not going through all the setup unless people are interested, but here's a quick synopsis.

  1. Create your IFTTT "applet" using a Webhook control.
  2. Take note of your Webhook key {your key} in your IFTTT account, and the name you gave your applet {event}.
  3. Create your BetterTouchBar Button with the following AppleScript.

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

My Script Looks like this:

return do shell script "curl -X POST https://maker.ifttt.com/trigger/**SunRoomLight**/with/key/**c4j433LR4l6KfXdbfg1SSp**"


UPDATE:
Made a few changes (adding a notification popup when light is turned on/off) and added Smart Garage door opener to Touch Bar.

NOTE: I have 100% success with this, but would like to work a way to check the status of the light (On or Off). Right now this will toggle your light, but if its remote (can't see the light) it would be nice to poll the status of the light to know if its on or off. Completely unnecessary, but would be nice.

A full writeup can be found here: https://www.imore.com/how-use-ifttt-touch-bar-macbook-pro

Enjoy my work?
paypal.me/K2DesignLab

I haven't had the time to look at your write up, but since already using webhooks the setup literally took only 3 minutes. Great idea! I don't wanna flood my limited touchbar real estate with all my switches and outlets, but it is handy for my bedroom lights. You've inspired me to bring all my switches and sensors into a webview HTML overlay though using the webhook method. Thank you for sharing.

I create a separate group for "smart" devices. I have others I may add in the future, for now a single button on my "tools" bar opens the full group of lights. (House Icon on far left)

Enjoy my work?
paypal.me/K2DesignLab

Do you mind @K2DesignLab if you could share your preset? Looks awesome to me!

1 Like

I haven't created this as a preset to share. The idea came from another preset Aqua, found here (4 main menus - on the right). I currently have many code entries that are specific to my setup. I can show you all the tools I have created and will work on a preset that I am able to share publicly soon enough.

Main/Blank

Finder Tools:

Finder Sub Menus:


Weather:

Tool Menu Main:

Tool Sub Menu Extras:

Tools Sub Menu Volume:

Tool Sub Menu Smart Home:

Calendar, Sports schedules and Events

Applications and Network/IP tools

Looks great! Would live to tryout this preset as soon it's ready!

Made a few changes (adding a notification popup when light is turned on/off) and added Smart Garage door opener to Touch Bar.

Made a few more changes to my Preset. Adding Smart Home Group/Menu to my Main Menu selections. Saving room on my other control group and allowing for more devices in the future. Still needs some tweaking... but now shows the light relay status for each TP-Link smart plug/device (Red-Green).

Hi, I was hoping you could help with how you got the light status? Id like to do something similar with my Hue lights. I am doing this through Huekey because IFTTT is a little slow, but id assume the idea is similar.

Light status is not done using IFTTT. Status is pulled directly from OEM TP-LINK server. Basically, I've built a preset that does what the TP-LINK app does. I have to generate a Token (That changes once in awhile) and code using a shell script. Its not a great solution and will be removing the status...

curl -s --request POST "https://wap.tplinkcloud.com/?token=-A1WSkyiVmd HTTP/1.1"
--data '{"method":"passthrough", "params": {"deviceId": "802F1A9095E8", "requestData": "{"system":{"get_sysinfo":null},"emeter":{"get_realtime":null}}" }}'
--header "Content-Type: application/json" | grep -q '..relay_state..:1' && echo "ON" || echo "OFF"

right, but how is the image dynamically changing based on the status? Id assume you are changing the icon based upon the response?

Oh, I just change color based on return value (ON or OFF).

Sorry, I should have been more clear. How do you get BTT to change the color based on the return value? I cant find any documentation that details that

Alternate Color Regex: