Applet: IF your Fitbit Distance goal is achieved → THEN Send a notification
This Applet triggers when your Fitbit daily distance goal is achieved. If so, a notification will be sent through the IFTTT app. But what if you don't want to get the notifications on a weekend day? Or, what if it is a rainy weekend and you still achieve your goal? Congratulate yourself for achieving your goal even in unfavorable weather. Adding queries and filter code to this Applet will help you achieve this.
Here's how you can set up the Applet:
Trigger service: Fitbit
Trigger: Daily distance goal achieved
Query service: Weather Underground
Query: Two day forecast
Action service: Notifications
Action: Send a notification from the IFTTT app
Filter code:
// Filter code that demonstrates Meta.currentUserTime
// and logic to skip actions on weekends
// 0 is for Sunday and 6 is for Saturday
let currentDay = Meta.currentUserTime.day();
let currentCondition = Weather.twoDayForecast[0].Condition;
if (currentDay == 0 || currentDay == 6) {
IfNotifications.sendNotification.skip();
}
else if (currentCondition == "Rainy") {
IfNotifications.sendNotification.setMessage("Nice work achieving the goal on a rainy day");
}
Applet: Turn on my entryway lights based on outside brightness
To prevent turning on lights when it is light outside, we can make use of a query and filter code that will check for the brightness using the Tempest Weather System.
Trigger service: SmartThings
Trigger: Unlocked
Query service: Tempest Weather System
Query: History of observations
Action service: SmartThings
Action: Switch on
Filter code:
let aboveThreshold = 100;
let currentLum = Number(Weatherflow.historyOfObservations[0].Brightness);
let time_unlocked = moment(SmartthingsV2.unlockedSmartthings.UnlockedAt,'MMMM D, YYYY at h:mmA').format("HH:mm");
var msg = 'Door unlocked at ' + time_unlocked + ' and it is currently ' + currentLum + 'lum above the ' + aboveThreshold + 'lum threshold.';
if (currentLum > aboveThreshold){
SmartthingsV2.turnOnSmartthings.skip(msg)
}
Applet: IF you start traveling to your vacation home →THEN heat some water for your stay
When you have plans to spend your weekend at your home-away-from-home, you want the heater to be turned on before you arrive. This Applet, along with the Google Calendar query and the filter code, will check if you have an event with the keyword - “Weekend at the Dacha” when you arrive near your Dacha. If yes, the heater will be turned on.
Trigger service: Location
Trigger: You enter an area
Query service: Google Calendar
Query: Search events (set Query to “Weekend at the Dacha”)
Action service: WeMo Smart Plug
Action: Turn On
Filter code:
// locationDate will fetch the moment.js date object for the location trigger
// calendarDate will fetch the moment.js date object for the Google Calendar query
let locationDate = new Date(Location.enterRegionLocation.OccurredAt);
let calendarDate = new Date(GoogleCalendar.searchEvents[0].Start);
// The following if statement checks if the date and the month when you enter
// the location matches the date and the month are the same. If they are the same,
// then the action should run.
if (locationDate.getDate !== calendarDate.getDate && locationDate.getMonth !== calendarDate.getMonth) {
WemoSwitch.attributeSocketOnDiscrete.skip();
}
Applet: IF tomorrow's forecast is clear → THEN schedule a long run
This Applet checks tomorrow’s weather then adds a “Go for a run” event to your calendar depending on the forecast. If it’s going to be sunny, you’re signed up for the long run. Otherwise, make it quick. Either way, you get a notification the day before as a heads up.
Trigger service: Date and Time
Trigger: Every day at
Query service: Weather Underground
Query: Two day forecast
Action service: Google Calendar
Action: Quick add event
Action service: Notifications
Action: Send a rich notification from the IFTTT app
Filter code:
if (Weather.twoDayForecast[1].Condition == "Sunny") {
var length_of_run_in_minutes = "90"
var length_of_run_in_words = "long"
} else {
var length_of_run_in_minutes = "60"
var length_of_run_in_words = "short"
}
GoogleCalendar.quickAddEvent.setQuickAdd(`8am tomorrow Go for a run ${length_of_run_in_minutes} minutes`)
IfNotifications.sendRichNotification.setTitle(
`You're going for a ${length_of_run_in_words} run tomorrow`
)
IfNotifications.sendRichNotification.setMessage(
`It's going to be ${Weather.twoDayForecast[1].Condition.toLowerCase()} with a high of ${Weather.twoDayForecast[1].HighTempFahrenheit}° F`
)
IfNotifications.sendRichNotification.setLinkUrl(
Weather.twoDayForecast[1].ForecastUrl
)
IfNotifications.sendRichNotification.setImageUrl(
Weather.twoDayForecast[1].TodaysConditionImageUrl
)
Applet: IF there's a new post on Reddit → THEN post a Tweet with an image
This Applet posts a tweet with an image from a specified twitter account and skips tweeting if there's no image on the reddit post.
Trigger service: reddit
Trigger: New hot post in subreddit
Action service: Twitter
Action: Post a tweet with image
Filter code:
let redditImageURL = Reddit.newHotPostInSubreddit.ImageURL;
let noImageURL = `http://ifttt.com/images/no_image_card.png`;
if (redditImageURL == noImageURL) {
Twitter.postNewTweetWithImage.skip(`No image URL present`);
}