I wanted a light to turn on only after sunset, and before sunrise, so here’s how I set that up.
Step 1, Create a New Applet
Step 2, Add your trigger
For me this was our MyQ integration with our garage door, but this should work with any standard IFTTT trigger
Step 3, Add a query
I selected Weather Underground, and then Current Weather, which has outputs for sunset and sunrise times for whatever location you give it.
Step 4, Add your action
I wanted to turn on a light plugged into a Wyze outlet, but again, any IFTTT action should work fine here
Step 5, Add your filter
On line one, we instantiate a new date object with the current date time. You might be able to use the meta data from the action but I found this harder to parse, and it should only differ by a few seconds if your code is running as quickly as IFTTT says it should.
Line two we parse the sunrise time from WU into another date object, and the same with the sunset on line three.
Then we just logically test if the current time is greater than sunrise, and less than sunset. That means it’s daylight out there, so on line 6, we skip our action.
Just save your applet, and it should now only trigger after dark.
You can see if things are working as expected by opening your applet settings and clicking “View Activity.” IFTTT will report the applet was skipped, and note that it was due to your trigger
Applets are hard to edit after the fact currently, but filters can be edited easily from the settings screen. One way to test if your filter is working, is to set the Date object to a time that we know is after dark, just add
between lines 1 and 2 (or whatever number would make sense if say you’re in Alaska at the height of summer 😉 ) this will override the current date time to whatever hour of the day you set, letting you know if your logic works as expected.