The Cron scheduler is most suitable for scheduling repetitive tasks. This scheduler allows you to periodically on/off one or more outputs at fixed times, dates, or intervals.

It is designed to work with an RTC clock module connected to the same chip.




Outputs – the comma-separated list of controlled outputs (e.g., 1,2,3,4)
On (duration) – when the Cron scheduler triggers an event, the firmware sets controlled outputs to the logical HIGH state. Then the firmware starts counting the specified number of seconds and changes the state back to LOW. If this value is zero, the scheduler is temporarily off.

Cron scheduler setup


After flashing the firmware, the scheduler is disabled because you need to set the Cron scheduler using your high-level system. The firmware saves a schedule in NVRAM and restores it after reboot. Please note, re-flashing clears the configured schedule.

Cron schedule string

The Cron schedule is very flexible, but it is challenging to set up the first time. The implemented Cron scheduler has the following design features:

  1. The scheduler support seconds in a schedule
  2. The scheduler does not support years in a schedule.

Therefore, a schedule should contain six parts, where the first part describes a schedule for seconds.

Example: 0 */2 * * * *

The following link allows you to prepare a schedule string visually. Also, you may find several examples there.

Zigbee internals


Zigbee attribute: ATTRID_IOV_BASIC_ACTIVE_TEXT (string data type, allows you to set or read a Cron schedule)
Zigbee commands: read, write.

Zigbee attribute: ATTRID_IOV_BASIC_MIM_ON_TIME (uint32, the “On” duration in seconds. It overrides the “On (duration)” parameter)
Zigbee commands: read, write.

Zigbee attribute: ATTRID_IOV_BASIC_OUT_OF_SERVICE (boolean, it contains the “Out of service” state.)
Zigbee commands: read.

Zigbee attribute: ATTRID_IOV_BASIC_PRESENT_VALUE (boolean, it is “True” when a controlled output is “HIGH,” and “False” when “LOW”)
Zigbee commands: read, write.

Zigbee attribute: ATTRID_IOV_BASIC_RELIABILITY (uint8, contains the error code if any)
Zigbee commands: read.

0 – no errors
1-4 – the invalid number in the expression.
5 – a range has only one number.
6 – a value in a range exceeds a maximum.
7 – a value in a range exceeds a minimum.
8 – a value in a range exceeds an end.
9 – an invalid comma-separated list.
10 – an incremented value requires two fields.
11 – an increment of argument is zero.
12 – error in the month name.
13 – error in the day name.
14 – empty Cron string.
15 – there is no free memory for a scheduler (a long schedule string).
16 – a schedule should contain six parts.
17 – there is no free memory.

Zigbee attribute: ATTRID_IOV_BASIC_STATUS_FLAG (uint8, bit #3 is set when a Cron schedule is out of order)
Zigbee commands: read.

Zigbee2MQTT commands

You should create a custom converter for your device, place it in the “data” folder, and add it to the configuration.

1. The following MQTT command immediately reads a Cron schedule.
Topic: zigbee2mqtt/[friedly_name]/[channel]/get/schedule
Channel: l1, l2, l3 … l16
Payload: 1
Returns: The current schedule {"schedule_[channel]": "string_value"}
2. The following MQTT command sets a new Cron schedule.
Topic: zigbee2mqtt/[friedly_name]/[channel]/set/schedule
Channel: l1, l2, l3 … l16
Payload: a schedule string (e.g. 0 */2 * * * *)
3. Read "On (duration)" value.
Topic: zigbee2mqtt/[friedly_name]/[channel]/get/on_time
Channel: l1, l2, l3 … l16
Payload: 1
Returns: The current schedule {"on_time_[channel]": decimal_value}
4. Set the new "On (duration)" value.
Topic: zigbee2mqtt/[friedly_name]/[channel]/set/on_time
Channel: l1, l2, l3 … l16
Payload: a new duration in seconds (e.g., 10)

There are no comments.

Leave a Reply