Tag Archive: tasks

Tasker implements lots of different logic. One such instance are Logic Operators, specifically the AND Operator (&&) and OR Operator (||). We will start with the AND Operator, which will succeed if separate conditions are met simultaneously. For example, lets say we want to close Relay Output 3, but only if Relay Outputs 1 AND 2 are closed. To create this logic in Tasker, we’ll create an empty Task and add an If Statement to it, followed by adding a Close Relay 3 action inside the If Statement. Here we’ll enter the following:

rout[1].state == 1 && rout[2].state ==1

This statement evaluates as “If Relay Output 1 AND Relay Output 2 are closed, then close Relay Output 3”. Now if Relay Outputs 1 and 2 were closed when this Task runs, it will pass the If Statement condition and close Output 3.

&& goes between the two conditions that both need to be met

Next is the OR Operator which is less strict then the AND Operator, as its condition succeeds when at least one of multiple conditions are met. Lets use a similar example as before where we want to close Relay Output 3, but this time if EITHER Relay Outputs 1 and 2 are closed. We’ll do the same thing we did for the AND Operator by creating an empty task and adding an If Statement to it along with a Close Relay 3 action inside the If Statement. Here we’ll enter the following:

rout[1].state == 1 || rout[2].state ==1

This statement evaluates as “If either Relay Output 1 or Relay Output 2 are on, then close Relay Output 3”.

|| goes between the conditions where only one of them needs to be met

Lastly, a more advanced example can use both Operators in a logic statement at once. For example, lets say we want close Relay Output 3 if Relay Outputs 1 AND 2 are closer, OR if the time of day is past 2:00pm. We’ll add another if statement in an empty Task and add a Close Relay 4 action inside of it. Here we’ll enter the following:

(rout[1].state == 1 && rout[2].state == 1) || time.isAfter(“14:00”)

This statement evaluates as “If either Relay Output 1 and Relay Output 2 are on, or the current time is past 2:00pm, close Relay Output 3”.

() goes around the “rout[1].state == 1 && rout[2].state == 1” to group them together separately from the time function

When you have a JNIOR with a Temperature sensor connected to it, you can have Tasker trigger a Task when the temperature reaches a certain degree. This post shows an example doing this.

You’ll start by going to the Tasker web page, and once there we can start by creating a new workspace and then going to the Task tab. Here we’ll create the task we want to execute when the temperature reaches a certain temperature. In this example, we’ll pulse relay 1 for 7 seconds. You can do this by clicking the ‘new task’ button to create and name a new task, and then clicking the ‘add action’ button. This will open the action dialog box. You’ll want to go to the Output Relay section and select Pulse Relay. You’ll then set the first field of the action you added to 1 for output 1 and the second field to 7 for 7 seconds. We did this in the example below, naming the Task ‘Pulse_Relay_1’

After creating a task, we’ll then go to the Signal Tab. Here we’ll click ‘add signal’ and name the new signal we are creating. Once its created we’ll want to select the Signal type as Temperature probe, or Environmental sensor depending on which one you are using. The JNIOR can handle up to two Temperature sensors connected at one time, so unless you have two Temperature sensors connected the channel for the Signal will be 1. If you have two connected, set the channel according to which temperature sensor is first in the Registry order. One way to check this is by going to the External section of the Input/Output tab of the JNIOR web page, and seeing which expansion module is at the top as that one should be channel 1 and the one below it should be channel 2. Lastly you’ll want to determine what measurement of temperature you wish to use, (or humidity if you are using the environmental sensor). Once these values are set, you’ll then want to move to the Trigger Tab. Here is an example of the signal we created below, naming it Temperature_Sensor.

In the Trigger Tab you’ll want to click ‘add trigger’, giving it a name and selecting it as a continuous signal for its trigger type. Once the trigger is created you’ll want to set the trigger to the temperature sensor signal we created previously, along with what temperature will activate the trigger. Lastly, you’ll set the Task Name to the Task that you want executed when the trigger activates. We created this trigger below, naming it Temp_Trigger. The Task we set for this trigger is the one we created earlier, “Pulse_Relay_1”.

