With IFTTT Pro+ you can add queries to your Applets to add more context, and filter code to ensure your actions only run when certain conditions are met.
In this case, we'll query the sunset and sunrise times in your location, then use filter code to skip the Applet's action while the Sun is still up.
Let's create an example Applet where we want to be notified when the ISS passes over our location, but only when it's after sunset so we can get a chance to see it.
Start with the Space - ISS passes over a specific location trigger, add the Weather Underground - Current weather query, and the Notifications - Send a notification from the IFTTT app action.
Now add the following filter code:
let sunrise = moment(Weather.currentWeather[0].SunriseAt);
let sunset = moment(Weather.currentWeather[0].SunsetAt);
let currentTime = Meta.currentUserTime;
let afterSunrise = currentTime.isAfter(sunrise);
let beforeSunset = currentTime.isBefore(sunset);
if (afterSunrise && beforeSunset) {
IfNotifications.sendNotification.skip(`ISS appears overhead for ${Space.spaceStationOverheadSoonNasa.DurationSeconds} seconds, but you won't see it while the sun is up`)
}
This code takes the sunrise and sunset times from the Weather Underground query, plus the user's current time, and skips the Notifications action if the current time is between sunrise and sunset (when the Sun is up).
Note that if you are using this code in an Applet with different actions, you'll need to replace the second last line with the relevant skip code for your action(s).
You can find the skip code for your Applet's actions below the filter code editor under Actions; the skip code will end in .skip()
: