Sunrise and Sunset in Tasker

Written by Anthony Pavia on Apr 9, 2020 11:32 am

Sometimes you may want something to occur at a specific time of day or sometimes you may want something to occur with certain events during the day.  The “events” in this case are the Sunrise and Sunset events.  These events occur at different times during the day based on the time of year and your geographic location.  Tasker grabs the location from the JNIOR registry, and uses it to calculate the time of sunrise and sunset for that day.

We had written a custom application called the SunEquation Application to accomplish the following before implementing the logic in Tasker.  You may ask, “What is the SunEquation application and can Tasker handle the same logic?”  The SunEquation Application simply calculates the time of Sunrise and Sunset only, and yes Tasker can do what the SunEquation Application does. The difference between the two is that Tasker is a heavyweight application that uses more processing power than a simple custom application like SunEquation that was designed to do one thing.  The SunEquation application was written for someone that was already running two other applications and the addition of Tasker might slow those other applications down.  Specifically the DMX application is sensitive to performance and that application is one of the two applications that were in use.

Below is an example to activate Loggers in Tasker at sunrise or sunset that will record the time the Loggers activated. This requires having the support tool downloaded along with the Tasker Application  There are several steps that will need to be configured to get this to work.

  1. Create a Logger in Tasker that will record the time it activates
  2. Create a Task that will perform the action of activating the Logger.
  3. Create Schedules that will execute the Tasks based on Sunrise and Sunset.

Create the Logger

The first thing we’ll want to do is create a Logger that will record the time its executed at. We’ll open the Tasker Web Page and go to the Logger Tab. Here we will create a Logger called SunriseSunset. Then we will append to the File Name field of the Logger so it has /flash/tasker/logging/sunrisesunset.log. By default, the Timestamp Format field will have a format that will be used, so the Logger should be complete.

Create the Task

The next thing needed is a Task that will activate the Logger. Go to the Task Tab and create a Task called Call_Sunrise_Sunset. Here we’ll add the call Log Profile action and enter the Logger’ name SunriseSunset. Now when the task is called, the Logger will activate.

Create a Schedule

To trigger the logger to run at sunrise and sunset, you’ll now want to go to the schedule tab of the Tasker application. You’ll then add two schedules, and name one them “Sunrise” and the other “Sunset”. For the “Sunrise” Schedule, you’ll want to enter the Task we created for it in the Task Name field, which is “Call_Sunrise”. You’ll do the same for the “Sunset” Schedule. Then you’ll add the rules to the Schedules.

Once you’ve clicked “Add Rule”, the Rule Dialog box will open. Here we’ll want to select the Schedule Type option, which will present 4 options. Two of those options will be Sunrise and Sunset.

Clicking the blue text in the dialog links to https://www.latlong.net. Here you can enter your address to get your current Latitude and Longitude.

After selecting the sunrise option for the sunrise task, and the sunset option for the sunset task, make sure that you enter the Latitude and Longitude of your current location for each, as this is how the JNIOR calculates the time of sunrise and sunset. Once entered, those tasks will now run at those times.

Sunrise and Sunset Scheduled tasks

Once this is all done, whenever it is sunrise/sunset for the day, Tasker will log each day when sunrise and sunset occur!

On this page