After that, you’ll save the the workspace and then should have a task that executes when your temperature sensor reaches a certain degree or humidity!

One of the actions you can perform in Tasker is the HTTP request action. This action allows you to post information to a specific URL. This post will show you an example of this.

You’ll start by going to the Tasker Web Page, and once you are there you’ll want to create new workspace, and then add a task to it. 

Once you’ve created and named a task for the workspace, you’ll want to add the HTTP request action to the Task. You’ll do this by clicking the add action button, and then selecting the HTTP request action in the Add Action Dialog box.


After you have added the HTTP request action to your Task, you’ll now want to enter the URL you wish to request from which will include the data that we are requesting. For this example, we are going to request a macro from the Cinema application. Here is a link to a post for installing the Cinema application if you don’t have it. This example assumes you’ve created a macro in the support tool called ‘pulse_output_1’, but the URL can include the name of any macro you have. Also the URL we are about to enter will use the IP address of 10.0.0.131, but this value should be of YOUR JNIOR’s IP address when doing a URL request to Cinema or the IP of whatever device you would be doing a HTTP request to. Lastly, the URL will include 8090 because that is the port Cinema listens on for macros. With this in mind, we’ll set the URL field to http://10.0.0.131:8090/macro?name=pulse_output_1.

You can then execute this task and Cinema will activate the macro included in the URL, which based off its name would have pulsed output 1 showing you have successfully sent a HTTP request!

A username:password@ can be provided prior to the IP Address for those HTTP requests the require login.

When using Tasker, to execute a task you can click the play button next to the task you wish to execute. But what if you wanted to execute a task remotely? This post explains how.

You’ll start by going to the Tasker Web Page, create a workspace, and then create a task inside the workspace. Give it an action so when we execute it remotely we can see it perform the action. Then save the workspace.

In this example, we created a task that simply pulses Output 1 for 5 seconds.

The next step to remotely communicating with Tasker in this example is by opening a command line session. You can do this through the JNIOR Support Tool by going to Tools/Command Line.

You can use any command line tool. Since the support tool provides a command line tool, that is what we use in this example.

Once you’ve opened a command line session, you can then connect to Tasker using a TCP connection and connecting to your JNIOR’s IP (ours is 10.0.0.120 for this example) and port 9210. You’ll activate all the setting in the option drop-down also.

Once this is done, all you need to do now is type the command to execute a task. To do this you type “task.execute TASKNAME\r\n”. So if you had a Task in Tasker called CloseOutput1, to execute it here remotely you would type “task.execute CloseOutput1\r\n”.

With this, you should now be able to remotely execute Tasks in Tasker!

In Tasker, the JNIOR can interact with the MQTT application to publish data to a specific topic. This post explains how with an example.

To start, you’ll want to make sure that you have both the Tasker and MQTT application. Once you do, we’ll start with opening the MQTT application web page which you can access by opening a web browser and going to the URL http://JNIOR_IP/mqtt. The MQTT page is where we configure the MQTT broker, which manages all topics and handles the subscriptions. To use MQTT you need to find a broker to interact with. The one we are using in this example is broker.hivemq.com which is free. We don’t recommend this broker for anything serious or commercial, as it is not secured or dedicated.

http://www.mqtt-dashboard.com/

For this example we will enter HiveMQ’s broker information on the right side of the page. Not all the boxes are required. The only information we need for the HiveMq broker is the MQTT Broker Host address. HiveMQ uses the default 1883 port number. After that if the connection hasn’t already been set, click the connect button and you should be connected with the HiveMQ Broker.

NOTE: The bottom of the MQTT web page also shows what topics you can interact with for MQTT. This will be useful as a reference when creating the MQTT publish action in Tasker.

More topics are available on the MQTT web page

Once you have established a connection with a broker on the MQTT web page, the next step is to open the Tasker web page. Once there, the first thing you’ll want to do is create a new workspace. We’ve named our example MQTT_Example. 

Once the workspace is created you’ll want to create a new Task in the Task Tab, and then add the MQTT publish action from the Add Action button to the Task.

After adding the MQTT publish action, you can now set the topic in the top field of the action, and the data you wish to publish to the topic in the bottom field. In this example, we publish to the state of output 1 on a JNIOR to switch it from false to true, turning the output ON.

The value after ‘jnior’ in the picture above is the serial number of the JNIOR we use in this example

After executing this task, you will have published an MQTT topic to your JNIOR and set Output 1 to ON!

The Control Panel is a very useful add-on to the JNIOR.  It gives you manual switches, visual indicators and an audio alarm.  Each of these features can be configured and used in Tasker.  Let’s check out how!

Before addressing how Tasker works with the Control Panel, you’ll want to make sure its connected properly. You can do so by using the extern command. When you are sure the Control Panel is correctly connected you’ll be able to integrate it with Tasker.

Here are the actions associated with the Control Panel.  Each one will be talked about in depth further down this post.

Control Panel actions for Tasks in Tasker

Using the Control Panel Switches as a Trigger

To enable the Control Panel Switches to be a Trigger that will be used to activate a Task is a very simple process. You only need to go to the trigger tab and add a trigger type set to the control panel switches.

Triggers have an automatic reset of 10 seconds after activating, but the reset can be made to activate based off other actions or different time intervals. Resets prevent the trigger from activating again until the reset condition has been met.

Using the Visual Indicators in a Task

The Visual Indicators on the Control Panel are the the 12 LEDs labeled L1 through L12.  The LEDs can be controlled by setting them to be OFF, ON, or to flash at different rates.  The LED will be on or flashing until it is turned off.

Set Control Panel LED Tasker example

Using the Audio Alarm in a Task

The Control Panel has a PC speaker on the back on the unit that can produce an audible alarm.  This is great for alerting people without the person needing to be looking at the Control Panel already.  Here is the setup when configuring the Alarm to be played.

The alarm plays with an oscillating sound.  You can select between slow, medium, fast, or custom.  Then a duration is needed in seconds followed by the volume on a scale of 0 – 100%.

Control Panel alarm Tasker example

If the custom option is selected then then additional options of the audio frequency to use and the duration of each beep are presented.

Control Panel alarm custom example

You can also elect to Silence and Alarm.  Maybe you have an alarm that plays for 60 seconds but can be silenced when someone responds to a given situation.  To do that we will use the Silence Alarm action.

 

Note: This functionality will require at least Tasker version 3.9

There are times when we want to log a temperature.  To do this we need to select a time interval between samples.  This interval can either be too short or too long.  Very rarely can we get the perfect interval.  A short interval leads to redundant data where the temperature doesn’t change often and several samples log the same temperature in a row.  A long interval can hide valid temperature changes.

So we ask ourselves, what do we really want?  The answer is usually that we want to know when the temperature changes.  Using the setup below, we can achieve the desired functionality. 

Configuration

The following image shows how we can set up a Task with Variables and Logic to only Log when the temperature changes.  The global variables make sure the current temperature values that are used in the logic are used when making the log entry.

Tasker Logging workspace

This screenshot shows how to configure the Logger to use the global variables.

Loggers in Tasker

This screenshot shows configuring the schedule to call the Task with a short interval.  The logic within the Task is responsible for making sure the log entries only occur when there is a valid temperature change.

Scheduled Log Tasks in Tasker

Result

Here is the result of a the functioning configuration over the past 15 minutes.  You’ll notice that the temperature changes, but it tends to bounce back and forth between two or three values.  We can handle that in another article!

Logged Temperature values

This feature is available in Tasker v3.1 and later.

The SNMP application offers built-in Traps when the digital inputs and relay outputs change. Tasker takes this further allowing you to send a SNMP Trap as a part of a Task. The value of the Trap can be custom and dynamic based on the message building rules of Tasker. An example of using a custom SNMP message in Tasker is below.

The first thing we need to do is make sure that SNMP is running. The feature covered in this post is available in SNMP v2.6 and greater. Once we know that SNMP is running we can Create or Open a Tasker Workspace.

To send a SNMP Trap we will need to add the SNMP Trap action to a Task. You can create a new Task for this action or add it to an already existing Task. The action will ask for the SNMP OID (Object Identifier), the message to send and the device to send the Trap to. The device to receive the Trap can be the built-in Trap Host that is defined in the SNMP application or a new one can be defined in the Devices Tab.

Upon selecting the SNMP Trap action you will be presented with the following

Send SNMP Trap empty

Here is what it will look like after entering some information

Send SNMP Trap example

Without defining a SNMP Device, the Trap will be sent to the Trap Host that is defined in the SNMP application. You can optionally define a new Trap Host by clicking + Add Device in the Devices Tab.

Tasker Add Device Action

You will be presented with a Dialog asking for a Device Name and the Device Type. Enter any name and select SNMP Device from the Device Type drop down.

Tasker Create New Device dialog

Now you can enter the Trap Host information as shown here.

Device tab in Tasker

Now back in our Task Action we will see this Device as an option.

SNMP Trap Action with Device in Tasker

Save the Workspace in the File menu and your Custom Trap will be able to be sent!

Advanced Usage

You can send a dynamic message. A dynamic message is one that has different data based on our message building rules. Here we will send the current temperature.

SNMP Trap Action Example

A defined Signal could also be used here instead of temp[1].f and a Trigger could be used to cause the Trap to get sent as described in the using signals and triggers post.

The TaskerApplication has a lot of different functionality built into its actions, but it also can handle logic too. One of those actions that you can create in Tasker is the If block action. This post will create two If blocks in Tasker, one being the If block and the other being the If/else block.

Create an If Block

To start, create a new workspace by going to the File Drop-Down and selecting new. After that, go into the Task tab of Tasker and select the “Add Task” button. Once you name your Task, you’ll click on it and select the “Add Action” button. This will bring up the Action Dialog box. Here we need to select the If block action in the Control Structures section of the Action Dialog box. Once we have our If block in the task, we’ll want to add one more action inside of the If block by selecting the “Add Action” button inside of the If block. Here we’ll also select the Pulse Output Relay action.

Tasker If Example empty

Setting the If Block Actions

Now that our actions have been added to the Task, we can now configure them to do what we want. For this example, we are going to configure the if statement to activate when Input 1 goes high. To check if the input is high, for the If block value field we’ll enter din[1].state == 1.

With this, the If block will Pulse Output Relay 1 for 1 second if Input 1 is high.

Tasker If Example

Create an If/Else Block

In the workspace, go into the Task tab of Tasker and select the “Add Task” button. Once you name your Task, you’ll click on it and select the “Add Action” button. This will bring up the Action Dialog box. Here we need to select the If/else block action in the Control Structures section of the Action Dialog box. Once we have our If block in the task, we’ll want to add two more actions inside of the If/else block by selecting the “Add Action” button inside of the If/else block. Here we’ll select the Pulse Output Relay action inside the conditional part of the If/else block , and the Pulse Output Relay action inside for the “else” part of the If/else block.

Tasker If/Else Example empty

Setting the If/Else Block Actions

With the actions being added to the Task, we can now configure them to do what we want. For this example, we are going to configure the If block to Pulse Output Relay 1 when Input 1 goes high, and Pulse Output Relay 2 when Input 1 isn’t high. For the If/else block value field, to check if the input is high we’ll enter din[1].state == 1. For the first Pulse Output Relay, we’ll set the channel to 1, and for the other pulse relay we’ll set the channel to 2.

