When creating an Applet, you can add queries to your Applets to add more context, and a filter 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 a filter to skip the Applet's action while the Sun is still up.
Let's create an example Applet where we want to send an SMS message using the Android SMS service after we arrive home, but only when it's after sunset.
Start with the Location - You enter an area trigger, add the Weather Underground - Current weather query, and the Android SMS - Send an SMS action.
Now add the following filter:
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) {
AndroidMessages.sendAMessage.skip()
}This code takes the sunrise and sunset times from the Weather Underground query, plus the user's current time, and skips the SMS 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, AndroidMessages.sendAMessage.skip(), with the relevant skip code for your action(s).
You can find the skip code for your Applet's actions to the right of the filter editor under Actions; the skip code will end in .skip():