Saturday, 26 October 2019

How to Use IFTTT Applets With Advanced Filters to Superpower Your Tasks

ifttt-filters-tasks

IFTTT is a great way to automate your everyday processes on your computer, your phone, and your smart home. But its basic functionality is somewhat limited. There is a way to create more advanced IFTTT applets that only run under certain conditions.

We’ll show you how, using an option called Filters in the IFTTT developer platform.

What Are IFTTT Filters?

You may know If This, Then That as a favorite service among techy and organized people. It lets you link up different services to one account. You can then trigger actions for one account based on the inputs of another.

For example, you can use IFTTT on your Android phone to send yourself an email whenever you receive an SMS. Or you can automatically log your phone calls in your calendar. You can link up services like Twitter, Facebook, Sonos, RSS feeds, weather information, Pushbullet, and many more.

The basic version of IFTTT which most people use is simple. It has a trigger—an “if this” statement—followed by an action—a “then that” statement.

But sometimes you want a more flexible solution. You might want the “then that” action to only be triggered in certain situations. If this is the case, then you can use an advanced feature of IFTTT called Filters.

How to Set Up IFTTT Filters

Using the IFTTT Platform for Applets With Advanced Filters

To start using filters, you need to head to the IFTTT Platform site. This is the site for developers who want to use IFTTT. However, even if you’re just a regular user you can still use the functions here.

To get started, click on Dashboard on the top right.

This will take you to your Private Applets section, where you can see any advanced applets that you have already created.

To set up a new applet using filters, click New Applet in the top right. This takes you to the Create a new Applet page.

Creating a New Applet for Adding IFTTT Filters

Create a new IFTTT applet

We’ll walk you through the steps to create an applet with filters with an example. Let’s say you have an Android phone and you want an applet to run whenever you get home.

Step 1: Choose Your Trigger

  1. Click on the Search services box and find Android Device.
  2. Select the specific trigger from the Please select drop-down menu.
  3. Choose Connects to a specific Wi-Fi network.
  4. Now, look at the Field label section enter the name of our home’s Wi-Fi network in the Value field.

Step 2: Choose an Action Before You Apply the Filters

In this example, we’re going to have our Sonos speaker play music when we arrive home.

  1. Click on Add action.
  2. Go to the Search services box and select Sonos.
  3. From the Please select drop-down, choose Play Favorite. We’re going to select which favorite to play later. So for now, leave the options for What favorite do you want to play? and Where do you want to play? set to Customizable by the user.
  4. Go ahead and add any filters into the Add filter code section. See below for more information on how to use filters.
  5. Once everything is done, just add an Applet title and Applet description at the bottom, then select Save.
  6. You’ll see an Applet Created banner once everything is done.

Step 3: Start Using the New Applet

  1. Go to the Dashboard and then to your Private Applets. You’ll see your new applet saved here.
  2. Click on it to bring up the options in a new window.
  3. Click Connect to start using the applet and enter your values such as which Sonos favorite you want to hear when you get home and in which location the music should play.
  4. Hit Save and your new applet is ready to use.

How to Use IFTTT Filters

Using IFTTT Applets With Advanced Filters and an example of a finished applet

Now you know where to add IFTTT filters. Let’s start looking at the filter code.

Filters use JavaScript which run when the applet is triggered. The JavaScript can access data about the trigger as well as metadata like the current time. That means that you can use filters in different ways depending on the trigger you select.

We’ll look at two different examples of filter code.

1. IFTTT Filter to Run an Applet Only During the Day

How to Use IFTTT Applets With Advanced Filters - filter code

In the example above, the applet plays music through the Sonos system whenever you get home and your device connects to your home Wi-Fi.

But, maybe, you want to limit this applet so it only runs during the day. If you arrive home late at night, you don’t want to turn on any music and disturb our neighbors.

To limit the hours in which the applet will run, we can use the following filter code:

var currentHour = Meta.currentUserTime.hour()
if (currentHour >= 8 || currentHour < 22 ) {
} else {
  Sonos.playFavorite.skip()
}

Here’s an explanation of what this code means:

The first line tells the system to check what the current time is in the user’s time zone. The second line says that if the current time is after 8am and before 10pm, the applet should run. The third and fourth lines say that if the time is before 8am and after 10pm, the applet should skip the action and not play the favorites.

2. IFTTT Filter to Change Lights to a Random Color

In the IFTTT filter documentation, there’s also an example of how to introduce a random element to actions. For example, the following code will send change your Lifx lights to a random color from a list of options you provide.

var colors = ["#FF8400", "#FF0000", "#15FF00", "#FF00D4","#00D4FF","#003CFF"]
var index = Math.floor((Math.random() * colors.length))
Lifx.color.setAdvancedOptions('color: ' + colors[index] + '; brightness: 1; duration: 12')

Here, the first line lists the different colors you want to include in the random rotation. The second line selects a random value from that list. The third line sets your Lifx lights to that color.

Limitations of IFTTT Filters

There are some limitations of IFTTT applets with filters that you should be aware of.

First, anyone can create an applet using filters. However, you can only publish applets with filters if you have a paid IFTTT account. If you don’t want to pay, you can still use filtered applets on your own account. You just won’t be able to publish them and share them with others.

Second, if you want to add more complex filters then this is possible, but you’ll need to know JavaScript. If you don’t know that language yet, there are several online Udemy courses to learn JavaScript we have recommended on our site.

Use Filters to Create Clever IFTTT Applets

Using the filters in the IFTTT Platform section, anyone can create complex applets to perform more sophisticated functions. We love IFTTT, but if you’re looking for a similar service with different options then you might be interested in these IFTTT alternatives you haven’t heard about.

Read the full article: How to Use IFTTT Applets With Advanced Filters to Superpower Your Tasks



from MakeUseOf https://ift.tt/31JWFZN
via IFTTT

No comments:

Post a Comment