With this, the If/else block should Pulse Output Relay 1 for 1 second when Input 1 is high, and Pulse Output Relay 2 for 1 second when Input 1 is not high.

Tasker If/Else Example

Signals and Triggers are very useful tools in the Tasker application. Signals are I/O values on either the JNIOR or a compatible expansion module with the JNIOR. Triggers are reactions to when a signal occurs. This post will explain all the parts of the Signal and Trigger tabs in detail.

The Signal Tab

To start, since signals in the Signal tab can be used in triggers we’ll start with Signals. Signals are I/O values on either the JNIOR or a compatible expansion module with the JNIOR. Each Signal values has what device the Signal is coming from, the channel number of the value, and then the type of value its getting. These can be used either in a Trigger or to set/evaluate the value of a variable defined in a task.

Tasker Signal Example

The Trigger Tab

The Trigger is a reaction to a Signal value. Triggers are made up of first, a Trigger value that watches a Signal to react to, along with what the Signal value needs to be to activate the Trigger. Second, is the Reset value that monitors a Signal like the Trigger value does. This is optional and a reset value is not required. If you don’t set a reset value for a Trigger, the Trigger value will always activate the Trigger. If you do add a Reset value, a Trigger that has activated won’t activate again until the reset value condition is met. Lastly, a task name is selected as the task to run when the Trigger value is met and the Trigger activates.

There are currently 5 types of events that can be added as a value for a trigger or reset. The first is a discrete signal, which consists of Input or Output changes going High or Low. The second is a continuous signal, which pertains to the temperature and 4-20ma/10volt values that are constantly being reported and updated. Discrete and continuous values use the signals created in the Signal Tab as the values available in a trigger. Third is the control panel switch signal, which as is name suggests is for when a switch on the control panel is pressed. Forth is the multi-switch control panel signal, which is that same as the normal control panel signal but is activated from two switches being pressed at the same time. Lastly, is the delayed Reset which activates a reset after a certain duration. As the name suggests, this is only available for the reset and can’t be used as a trigger signal. The control panel and delay reset values do not need to be made as signals in the Signal Tab to be used in a trigger, while the discrete and continuous signals do.

Tasker Trigger Example

These steps show show you how to properly create a Signal and Trigger.

Example

The example below will show you how to make a Trigger activate when Relay output 1 on the JNIOR goes High.

We’ll create two Signals with the first ones values being: Device is the Relay Output states of a JNIOR, the channel 1, and the type being the state. The second ones values would be: Device is the Relay Output states of a JNIOR, the channel 2, and the type being the state.

Tasker Signal Reset

Afterwards you would begin configuring a Trigger. The Trigger values would be the Example Signal we created, and its trigger value will be high. For the Reset values, we’ll select the Example Signal Reset we created as the Reset value, and its reset value will be high as well. Lastly, we’ll pick whichever task we want to run during the Trigger activation as the Task value. In this example my task I created is Example Task. The final product of this example is a trigger that will activate when Relay Output 1 goes high. It won’t activate again though until Relay Output 2 goes high.

The Tasker application has a lot of different functionality built into its actions, but it also can handle logic. One of those logic actions that you can create in Tasker is the loop action. This post will create two loops in Tasker, one being the for loop and the other being the while loop.

Creating a For Loop

To start, create a new workspace, by going to the File Drop-Down and selecting new. After that, go into the Task tab of Tasker and select the “Add Task” button. Once you name your Task, you’ll click on it and select the “Add Action” button. This will bring up the Action Dialog box. Here we need to select the for loop action in the Control Structures section of the Action Dialog box. Once we have our loop in the task, we’ll want to add two more actions inside of the loop by selecting the “Add Action” button inside of the loop. Here we’ll also select the Pulse Relay action and the Sleep action.

Setting the For Loop Action Values

