Skip to content

Device schedule

Riff edited this page Aug 4, 2022 · 3 revisions

To help better controlling the device automatically, Divoom Gateway supports schedule config to create tasks based on cron expressions.

Cron expression

Cron expression is a very powerful tool to describe a schedule, for examples:

Cron Explanation
0/10 * * * * * Every 10 seconds
0 15 10 * * * Every day at 10:15:00 AM
0 11 11 11 11 * Every year on Nov 11 at 11:11:00 AM

Schedule

With this, we can easily create a schedule that switches between channels:

schedules:
# At 0 seconds in every minute, show clock channel and set brightness to 10 (out of 100).
- cron: "0 * * * * *"
  operations:
  - channel set clock
  - system set-brightness 10

# At 20 seconds in every minute, show clock cloud and set brightness to 30 (out of 100).
- cron: "20 * * * * *"
  operations:
  - channel set cloud
  - system set-brightness 30

# At 40 seconds in every minute, show customPage cloud and set brightness to 80 (out of 100).
- cron: "40 * * * * *"
  operations:
  - channel set customPage
  - system set-brightness 80

For more on what operations we support, feel free to check our Device DSL doc.

Use it in Divoom Gateway

Divoom Gateway supports a config file, which allows us to specify schedules as part of the config.

Simply save the config above into a yaml file, and launch the gateway via the command below and give it a try!

divoom-gateway 192.168.0.123 -c divoom-gateway.yaml

Use it in SDK

The schedule tool is provided as part of the SDK - divoom crate as well.

If you are interested, the main function of Divoom Gateway serves as a very good example to start with: https://github.com/r12f/divoom/blob/main/divoom_gateway/src/main.rs.

Clone this wiki locally