Using the Cronformat for automations

With Lumia Automations you can trigger messages, commands and actions in a simple way.

Just head to “Automations” on the left sidebar and press Add

image

In our example we make a simple ChatBot shout all 5 Minutes which leads our viewers to our commands page.

So we name it “welcome” and put it as Automation Type “Scheduler”. For showing the difference we use for now the Simplified Schedule. We put Run on to Minutes and we set it below to 5.
Our Value Type is a “Chatbot-Message” and below as Value we have to put our text:
Welcome to my Stream. If you want to play with my lights have a look at {{commands_url}}

Now every 5 minutes our Chatbot will send out this message.

A problem you will face is if you have more than one Automation running as this message will be run every 5 minutes straight. So it will run at 14:00:00, 14:05:00, 14:10:00… and so on. If you set another message all 5 minutes they will both trigger at the same time.

To avoid this we can use the Cron format.

To explain the cron format, I have to go back a bit.

If you switch off the Simplified Schedule you will see six asterisks. Each Asterisk specifics a time.
It is in order: Seconds / Minutes / Hours / Day of the month / Month / Day of the week

There are 4 operators for setting Cron:
* defines the respective column can have any value:
I.e. * * * * * * means “Do it every second in every minute on every hour, every day in every month”

/defines step sizes:
I.e. * */5 * * * * means “Do it all 5 minutes no matter what time, day or month it is”
0 */5 * * * * means “Do it all 5 minutes when seconds are 0 but else no matter what time, day or month it is”
* 3/5 * * * * means “Do it all 5 minutes starting at minute 3, else not matter, what time, day or month it is.” So it will start i.e. at 14:03:27 and continue at 14:08:27, 14:13:27 and so on. So when you set this up at 14:08:56 it will wait until 15:03:00 until it starts with the schedule.

- defines regions like Monday to Friday. This would look like this:
* * * * * 1-5 So it triggers no matter what time and month but only Monday to Friday. While Sunday is 0 or 7.

, separates enumarations.
I.e. 0 5,10,25 * * * * means “Do it at second 0 of a minute and minute 5, at minute 10 and minute 25 but NOT at minute 15 on every hour and every day in every month”

This sounds very confusing but once you got the logic it is easy as breathing.

IMPORTANT NOTE: If you set the seconds to * then it will trigger every second in your defined minute. So in most cases you want to set it to 0 or to a second you think fit.

Now that we know how to use Cronformat, we can build another Chat message, we want to send and organise the timing for it.

Our first message is pretty easy to set. We still want to run it every 5 minutes. So we put the time format like 0 */5 * * * *

For the second message, we decided that June will be our Twitter promotion month and we want to send it every 5 minutes. But we do not want it to trigger at the same time as our first message.
So we set it to 0 3/5 * * 6 * which means that it will trigger at minute 3 and will repeat all 5 minutes but only if the month is June.

IMPORTANT NOTE: If you set the seconds to * then it will trigger every second in your defined minute. So in most cases you want to set it to 0 or to a second you think fit.

And so we can create our schedule exactly to the second.

Here are some more examples:

Trigger at minute 5, 15, 25, 35 every hour every day.

image

Trigger at second 30 but only between minute 4 to 20 on every day. I.e. 16:06:30, 16:07:30…16:20:30, then it ends.

image

This looks similar to the one before but means: Trigger every 30 seconds on minute 4 to 20 every day. Like: 16:06:00, 16:06:30, 16:07:00

image

The next one means that it triggers on every Wednesday in the months January to June at 01:30:00 am

image

In most cases you only need something simple as: every 5 minutes or every 10 minutes what would look like this:

image

IMPORTANT NOTE: If you set the seconds to * then it will trigger every second in your defined minute. So in most cases you want to set it to 0 or to a second you think fit.