Now that we have our Task’s actions added, we can configure their values to what we want, which is to have our loop use a variable to pulse relays 1 – 3 for 2 seconds, with a 1 second delay between them. To do this, we’ll start by setting the variable in the first field value of the loop action, which in this example we will make ‘a’. The other loop fields are to set how many times the loop will repeat, and since we want to pulse 3 relays we’ll set the second loop field to 1 and the third to 3.

Next for the Pulse Relays action, the first field will be replaced with the variable we created in the first field of the loop action, ‘a’. After that we’ll want the second field set to 1, since we want it to pulse for 1 seconds. Lastly, we’ll set the sleep action to 2 seconds so that no relay is pulsing at the same time as another, and has 1 second delay between each other.

With this, your loop should be configured properly. Now it will loop through output relays 1 – 3 on your JNIOR, pulsing each relay for 1 second with a 1 second delay between each relay pulsing.

Creating a While Loop

For creating a while loop, in your workspace go into the Task tab of Tasker and select the “Add Task” button. Once you name your Task, you’ll click on it and select the “Add Action” button. This will bring up the Action Dialog box. Here we need to select the while loop action in the Control Structures section of the Action Dialog box. Once we have our loop in the task, we’ll want to add two more actions inside of the loop by selecting the “Add Action” button inside of the loop. Here we’ll also select the Pulse Relay action and the Sleep action.

Tasker While Loop Action empty

Setting the While Loop Action Values

Now that we have our Task’s actions added, we can configure their values to what we want, which is to have our loop use a variable to check the state of input 1, and if its high (equal to 1) to pulse output 1 for 1 second with a one second delay between it every time it pulses. To do this, we’ll start by setting the variable in the field value of the loop action to din[1].state == 1 to check if input 1’s state is high. Then we’ll set the pulse output of whichever relay we wish to pulse for 1 second, with a second sleep so it will pulse for 1 second, and then wait 1 second.

Tasker While Loop Action

Tasker is able to perform many different things, one of which is the ability to log information. Tasker contains a Logger tab that can create Logger profiles to record data. These Loggers tell what needs logged and which file it should be stored in when used in a task. This post will show how to record temperature values from an environmental sensor using Tasker.

In order to setup Tasker to record temperatures from a environmental sensor, there are a few step we need to take:

  1. First we need to create Signals in the Signal Tab. These will be used in the Logger tab to record their values.
  2. Next we create a Logger in the Logger tab. Here we use the Signals to document their values in log files.
  3. After creating the Logger, we now go to the Task tab and create a task that includes the Logger that was just created.
  4. Finally, once the task is created, in the Schedule tab we create a Schedule that runs the task for however often we wish to record the environmental sensor values.

NOTE: In step 4 you can also use a Trigger, but this example will focus on using a Schedule.

Creating Signals

Signals are Input/Output values from the JNIOR or from expansion modules compatible with the JNIOR. In this example we are using a environmental sensor expansion module to record these values. First we’ll create a new workspace using the File Drop-Down. Then in the Signals tab, After clicking the “Add Signal” button, we’ll create a new signal called Temp_1. After the Signal is created, it has three value fields to fill out. The first one is the Signal drop down value, where you will pick where we are getting the Input/Output values from. As stated previously, we are grabbing these values from a environmental sensor, so we’ll select it from the drop down options. Next is the channel for the environmental sensor. Each channel represents a different environmental sensor. Since we are only using one sensor, we’ll select channel 1. Lastly is the variable type, and while the values you can get are either Celsius, Fahrenheit, or humidity, we are going to be logging the info in Fahrenheit, so that’s what we’ll chose.

Signal tab in Tasker

Creating a Logger

