Applet: IF you complete a new activity on Strava → THEN Send a notification
This Applet triggers whenever you complete a new activity on Strava. If so, a notification will be sent through the IFTTT app. But what if you don't want notifications on a weekend day? Or, what if it was rainy out and you still got your workout in? Congratulate yourself for training in unfavorable weather. Adding queries and filter code to this Applet will help you do that
Here's how you can set up the Applet:
Trigger service: Strava
Trigger: New activity by you
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 getting your workout in 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 cabin, you want the heater turned on before you arrive. This Applet, along with the Google Calendar Query and the filter code, will check whether you have an event with the keyword "Weekend at the Cabin" when you arrive near your cabin. If it does, the heater will turn on
Trigger service: Location
Trigger: You enter an area
Query service: Google Calendar
Query: Search events (set Query to “Weekend at the Cabin”)
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 X (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 = `https://ifttt.com/images/no_image_card.png`;
if (redditImageURL == noImageURL) {
Twitter.postNewTweetWithImage.skip(`No image URL present`);
}