Now that the Signal is created, we can create a Logger to record those values to a file. We’ll go to the Logger tab and select “Add Logger”. The first value is the File Name, which is where you define what the name of the log will be when its created, and the file path on the JNIOR where it will be saved. In our example, we used the file path /flash/tasker/logging/temps-{{date(YYMMDD)}}.log. If you run this logger and go to the directory on the JNIOR where you saved this log, you’ll see the date(YYMMDD) will be replaced with the date the log was created. After this is the Headers field which create headers in the log right above where values will be added. We define a header in the example that will add Temperature to the top of the log. The next field is the Timestamp Format, which defines how the time is recorded next to the value being logged, leaving this blank will used the grayed out default (MM/dd/yy HH:mm:ss zzz).  After that is the Schema field, which lets you define what values should be logged when the logger activates, here we simply log the temperature from a Temp sensor connected to the JNIOR by entering {{temp[1].f}}. Lastly, is the file retention count. All this does is decide how many files of information Logger will create before overwriting previous files, so if the number is set to 10, once Logger has created 10 files of information, next file it create will overwrite the previous 1st Logger file. This example uses 30.

Here is the resulting log on the JNIOR created from the Logger.

Creating a Task

With the Logger being created, we now need a task that uses our Logger so it will activate and record the data we want. In the Task tab, we’ll select the button “Add Task”. Once the Task is named, click on its name and select “Add Action”. The Action Dialog box will appear which has all the actions a task can perform. Here we’ll select the Log Profile action, which we can use to call the Logger we created in the Task. Once the action is added, the only value to enter is the name of the Logger we just created. This will now make the Task activate the Logger each time its run.

Task tab in Tasker

Creating a Schedule

Lastly, having a task activate a Logger is good, but it will only record when you activate it. Adding the task to a schedule will allow us to record these values on a time interval. Going to the Schedule tab, you’ll click on the “Add Schedule” button. After naming the Schedule, there will be two options to fill out. The first one appears by selecting the “Add Rule” button, which will bring up the Rule Dialog box where you can configure when the schedule is timed. For this example we will set the Schedule type to schedule so we have more options rules to pick from. The start on date is  the date for whenever you want the schedule to begin activating the task you set with it. Next is the Start Time, Repeat Every, and End Time options (End Time appears after you edit Repeat Every). We set both the Start and End Time to Midnight so that the interval is always running. Repeat Every is set to 2.5 minutes so that with the Start and End time set, the task will run every 2.5 minutes for an entire day. For the Date Selection type, we used daily in this example so we can set the Recur Every option to 1. This will make the task run every day. Lastly, after completing the Rules for the schedule, we add a task that we want the schedule to activate based off the rules we set for it, which will be the task we created in the Tasks tab.

Scheduling Tasks in Tasker

Once the Schedule is completed, the Logger will now record the Signal values of the environmental sensor as values in a .csv file from a task that is scheduled to run every 2.5 minutes, every day.

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!

To monitor the environment with the JNIOR you will need 3 things. First, either the Environmental Sensor or the Rugged External Temperature Sensor. Second, the Tasker application that will read that sensor and log the values. Third, the Grapher application to graph the data logged from Tasker.

INTEG resells an environmental sensor from Embedded Data Systems. The sensor itself wont work directly with the JNIOR until it is wired. They have several different models that provide different environmental metrics. Temperature and humidity have been the consistent requests. INTEG also sells a rugged external sensor that tracks just temperature.

NOTE: Only the Environmental Sensor records humidity.

Set Up

The first thing to check when setting up is the sensor module you connect to the JNIOR. In the Console Tab of the JNIOR Web Tool, commands you can use to see what sensor is connected are the extern command to tell you what modules you have connected, and the extern -r command to remove a module on your device that is no longer connected. To tell which sensor module you have connected, look at the ID of the device from the extern command. If it ends with 7E its the Humidity Sensor, if its 28 its the Rugged External Temperature sensor.

extern command for JNIOR command line

After that, you’ll want to make sure that you have the applications to graph the data logged.

Name Version Release Date Size MD5
Tasker v12.0 Jun 20 2023 2.9 MB edfd2578eccdf8595b4f3d35f1ca4bf8
Grapher v4.1 Jun 18 2020 788.5 KB 75e992513636e0c45c7aa7f71d8c1303

You’ll want to do an update project one at a time, publishing these to the JNIOR you have the sensor connected to. After that, to get to the Grapher application, you can either type (JNIOR’s IP)/Grapher into the URL of a web browser or you can select it under the tools tab of Tasker to take you to the application. There you can create the graph to monitor your Temperature. 

Once on the Grapher application page, you’ll want to go to the Grapher Configuration page to enter settings for creating a graph. You can access this by going to the top of the Grapher application page and at the top click Tools/Grapher Configuration. To start, you can go down to the files section and add the files that give the values to be put on a graph.

At the top, you can define the directory path of the file you want monitored, but keep in mind whatever path and file name is set here should match what you set in the Tasker application. The column value field is where you enter what you want the names of the values from the log file in Tasker to be called. One of the column values needs to be Timestamp since the graph needs that information to know where to plot it the value being pulled. The Date format can be set to MM-DD-YY HH:mm:ss.SSS. The file count is specified to how many files you want added. After setting this, you can configure the Graph section described below that will be monitored for the graph.

Here you can create the graph name, and then set the range of the graph and also the time range being charted. Below that you can create the lines that go into the graph that are tracked. You can add their names, what the units they are measured in are called, and the color of the line. Once this is all set you’ll now want to open the Tasker application by typing in the URL (JNIOR’s IP)/tasker, or by clicking the link for it from the JNIOR Web Page in the applications section of the Configuration tab.

In the Tasker application, the first thing we’ll want to do is create a workspace. After that we’ll create a Logger using the Logger Tab. Once on the Logger Tab of Tasker, clicking the “add Logger” button will create an empty Logger in the Logger Tab, which you can name Log_Temp for this example. This is where the file will be created that Grapher pulls the data from to graph.

Like in the picture above, you’ll want to set the log file path. The one in the example is called temps-{{date(YYMMDD)}}.csv just like the one named in the file section in Grapher of this example, the only difference being that the YYMMDD has “” around it while the file section in Grapher should not. (The date.format part of the file name auto inputs the date when creating the file). The Timestamp Format specifies the Timestamp of when the value are logged. This is needed to know where the files need to be plotted in Grapher, which is also why we included the Timestamp value in Grapher eariler. Entering nothing in the Timestamp Format field will default it to MM/dd/yy HH:mm:ss zzz, so you don’t need to enter anything in this field unless you want to change formatting of the default timestamp. The Schema field will contain separate values that act as the referenced schema values we defined in the graph section of Grapher.

For how the schema values work, they simply refer to values on the JNIOR such as the I/O or analog values. The double squiggly brackets and comma between each value are needed to separate each value. The picture above uses Signals from the signal tab, so you’ll need to go to the Signal tab after this and create two signals for Celsius and Fahrenheit for the humidity temperature sensor. Make sure the names in brackets in the schema under logger and the signal names in the signal tab match each other. More information on how to reference values on the JNIOR in a Logger, go to the help drop down at the top of the Tasker page and select the help link.

After defining the values for the Logger in Tasker, we’ll now want to create a Task in the Task Tab of Tasker. Once in the Task Tab, we’ll select the “add Task” button. This will add an empty Task to Tasker that you can name. Once we do that, we’ll want to select the “add Action” button to add an action to the Task to run the Logger we just created. In the action submenu we’ll want to select the Force Log Profile action. Once its added, we’ll enter the Logger name we created earlier to the action so it’ll run that Logger every time the Task runs.

Once that is done, we’ll now add a schedule that runs every two minutes so the graph is constantly getting more data every two minutes.

Going to the schedule Tab, we’ll click the “add Schedule” button to add an empty schedule to Tasker. We’ll then select the “add Rule” button to open the rule submenu. Here we’ll set the Schedule to run every two minutes, every day, from Midnight to Midnight like shown in the picture below. We’ll also set the schedule to run the Task that activates Logger to every two minutes.

Once this is all set up, going back to the Grapher application should now give you a graph of the logged temperatures!

Grapher Main Page